How to use the webmidi.inputs 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 / 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);


    // Make sure we are in MCU protocol mode
    midi.outputs[output].sendChannelMode(
      127,
github ISNIT0 / webaudio-generator / src / nodes / inputs / midi.ts View on Github external
WebMidi.enable(function (err: any) {
            if (err) {
                alert("WebMidi could not be enabled.");
            }

            const output = WebMidi.outputs[0];
            const input = WebMidi.inputs[0];

            input.addListener('noteon', "all",
                function (e: any) {
                    console.log("Received 'noteon' message (" + e.note.name + e.note.octave + ").");
                    output.playNote(`${e.note.name}${e.note.octave}`, 'all', { velocity: 1 });
                    synth.triggerAttack(`${e.note.name}${e.note.octave}`);
                }
            );
            input.addListener('noteoff', "all",
                function (e: any) {
                    console.log("Received 'noteoff' message (" + e.note.name + e.note.octave + ").");
                    output.playNote(`${e.note.name}${e.note.octave}`, 'all', { velocity: 0 });
                    synth.triggerRelease();
                }
            );
        });
github cfry / dde / music / note.js View on Github external
WebMidi.enable(function(err) {
                                if (err) { warning("WebMidi couldn't be enabled: " + err) }
                                else {
                                    out("WedMidi enabled")
                                    //out(WebMidi.inputs)
                                    //out(WebMidi.outputs)
                                    inspect({"WebMidi.inputs":  WebMidi.inputs,
                                             "WebMidi.outputs": WebMidi.outputs})
                                }
                             })
            //eval_and_play_button_id.style.display = "inline-block"
github tensorflow / magenta / demos / ai-jam-js / static / src / keyboard / Midi.js View on Github external
WebMidi.enable((err) => {
			if (!err){
				this._isEnabled = true

				this._magenta.instances().forEach((instance) => {
					this._magenta.updatePort(WebMidi.getOutputByName(instance.portName()))
				})

				if (WebMidi.inputs){
					WebMidi.inputs.forEach((input) => this._bindInput(input))
				}
				WebMidi.addListener('connected', (device) => {
					if (device.input) {
						this._bindInput(device.input)
					}
					if (device.output) {
						this._magenta.updatePort(device.output)
					}
				})
			}
		})
	}
github tensorflow / magenta / demos / ai-duet / static / src / keyboard / Midi.js View on Github external
WebMidi.enable((err) => {
			if (!err){
				this._isEnabled = true
				if (WebMidi.inputs){
					WebMidi.inputs.forEach((input) => this._bindInput(input))
				}
				WebMidi.addListener('connected', (device) => {
					if (device.input){
						this._bindInput(device.input)
					}
				})
			}
		})
	}
github tambien / Piano / Demo.js View on Github external
WebMidi.enable((err) => {
			if (!err){
				this._isEnabled = true
				if (WebMidi.inputs){
					WebMidi.inputs.forEach((input) => this._bindInput(input))
				}
				WebMidi.addListener('connected', (device) => {
					if (device.input){
						this._bindInput(device.input)
					}
				})
			}
		})
	}
github ritz078 / raaga / components / MidiSelect / MidiSelect.tsx View on Github external
const handleMidiDeviceChange = useCallback(() => {
    setInputMidis(webMidi.inputs);

    if (!webMidi.inputs.length) {
      onMidiDeviceChange(null);
    }
  }, [webMidi]);
github googlecreativelab / aiexperiments-ai-duet / static / src / keyboard / Midi.js View on Github external
WebMidi.enable((err) => {
			if (!err){
				this._isEnabled = true
				if (WebMidi.inputs){
					WebMidi.inputs.forEach((input) => this._bindInput(input))
				}
				WebMidi.addListener('connected', (device) => {
					if (device.input){
						this._bindInput(device.input)
					}
				})
			}
		})
	}
github tensorflow / magenta / demos / ai-duet / static / src / keyboard / Midi.js View on Github external
WebMidi.enable((err) => {
			if (!err){
				this._isEnabled = true
				if (WebMidi.inputs){
					WebMidi.inputs.forEach((input) => this._bindInput(input))
				}
				WebMidi.addListener('connected', (device) => {
					if (device.input){
						this._bindInput(device.input)
					}
				})
			}
		})
	}
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 values = {...this.defaults(), ...attributes};
    const input = midi.inputs[values._controller_input];
    const output = midi.outputs[values._controller_output];
    this._fader = new Fader({input, output}, values._control, {
      min: values.min,
      max: values.max,
      value: values.value
    });
    this._fader.stateChanged.connect((sender, args) => {
      switch (args.name) {
        case 'value':
        case 'min':
        case 'max':
          this.set(args.name, args.newValue);
          break;
      }
      this.save_changes();
    });

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