WebMIDILink suggestion

Official support for: g200kg.com
Post Reply New Topic
RELATED
PRODUCTS

Post

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
I'm a WebMIDI application developer, and want to use the soft synths that support WebMIDILink.
My application (written in Javascript) is designed to send MIDI messages to standard MIDI synthesizers, so it assembles them in Uint8Arrays.
WebMIDILink sends 'midi' messages as strings to its client synths, and the synths then have to analyse the string.

It would save us all a lot of hassle, and processor time, if I could simply send the Uint8Array. (Rather than me having to construct the string, just so that it can be analysed by the synth.)
Edit:
Maybe we could agree on a new message type (e.g. 'webmidi') whose detail would be a Uint8Array?

See https://developer.mozilla.org/en-US/doc ... ing_events (https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events)

I would create the message as follows:

Code: Select all (#)

var event = new CustomEvent('webmidi', { 'detail': unit8Array });
and send it using

Code: Select all (#)

synth.dispatchEvent(event);
The event listener would then be much simpler:

Code: Select all (#)

window.addEventListener("webmidi", handleWebMidi, false);
function handleWebMidi(event) {
    var msg = event.detail;
    switch (msg[0]) {
                case 0x80:
                    NoteOff(msg[1]);
                    break;
                case 0x90:
                    var velo = msg[2];
                    if (velo > 0)
                        NoteOn(msg[1], velo);
                    else
                        NoteOff(msg[1]);
                    break;
                case 0xb0:
                    if (msg[1]) == 0x78) {
                        AllNoteOff();
                    }
                    break;
            }
}
I think you could also use a similar strategy for your level2 messages, but they are not so time-critical...

All the best,
James

Post Reply

Return to “g200kg”