From 594f4a98ccd2c3da215cb5725114658f3463f8d0 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 12 Aug 2023 00:30:06 +0200 Subject: [PATCH] playing a bit --- src/API.ts | 23 ++++++++++------------- src/Clock.ts | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/API.ts b/src/API.ts index 61dda7d..b50c473 100644 --- a/src/API.ts +++ b/src/API.ts @@ -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 } diff --git a/src/Clock.ts b/src/Clock.ts index 6dee34e..f0fdb23 100644 --- a/src/Clock.ts +++ b/src/Clock.ts @@ -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);