playing a bit
This commit is contained in:
23
src/API.ts
23
src/API.ts
@ -4,8 +4,7 @@ import { tryEvaluate } from "./Evaluator";
|
|||||||
import { MidiConnection } from "./IO/MidiConnection";
|
import { MidiConnection } from "./IO/MidiConnection";
|
||||||
import { next } from "zifferjs";
|
import { next } from "zifferjs";
|
||||||
import {
|
import {
|
||||||
superdough,
|
superdough, samples,
|
||||||
samples,
|
|
||||||
initAudioOnFirstClick,
|
initAudioOnFirstClick,
|
||||||
registerSynthSounds
|
registerSynthSounds
|
||||||
} from 'superdough';
|
} from 'superdough';
|
||||||
@ -17,8 +16,6 @@ const init = Promise.all([
|
|||||||
registerSynthSounds(),
|
registerSynthSounds(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DrunkWalk {
|
class DrunkWalk {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,8 +227,8 @@ export class UserAPI {
|
|||||||
this.MidiConnection.sendMidiNote(note, channel, velocity, duration)
|
this.MidiConnection.sendMidiNote(note, channel, velocity, duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
public zn(input: string, options: {[key: string]: any} = {}): void {
|
public zn(input: string, options: {[key: string]: number} = {}): void {
|
||||||
const node = next(input, options);
|
const node = next(input, options as any);
|
||||||
const channel = options.channel ? options.channel : 0;
|
const channel = options.channel ? options.channel : 0;
|
||||||
const velocity = options.velocity ? options.velocity : 100;
|
const velocity = options.velocity ? options.velocity : 100;
|
||||||
const sustain = options.sustain ? options.sustain : 0.5;
|
const sustain = options.sustain ? options.sustain : 0.5;
|
||||||
@ -261,7 +258,6 @@ export class UserAPI {
|
|||||||
this.MidiConnection.sendPitchBend(value, channel)
|
this.MidiConnection.sendPitchBend(value, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public program_change(program: number, channel: number): void {
|
public program_change(program: number, channel: number): void {
|
||||||
/**
|
/**
|
||||||
* Sends a MIDI program change to the current MIDI output.
|
* Sends a MIDI program change to the current MIDI output.
|
||||||
@ -556,20 +552,20 @@ export class UserAPI {
|
|||||||
// Transport functions
|
// Transport functions
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
||||||
bpm(bpm?: number): number {
|
bpm(n?: number): number {
|
||||||
/**
|
/**
|
||||||
* Sets or returns the current bpm.
|
* Sets or returns the current bpm.
|
||||||
*
|
*
|
||||||
* @param bpm - [optional] The bpm to set
|
* @param bpm - [optional] The bpm to set
|
||||||
* @returns The current bpm
|
* @returns The current bpm
|
||||||
*/
|
*/
|
||||||
if (bpm === undefined)
|
if (n === undefined)
|
||||||
return this.app.clock.bpm
|
return this.app.clock.bpm
|
||||||
|
|
||||||
if (bpm < 1 || bpm > 500)
|
if (n < 1 || n > 500)
|
||||||
console.log(`Setting bpm to ${bpm}`)
|
console.log(`Setting bpm to ${n}`)
|
||||||
this.app.clock.bpm = bpm
|
this.app.clock.bpm = n
|
||||||
return bpm
|
return n
|
||||||
}
|
}
|
||||||
tempo = this.bpm
|
tempo = this.bpm
|
||||||
|
|
||||||
@ -976,4 +972,5 @@ export class UserAPI {
|
|||||||
sound = async (values: object, delay: number = 0.00) => {
|
sound = async (values: object, delay: number = 0.00) => {
|
||||||
superdough(values, delay)
|
superdough(values, delay)
|
||||||
}
|
}
|
||||||
|
d = this.sound
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export class Clock {
|
|||||||
this.time_position = { bar: 0, beat: 0, pulse: 0 }
|
this.time_position = { bar: 0, beat: 0, pulse: 0 }
|
||||||
this.bpm = 120;
|
this.bpm = 120;
|
||||||
this.time_signature = [4, 4];
|
this.time_signature = [4, 4];
|
||||||
this.ppqn = 48;
|
this.ppqn = 48*2;
|
||||||
ctx.audioWorklet.addModule(TransportProcessor).then((e) => {
|
ctx.audioWorklet.addModule(TransportProcessor).then((e) => {
|
||||||
this.transportNode = new TransportNode(ctx, {}, this.app);
|
this.transportNode = new TransportNode(ctx, {}, this.app);
|
||||||
this.transportNode.connect(ctx.destination);
|
this.transportNode.connect(ctx.destination);
|
||||||
|
|||||||
Reference in New Issue
Block a user