Testing zn method chaining
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
"superdough": "^0.9.3",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tone": "^14.8.49",
|
||||
"zifferjs": "file:../zifferjs",
|
||||
"zifferjs": "https://github.com/amiika/zifferjs.git",
|
||||
"zzfx": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
17
src/API.ts
17
src/API.ts
@ -3,7 +3,7 @@ import { scale } from './Scales';
|
||||
import { tryEvaluate } from "./Evaluator";
|
||||
import { MidiConnection } from "./IO/MidiConnection";
|
||||
import { DrunkWalk } from './Utils/Drunk';
|
||||
import { next, Pitch, Chord, Rest } from "zifferjs";
|
||||
import { Pitch, Chord, Rest, Event, Start, cachedStart } from "zifferjs";
|
||||
import {
|
||||
superdough, samples,
|
||||
initAudioOnFirstClick,
|
||||
@ -176,8 +176,13 @@ export class UserAPI {
|
||||
this.MidiConnection.sendMidiNote(note, channel, velocity, duration)
|
||||
}
|
||||
|
||||
public zn(input: string, options: {[key: string]: string|number} = {}): Pitch|Chord|Rest {
|
||||
const node = next(input, options) as any;
|
||||
public zn(input: string, options: {[key: string]: string|number} = {}): Event {
|
||||
let event = cachedStart(input, options);
|
||||
if(event instanceof Start) {
|
||||
// do nothing for now ...
|
||||
} else {
|
||||
let node = event;
|
||||
if(node.modifiedEvent) node = node.modifiedEvent;
|
||||
const channel = (options.channel ? options.channel : 0) as number;
|
||||
const velocity = (options.velocity ? options.velocity : 100) as number;
|
||||
const sustain = (options.sustain ? options.sustain : 0.5) as number;
|
||||
@ -186,7 +191,7 @@ export class UserAPI {
|
||||
this.MidiConnection.sendMidiNote(node.note!, channel, velocity, sustain);
|
||||
if(node.bend) this.MidiConnection.sendPitchBend(8192, channel);
|
||||
} else if(node instanceof Chord) {
|
||||
node.pitches.forEach(pitch => {
|
||||
node.pitches.forEach((pitch: Pitch) => {
|
||||
if(pitch.bend) this.MidiConnection.sendPitchBend(pitch.bend, channel);
|
||||
this.MidiConnection.sendMidiNote(pitch.note!, channel, velocity, sustain);
|
||||
if(pitch.bend) this.MidiConnection.sendPitchBend(8192, channel);
|
||||
@ -194,7 +199,9 @@ export class UserAPI {
|
||||
} else if(node instanceof Rest) {
|
||||
// do nothing for now ...
|
||||
}
|
||||
return node;
|
||||
if(node.modifiedEvent) node.modifiedEvent = undefined;
|
||||
}
|
||||
return event.next();
|
||||
}
|
||||
|
||||
public sysex(data: Array<number>): void {
|
||||
|
||||
@ -1158,8 +1158,9 @@ yaml@^2.1.1:
|
||||
resolved "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz"
|
||||
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
|
||||
|
||||
"zifferjs@file:../zifferjs":
|
||||
"zifferjs@https://github.com/amiika/zifferjs.git":
|
||||
version "0.0.0"
|
||||
resolved "https://github.com/amiika/zifferjs.git#374ee4edb0b07d9968b635f899f9f88d79ddaa07"
|
||||
dependencies:
|
||||
"@types/seedrandom" "^3.0.5"
|
||||
lru-cache "^10.0.0"
|
||||
|
||||
Reference in New Issue
Block a user