diff options
| author | julian laplace <julescarbon@gmail.com> | 2025-07-05 18:57:07 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2025-07-05 18:57:07 +0200 |
| commit | 0e0c63f658fe5e0d0249bcbfba87fdb5e0484208 (patch) | |
| tree | 1684dae526382ca4fcea18a2cd2929f184bde925 /client/lib | |
| parent | c0f04ce84a66955f6363c5a7fe565359079c6457 (diff) | |
local proxy, json
Diffstat (limited to 'client/lib')
| -rw-r--r-- | client/lib/keys.js | 1 | ||||
| -rw-r--r-- | client/lib/midi.js | 33 |
2 files changed, 33 insertions, 1 deletions
diff --git a/client/lib/keys.js b/client/lib/keys.js index 84f8103..687517f 100644 --- a/client/lib/keys.js +++ b/client/lib/keys.js @@ -38,7 +38,6 @@ function keydown(e) { if (!(e.keyCode in keys)) return; var index = keys[e.keyCode]; if (e.shiftKey) index += letters.length; - index -= 7; callback(index); } diff --git a/client/lib/midi.js b/client/lib/midi.js new file mode 100644 index 0000000..06cb266 --- /dev/null +++ b/client/lib/midi.js @@ -0,0 +1,33 @@ +/** + * MIDI + * @module midi.js; + */ + +import { WebMidi } from "webmidi"; + +function enable(play) { + WebMidi.enable() + .then(onEnabled) + .catch((error) => console.error(error)); + + // Function triggered when WEBMIDI.js is ready + function onEnabled() { + // Display available MIDI input devices + if (WebMidi.inputs.length < 1) { + console.log("No device detected."); + return; + } else { + WebMidi.inputs.forEach((device, index) => { + document.body.innerHTML += `${index}: ${device.name} <br>`; + }); + const mySynth = WebMidi.inputs[0]; + // const mySynth = WebMidi.getInputByName("TYPE NAME HERE!") + + mySynth.channels[1].addListener("noteon", (event) => { + console.log(event.note); + }); + } + } +} + +export default { enable }; |
