How to use the webmidi.getInputById function in webmidi

To help you get started, we’ve selected a few webmidi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grame-cncm / fausteditorweb / src / index.ts View on Github external
$("#midi-ui-note").text(data[1]).show();
                } else {
                    keys.splice(keys.indexOf(data[1]), 1);
                    if (keys.length === 0) $("#midi-ui-note").hide();
                    else $("#midi-ui-note").text(keys[keys.length - 1]);
                }
            }
        };
        if (id === "-2") {
            key2Midi.handler = listener;
            key2Midi.enabled = true;
            return;
        }
        key2Midi.enabled = false;
        if (id === "-1") return;
        const input = webmidi.getInputById(id);
        if (!input) return;
        midiEnv.input = input;
        input.addListener("midimessage", "all", e => listener(e.data));
    });
    // Append current connected devices
github ritz078 / raaga / components / SoundPlayer.tsx View on Github external
useEffect(() => {
    const _onNoteStart = e => {
      onNoteStart(e.note.number, e.velocity, true);
    };

    const _onNoteStop = e => {
      onNoteStop(e.note.number, true);
    };

    if (!webMidi.supported) return;

    const input = webMidi.getInputById(midiDevice);

    if (input) {
      input.addListener("noteon", "all", _onNoteStart);
      input.addListener("noteoff", "all", _onNoteStop);
    }
    return () => {
      if (input) {
        input.removeListener("noteon", "all", _onNoteStart);
        input.removeListener("noteoff", "all", _onNoteStop);
      }
    };
  }, [midiDevice, onNoteStart, onNoteStop]);

webmidi

WEBMIDI.js makes it easy to talk to MIDI instruments from a browser or from Node.js. It simplifies the control of external or virtual MIDI instruments with functions such as playNote(), sendPitchBend(), sendControlChange(), etc. It also allows reacting to

Apache-2.0
Latest version published 4 months ago

Package Health Score

80 / 100
Full package analysis