23
src/API.ts
23
src/API.ts
@ -164,9 +164,14 @@ export class UserAPI {
|
||||
// Transport functions
|
||||
// =============================================================
|
||||
|
||||
bpm(bpm: number): void {
|
||||
bpm(bpm?: number): number {
|
||||
if (bpm === undefined)
|
||||
return this.app.clock.bpm
|
||||
|
||||
this.app.clock.bpm = bpm
|
||||
return bpm
|
||||
}
|
||||
tempo = this.bpm
|
||||
|
||||
time_signature(numerator: number, denominator: number): void {
|
||||
this.app.clock.time_signature = [numerator, denominator]
|
||||
@ -210,12 +215,16 @@ export class UserAPI {
|
||||
get bar(): number { return this.app.clock.time_position.bar }
|
||||
get pulse(): number { return this.app.clock.time_position.pulse }
|
||||
get beat(): number { return this.app.clock.time_position.beat }
|
||||
get beats_since_origin(): number { return this.app.clock.beats_since_origin }
|
||||
|
||||
onbar(...bar: number[]): boolean {
|
||||
return bar.some(b => b === this.app.clock.time_position.bar)
|
||||
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);
|
||||
console.log(bar_list)
|
||||
console.log(bar.some(b => bar_list.includes(b % n)))
|
||||
return bar.some(b => bar_list.includes(b % n))
|
||||
}
|
||||
|
||||
// TODO: bugfix here
|
||||
onbeat(...beat: number[]): boolean {
|
||||
let final_pulses: boolean[] = []
|
||||
beat.forEach(b => {
|
||||
@ -235,7 +244,6 @@ export class UserAPI {
|
||||
}
|
||||
|
||||
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) }
|
||||
|
||||
euclid(pulses: number, length: number, rotate: number=0): boolean {
|
||||
@ -266,9 +274,8 @@ export class UserAPI {
|
||||
// Small ZZFX interface for playing with this synth
|
||||
zzfx = (...thing: number[]) => zzfx(...thing);
|
||||
|
||||
playSound = async (values: object) => {
|
||||
sound = async (values: object) => {
|
||||
await this.load;
|
||||
webaudioOutput(sound(values), 0.01)
|
||||
webaudioOutput(sound(values), 0.00)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user