commit stuff

This commit is contained in:
2023-08-04 13:21:15 +02:00
parent 44ee91a433
commit 8927cdd4c5

View File

@ -329,10 +329,43 @@ export class UserAPI {
// ============================================================= // =============================================================
// Time markers // Time markers
// ============================================================= // =============================================================
get tick(): number { return this.app.clock.tick }
get bar(): number { return this.app.clock.time_position.bar } get bar(): number {
get pulse(): number { return this.app.clock.time_position.pulse } /**
get beat(): number { return this.app.clock.time_position.beat } * Returns the current bar number
*/
return this.app.clock.time_position.bar
}
get tick(): number {
/**
* Returns the current tick number
*/
return this.app.clock.tick
}
get pulse(): number {
/**
* Returns the current pulse number
*/
return this.app.clock.time_position.pulse
}
get beat(): number {
/**
* Returns the current beat number
*/
return this.app.clock.time_position.beat
}
get t_beat(): number {
/**
* Returns the current beat number since the origin of time
* TODO: fix! Why is this not working?
*/
return Math.floor(this.app.clock.tick / this.app.clock.ppqn)
}
onbar(n: number, ...bar: number[]): boolean { onbar(n: number, ...bar: number[]): boolean {
// n is acting as a modulo on the bar number // n is acting as a modulo on the bar number
@ -385,10 +418,8 @@ export class UserAPI {
mod(...pulse: number[]): boolean { return pulse.some(p => this.app.clock.time_position.pulse % p === 0) } mod(...pulse: number[]): boolean { return pulse.some(p => this.app.clock.time_position.pulse % p === 0) }
modbar(...bar: number[]): boolean { return bar.some(b => this.app.clock.time_position.bar % b === 0) } modbar(...bar: number[]): boolean { return bar.some(b => this.app.clock.time_position.bar % b === 0) }
euclid(pulses: number, length: number, rotate: number=0): boolean { euclid(iterator: number, pulses: number, length: number, rotate: number=0): boolean {
const pulse = this.app.clock.time_position.beat; return this.euclidean_cycle(pulses, length, rotate)[iterator % length];
const nextPulse = pulse % length;
return this.euclidean_cycle(pulses, length, rotate)[nextPulse];
} }
euclidean_cycle(pulses: number, length: number, rotate: number = 0): boolean[] { euclidean_cycle(pulses: number, length: number, rotate: number = 0): boolean[] {