playing a bit

This commit is contained in:
2023-08-12 00:30:06 +02:00
parent ed19138786
commit 594f4a98cc
2 changed files with 11 additions and 14 deletions

View File

@ -4,8 +4,7 @@ import { tryEvaluate } from "./Evaluator";
import { MidiConnection } from "./IO/MidiConnection";
import { next } from "zifferjs";
import {
superdough,
samples,
superdough, samples,
initAudioOnFirstClick,
registerSynthSounds
} from 'superdough';
@ -17,8 +16,6 @@ const init = Promise.all([
registerSynthSounds(),
]);
class DrunkWalk {
/**
@ -230,8 +227,8 @@ export class UserAPI {
this.MidiConnection.sendMidiNote(note, channel, velocity, duration)
}
public zn(input: string, options: {[key: string]: any} = {}): void {
const node = next(input, options);
public zn(input: string, options: {[key: string]: number} = {}): void {
const node = next(input, options as any);
const channel = options.channel ? options.channel : 0;
const velocity = options.velocity ? options.velocity : 100;
const sustain = options.sustain ? options.sustain : 0.5;
@ -261,7 +258,6 @@ export class UserAPI {
this.MidiConnection.sendPitchBend(value, channel)
}
public program_change(program: number, channel: number): void {
/**
* Sends a MIDI program change to the current MIDI output.
@ -556,20 +552,20 @@ export class UserAPI {
// Transport functions
// =============================================================
bpm(bpm?: number): number {
bpm(n?: number): number {
/**
* Sets or returns the current bpm.
*
* @param bpm - [optional] The bpm to set
* @returns The current bpm
*/
if (bpm === undefined)
if (n === undefined)
return this.app.clock.bpm
if (bpm < 1 || bpm > 500)
console.log(`Setting bpm to ${bpm}`)
this.app.clock.bpm = bpm
return bpm
if (n < 1 || n > 500)
console.log(`Setting bpm to ${n}`)
this.app.clock.bpm = n
return n
}
tempo = this.bpm
@ -976,4 +972,5 @@ export class UserAPI {
sound = async (values: object, delay: number = 0.00) => {
superdough(values, delay)
}
d = this.sound
}

View File

@ -47,7 +47,7 @@ export class Clock {
this.time_position = { bar: 0, beat: 0, pulse: 0 }
this.bpm = 120;
this.time_signature = [4, 4];
this.ppqn = 48;
this.ppqn = 48*2;
ctx.audioWorklet.addModule(TransportProcessor).then((e) => {
this.transportNode = new TransportNode(ctx, {}, this.app);
this.transportNode.connect(ctx.destination);