adding ebeat function
This commit is contained in:
@ -23,7 +23,6 @@ interface Pattern<T> {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is an override of the basic "includes" method.
|
||||
*/
|
||||
@ -806,11 +805,17 @@ export class UserAPI {
|
||||
get ebeat(): number {
|
||||
/**
|
||||
* Returns the current beat number since the origin of time
|
||||
* TODO: fix! Why is this not working?
|
||||
*/
|
||||
return this.app.clock.beats_since_origin;
|
||||
}
|
||||
|
||||
get epulse(): number {
|
||||
/**
|
||||
* Returns the current number of pulses elapsed since origin of time
|
||||
*/
|
||||
return this.app.clock.pulses_since_origin;
|
||||
}
|
||||
|
||||
onbar(n: number, ...bar: number[]): boolean {
|
||||
// n is acting as a modulo on the bar number
|
||||
const bar_list = [...Array(n).keys()].map((i) => i + 1);
|
||||
|
||||
15
src/Clock.ts
15
src/Clock.ts
@ -41,13 +41,13 @@ export class Clock {
|
||||
tick: number
|
||||
|
||||
constructor(public app: Editor, ctx: AudioContext) {
|
||||
this.time_position = { bar: 0, beat: 0, pulse: 0 }
|
||||
this.time_signature = [4, 4];
|
||||
this.tick = 0;
|
||||
this.bpm = 120;
|
||||
this.ppqn = 48;
|
||||
this.transportNode = null;
|
||||
this.ctx = ctx;
|
||||
this.tick = 0;
|
||||
this.time_position = { bar: 0, beat: 0, pulse: 0 }
|
||||
this.bpm = 120;
|
||||
this.time_signature = [4, 4];
|
||||
this.ppqn = 48;
|
||||
ctx.audioWorklet.addModule(TransportProcessor).then((e) => {
|
||||
this.transportNode = new TransportNode(ctx, {}, this.app);
|
||||
this.transportNode.connect(ctx.destination);
|
||||
@ -70,7 +70,6 @@ export class Clock {
|
||||
return nextBarinTicks - currentBeatInTicks
|
||||
}
|
||||
|
||||
|
||||
get beats_per_bar(): number {
|
||||
/**
|
||||
* Returns the number of beats per bar.
|
||||
@ -82,6 +81,10 @@ export class Clock {
|
||||
return (this.time_position.bar - 1) * this.beats_per_bar + this.time_position.beat;
|
||||
}
|
||||
|
||||
get pulses_since_origin(): number {
|
||||
return (this.beats_since_origin * this.ppqn) + this.time_position.pulse
|
||||
}
|
||||
|
||||
get pulse_duration(): number {
|
||||
/**
|
||||
* Returns the duration of a pulse in seconds.
|
||||
|
||||
Reference in New Issue
Block a user