Skip to content

Commit 471bf57

Browse files
committed
midi support for cli
1 parent c3ba30f commit 471bf57

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

packages/cli/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@kabelsalat/core": "workspace:*",
13-
"yesno": "^0.4.0",
1413
"chokidar": "^3.6.0",
15-
"speaker": "^0.5.5"
14+
"jzz": "^1.8.5",
15+
"speaker": "^0.5.5",
16+
"yesno": "^0.4.0"
1617
}
1718
}

packages/cli/src/cli.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

33
import "@kabelsalat/core/src/compiler.js";
4+
import { MIDI, parseMidiMessage } from "@kabelsalat/core/src/midi.js";
45
import { AudioGraph } from "@kabelsalat/core/src/audiograph.js";
56
import { existsSync } from "node:fs";
67
import fs from "node:fs/promises";
@@ -10,6 +11,7 @@ import { audiostream } from "./audiostream.js";
1011
import chokidar from "chokidar";
1112
import Speaker from "speaker";
1213
import yesno from "yesno";
14+
import navigator from "jzz";
1315

1416
let logo = `
1517
▄ •▄ ▄▄▄· ▄▄▄▄· ▄▄▄ .▄▄▌ .▄▄ · ▄▄▄· ▄▄▌ ▄▄▄· ▄▄▄▄▄
@@ -63,6 +65,13 @@ const filePath = path.resolve(process.cwd(), file);
6365
// create audio graph
6466
const audioGraph = new AudioGraph(44100);
6567

68+
// init midi
69+
const midi = new MIDI(navigator);
70+
midi.on("midimessage", (_, message) => {
71+
const msg = parseMidiMessage(message);
72+
msg && audioGraph.parseMsg(msg);
73+
});
74+
6675
Object.assign(globalThis, api);
6776
function update(code) {
6877
try {

pnpm-lock.yaml

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)