Update zifferjs
This commit is contained in:
@ -30,7 +30,7 @@
|
|||||||
"superdough": "^0.9.3",
|
"superdough": "^0.9.3",
|
||||||
"tailwindcss": "^3.3.3",
|
"tailwindcss": "^3.3.3",
|
||||||
"tone": "^14.8.49",
|
"tone": "^14.8.49",
|
||||||
"zifferjs": "^0.0.5",
|
"zifferjs": "^0.0.6",
|
||||||
"zzfx": "^1.2.0"
|
"zzfx": "^1.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/API.ts
50
src/API.ts
@ -1,4 +1,4 @@
|
|||||||
import { Pitch, Chord, Rest, Event, cachedEvent } from "zifferjs";
|
import { Pitch, Chord, Rest, Event, cachedPattern } from "zifferjs";
|
||||||
import { MidiConnection } from "./IO/MidiConnection";
|
import { MidiConnection } from "./IO/MidiConnection";
|
||||||
import { tryEvaluate } from "./Evaluator";
|
import { tryEvaluate } from "./Evaluator";
|
||||||
import { DrunkWalk } from "./Utils/Drunk";
|
import { DrunkWalk } from "./Utils/Drunk";
|
||||||
@ -248,33 +248,35 @@ export class UserAPI {
|
|||||||
|
|
||||||
public zn(input: string,
|
public zn(input: string,
|
||||||
options: {[key: string]: string|number} = {}): Event {
|
options: {[key: string]: string|number} = {}): Event {
|
||||||
let event = cachedEvent(input, options);
|
const pattern = cachedPattern(input, options);
|
||||||
|
|
||||||
// Check if event is modified
|
if(pattern.hasStarted()) {
|
||||||
const node = event.modifiedEvent ? event.modifiedEvent : event;
|
const event = pattern.peek();
|
||||||
|
// Check if event is modified
|
||||||
|
const node = event.modifiedEvent ? event.modifiedEvent : event;
|
||||||
|
|
||||||
const channel = (options.channel ? options.channel : 0) as number;
|
const channel = (options.channel ? options.channel : 0) as number;
|
||||||
const velocity = (options.velocity ? options.velocity : 100) as number;
|
const velocity = (options.velocity ? options.velocity : 100) as number;
|
||||||
const sustain = (options.sustain ? options.sustain : 0.5) as number;
|
const sustain = (options.sustain ? options.sustain : 0.5) as number;
|
||||||
|
|
||||||
if(node instanceof Pitch) {
|
if(node instanceof Pitch) {
|
||||||
if(node.bend) this.MidiConnection.sendPitchBend(node.bend, channel);
|
if(node.bend) this.MidiConnection.sendPitchBend(node.bend, channel);
|
||||||
this.MidiConnection.sendMidiNote(node.note!, channel, velocity, sustain);
|
this.MidiConnection.sendMidiNote(node.note!, channel, velocity, sustain);
|
||||||
if(node.bend) this.MidiConnection.sendPitchBend(8192, channel);
|
if(node.bend) this.MidiConnection.sendPitchBend(8192, channel);
|
||||||
} else if(node instanceof Chord) {
|
} else if(node instanceof Chord) {
|
||||||
node.pitches.forEach((pitch: Pitch) => {
|
node.pitches.forEach((pitch: Pitch) => {
|
||||||
if(pitch.bend) this.MidiConnection.sendPitchBend(pitch.bend, channel);
|
if(pitch.bend) this.MidiConnection.sendPitchBend(pitch.bend, channel);
|
||||||
this.MidiConnection.sendMidiNote(pitch.note!, channel, velocity, sustain);
|
this.MidiConnection.sendMidiNote(pitch.note!, channel, velocity, sustain);
|
||||||
if(pitch.bend) this.MidiConnection.sendPitchBend(8192, channel);
|
if(pitch.bend) this.MidiConnection.sendPitchBend(8192, channel);
|
||||||
});
|
});
|
||||||
} else if(node instanceof Rest) {
|
} else if(node instanceof Rest) {
|
||||||
// do nothing for now ...
|
// do nothing for now ...
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove old modified event
|
||||||
|
if(event.modifiedEvent) event.modifiedEvent = undefined;
|
||||||
}
|
}
|
||||||
|
return pattern.next();
|
||||||
// Remove old modified event
|
|
||||||
if(event.modifiedEvent) event.modifiedEvent = undefined;
|
|
||||||
|
|
||||||
return node.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|||||||
@ -1148,10 +1148,10 @@ yaml@^2.1.1:
|
|||||||
resolved "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz"
|
resolved "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz"
|
||||||
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
|
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
|
||||||
|
|
||||||
zifferjs@^0.0.5:
|
zifferjs@^0.0.6:
|
||||||
version "0.0.5"
|
version "0.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/zifferjs/-/zifferjs-0.0.5.tgz#b641e6d960e1b24389feacc0d975262af63cb75e"
|
resolved "https://registry.yarnpkg.com/zifferjs/-/zifferjs-0.0.6.tgz#7adfaa6a2ce6bdd496289dd0454f1767e6e5244e"
|
||||||
integrity sha512-8IfsiiWigHLh1h7SaBtXe0Cig8bbvCR6mI4P/0n3j/oedY8WQcu5gj+v1q+VcQW0D2zfTvGGKrWZdqCjXrKRfw==
|
integrity sha512-fruobVQUaoko2d99euiGlvkJZH4mbuekJxUKiOt20vuLHzEybaLzWy9OuOryPodCatWCY5fcs40lB86ST5fWbg==
|
||||||
dependencies:
|
dependencies:
|
||||||
lru-cache "^10.0.0"
|
lru-cache "^10.0.0"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user