-
Notifications
You must be signed in to change notification settings - Fork 11
Web MIDI API
SpessaSynth provides an easy way to connect physical MIDI Devices
to it and back using MIDIDeviceHandler
.
Tip
If you encounter any errors in this documentation, please open an issue!
// normal install
import { MIDIDeviceHandler } from "./spessasynth_lib/external_midi/midi_handler.js";
// npm package
import { MIDIDeviceHandler } from "spessasynth_lib";
Tip
Using the npm package? Make sure you've read this
const MIDIHandler = new MIDIDeviceHandler();
The MIDI inputs as MIDIInputMap.
The MIDI outputs as MIDIOutputMap.
Initializes the connection to physical MIDI Devices.
MIDIHandler.createMIDIDeviceHandler();
The returned value is boolean
, true if succeeded, false if failed.
Important
This function is asynchronous.
Connects a Sequencer
instance to a MIDI Output, playing back the sequence to it.
MIDIHandler.connectMIDIOutputToSeq(output, seq);
- output - a
MIDIOutput
to connect to. - seq - a
Sequencer
instance to connect.
Disconnects all MIDI devices from the sequencer.
MIDIHandler.connectMIDIOutputToSeq(seq);
- seq - a
Sequencer
instance to disconnect.
Connects a MIDI Input to a Synthetizer
instance, responding to all received messages.
MIDIHandler.connectDeviceToSynth(input, synth);
- input - a
MIDIInput
to connect. - synth - a
Synthetizer
instance to connect to.
Disconnects all MIDI Inputs from the Synthetizer
instance.
MIDIHandler.disconnectAllDevicesFromSynth();
No arguments as this simply removes the onmidimessage
property from the inputs.
Tip
If you encounter any errors in this documentation, please open an issue!
Warning
Make sure you always update worklet_processor.min.js
along with the npm package!