Updating zifferjs

This commit is contained in:
2023-08-12 21:34:53 +03:00
parent 673203aef9
commit af1d8a774c
4 changed files with 39 additions and 27 deletions

33
package-lock.json generated
View File

@ -21,7 +21,7 @@
"postcss": "^8.4.27",
"tailwindcss": "^3.3.3",
"tone": "^14.8.49",
"zifferjs": "github:amiika/zifferjs",
"zifferjs": "file:../zifferjs",
"zzfx": "^1.2.0"
},
"devDependencies": {
@ -31,6 +31,22 @@
"vite": "^4.4.5"
}
},
"../zifferjs": {
"version": "0.0.0",
"dependencies": {
"@types/seedrandom": "^3.0.5",
"lru-cache": "^10.0.0",
"seedrandom": "^3.0.5"
},
"devDependencies": {
"@vitest/ui": "^0.34.1",
"peggy": "^3.0.2",
"ts-pegjs": "^4.2.1",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vitest": "^0.34.1"
}
},
"node_modules/@alloc/quick-lru": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",
@ -1438,14 +1454,6 @@
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
},
"node_modules/lru-cache": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz",
"integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==",
"engines": {
"node": "14 || >=16.14"
}
},
"node_modules/merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
@ -2099,11 +2107,8 @@
}
},
"node_modules/zifferjs": {
"version": "0.0.0",
"resolved": "git+ssh://git@github.com/amiika/zifferjs.git#022a8297313c37402434ad728db38641442e4659",
"dependencies": {
"lru-cache": "^10.0.0"
}
"resolved": "../zifferjs",
"link": true
},
"node_modules/zzfx": {
"version": "1.2.0",

View File

@ -28,7 +28,7 @@
"postcss": "^8.4.27",
"tailwindcss": "^3.3.3",
"tone": "^14.8.49",
"zifferjs": "github:amiika/zifferjs",
"zifferjs": "file:../zifferjs",
"zzfx": "^1.2.0"
}
}

View File

@ -2,7 +2,7 @@ import { Editor } from "./main";
import { scale } from './Scales';
import { tryEvaluate } from "./Evaluator";
import { MidiConnection } from "./IO/MidiConnection";
import { next } from "zifferjs";
import { next, Pitch, Chord, Rest } from "zifferjs";
// @ts-ignore
import { webaudioOutput, samples } from '@strudel.cycles/webaudio';
@ -225,13 +225,23 @@ export class UserAPI {
}
public zn(input: string, options: {[key: string]: any} = {}): void {
const node = next(input, options);
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;
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 => {
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 ...
}
}
public sysex(data: Array<number>): void {

View File

@ -634,11 +634,6 @@ lines-and-columns@^1.1.6:
resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
lru-cache@^10.0.0:
version "10.0.1"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz"
integrity sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==
merge2@^1.3.0:
version "1.4.1"
resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz"
@ -993,11 +988,13 @@ yaml@^2.1.1:
resolved "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz"
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
"zifferjs@github:amiika/zifferjs":
"zifferjs@file:../zifferjs":
version "0.0.0"
resolved "git+ssh://git@github.com/amiika/zifferjs.git#022a8297313c37402434ad728db38641442e4659"
resolved "file:../zifferjs"
dependencies:
"@types/seedrandom" "^3.0.5"
lru-cache "^10.0.0"
seedrandom "^3.0.5"
zzfx@^1.2.0:
version "1.2.0"