Update zifferjs
This commit is contained in:
@ -30,7 +30,7 @@
|
||||
"superdough": "^0.9.3",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tone": "^14.8.49",
|
||||
"zifferjs": "^0.0.1",
|
||||
"zifferjs": "^0.0.2",
|
||||
"zzfx": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
50
src/API.ts
50
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 { Pitch, Chord, Rest, Event, Start, cachedStart, pattern } from "zifferjs";
|
||||
import { Pitch, Chord, Rest, Event, cachedEvent} from "zifferjs";
|
||||
import {
|
||||
superdough,
|
||||
samples,
|
||||
@ -189,31 +189,33 @@ export class UserAPI {
|
||||
|
||||
public zn(input: string,
|
||||
options: {[key: string]: string|number} = {}): Event {
|
||||
const event = cachedStart(input, options);
|
||||
if(event instanceof Start) {
|
||||
let event = cachedEvent(input, options);
|
||||
|
||||
// Check if event is modified
|
||||
const node = event.modifiedEvent ? event.modifiedEvent : event;
|
||||
|
||||
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;
|
||||
|
||||
if(node instanceof Pitch) {
|
||||
if(node.bend) this.MidiConnection.sendPitchBend(node.bend, channel);
|
||||
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: 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);
|
||||
});
|
||||
} else if(node instanceof Rest) {
|
||||
// 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;
|
||||
if(node instanceof Pitch) {
|
||||
if(node.bend) this.MidiConnection.sendPitchBend(node.bend, channel);
|
||||
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: 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);
|
||||
});
|
||||
} else if(node instanceof Rest) {
|
||||
// do nothing for now ...
|
||||
}
|
||||
if(node.modifiedEvent) node.modifiedEvent = undefined;
|
||||
}
|
||||
return event.next();
|
||||
|
||||
// Remove old modified event
|
||||
if(event.modifiedEvent) event.modifiedEvent = undefined;
|
||||
|
||||
return node.next();
|
||||
}
|
||||
|
||||
public sysex(data: Array<number>): void {
|
||||
|
||||
@ -1153,10 +1153,10 @@ yaml@^2.1.1:
|
||||
resolved "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz"
|
||||
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
|
||||
|
||||
zifferjs@^0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/zifferjs/-/zifferjs-0.0.1.tgz#9ddd0e56efb1652105fa11f9496fe61b228c8862"
|
||||
integrity sha512-D7y79/RfHyMD5bWN0DD3VDWRk/XXuknvYBFuuZ77xe3heOiTZ6j+g3MS9AMewCDoTWIgWN79vPs2VYey89DdOQ==
|
||||
zifferjs@^0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/zifferjs/-/zifferjs-0.0.2.tgz#17abcba0874da603908baefd00bee764300e5cb9"
|
||||
integrity sha512-NQ9JxMDA5dBQF6kiTFJxDQKxpFn5qklDLu6ow/53V+E8RVEbpSsYcSBhcJ893u5Re4vSooJDJOcMsQwcF4GYww==
|
||||
dependencies:
|
||||
lru-cache "^10.0.0"
|
||||
seedrandom "^3.0.5"
|
||||
|
||||
Reference in New Issue
Block a user