Skip to content

Commit

Permalink
midi support for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Jun 26, 2024
1 parent c3ba30f commit 471bf57
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
},
"dependencies": {
"@kabelsalat/core": "workspace:*",
"yesno": "^0.4.0",
"chokidar": "^3.6.0",
"speaker": "^0.5.5"
"jzz": "^1.8.5",
"speaker": "^0.5.5",
"yesno": "^0.4.0"
}
}
9 changes: 9 additions & 0 deletions packages/cli/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

import "@kabelsalat/core/src/compiler.js";
import { MIDI, parseMidiMessage } from "@kabelsalat/core/src/midi.js";
import { AudioGraph } from "@kabelsalat/core/src/audiograph.js";
import { existsSync } from "node:fs";
import fs from "node:fs/promises";
Expand All @@ -10,6 +11,7 @@ import { audiostream } from "./audiostream.js";
import chokidar from "chokidar";
import Speaker from "speaker";
import yesno from "yesno";
import navigator from "jzz";

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

// init midi
const midi = new MIDI(navigator);
midi.on("midimessage", (_, message) => {
const msg = parseMidiMessage(message);
msg && audioGraph.parseMsg(msg);
});

Object.assign(globalThis, api);
function update(code) {
try {
Expand Down
27 changes: 25 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 471bf57

Please sign in to comment.