How to use the webmidi.enabled 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 jupyter-widgets / midicontrols / src / enableMIDI.ts View on Github external
export default async function enableMIDI() {
  if (midi.enabled) {
    return;
  }

  const midiEnabled = new PromiseDelegate();
  midi.enable(function(err) {
    if (err) {
      midiEnabled.reject(err);
    } else {
      midiEnabled.resolve(undefined);
    }
  });  
  await midiEnabled.promise;
  // if (!(midi.inputs[1] && midi.outputs[1])) {
  //   throw new Error("Could not find MIDI device");
  // }
}
github cfry / dde / music / note.js View on Github external
start(seconds_per_beat=1){
        if (!WebMidi.enabled) {
            Midi.init()
            let the_note = this
            setTimeout(function() { the_note.start(seconds_per_beat) }, 1000)
        }
        else if (WebMidi.outputs.length == 0) {
            dde_error("There are no WebMidi outputs to play a Note on. <a href="#">Help</a>")
        }
        else if (this.is_rest()) { return this } //skip playing the "Rest" as it would error
        else {
            var extra_args = {duration:       Math.round(this.dur  * seconds_per_beat * 1000),
                              time:     "+" + Math.round(this.time * seconds_per_beat * 1000),
                              velocity: this.velocity}
            const pitch = this.pitch
            const chan  = this.channel
            WebMidi.outputs[0].playNote(pitch, chan, extra_args)
            return this
github jupyter-widgets / midicontrols / src / widget.ts View on Github external
initialize(attributes: any, options: any) {
    super.initialize(attributes, options);
    if (!midi.enabled) {
      throw new Error('WebMidi library not enabled');
    }

    const input = midi.inputs.findIndex(x => x.manufacturer === "Behringer" && x.name.startsWith("X-TOUCH MINI"));
    if (input === -1) {
      throw new Error("Could not find Behringer X-TOUCH MINI input");
    }

    const output = midi.outputs.findIndex(x => x.manufacturer === "Behringer" && x.name.startsWith("X-TOUCH MINI"));
    if (output === -1) {
      throw new Error("Could not find Behringer X-TOUCH MINI output");
    }

    this.set('_controller_input', input);
    this.set('_controller_output', output);
github ritz078 / raaga / pages / index.tsx View on Github external
webMidi.enable(err => {
      setWebMidiEnabled(!err && webMidi.enabled);
    });
  }, []);

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 3 months ago

Package Health Score

84 / 100
Full package analysis