Skip to content

Commit

Permalink
playing a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubobubobubobubo committed Aug 11, 2023
1 parent ed19138 commit 594f4a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -17,8 +16,6 @@ const init = Promise.all([
registerSynthSounds(),
]);



class DrunkWalk {

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -976,4 +972,5 @@ export class UserAPI {
sound = async (values: object, delay: number = 0.00) => {
superdough(values, delay)
}
d = this.sound
}
2 changes: 1 addition & 1 deletion src/Clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 594f4a9

Please sign in to comment.