dingram / jsmidgen

A pure-JavaScript MIDI generator
228 stars 33 forks source link

Allow Add System Exclusive Messages to Track #42

Open tcdw opened 1 year ago

tcdw commented 1 year ago

On one of projects I am working on, I want to add MIDI system exclusive messages for my custom need; however, there are no way of adding that (at least officially).

After reading the source code, I found it's able to pass a object with toBytes function. So, I am using this workaround:

// add GM reset
track.addEvent({
    toBytes() {
        // Channel 1 (1 byte), message start (1 byte), message length (1 byte), message (5 bytes)
        return [0x00, 0xF0, 0x05, 0x7E, 0x7F, 0x09, 0x01, 0xF7];
    },
}); // add `as any` before the right parentheses if you using TypeScript

It would be much appreciated to add this function officially, since sometimes MIDI sysex is still need to be used.

walmik commented 1 year ago

I m curious to know how do you use this? Do you generate a midi file and play that in a DAW to transmit sysex?

tcdw commented 1 year ago

I m curious to know how do you use this? Do you generate a midi file and play that in a DAW to transmit sysex?

Because I want to generate MIDI that using some of Yamaha XG's exclusive features (for instance, echo and aftertouch) and being able play instantly on MIDI players.

I admit it sounds like a XY Problem, since I am making a purely hobby project.

walmik commented 1 year ago

I too have a hobby project and it depends on jsmidgen. I d like sysex support too! In my usecase I want to send sysex to Disting Ex to manipulate it's settings. These are not musical setting such as aftertouch, instead they are settings of the various algorithms on it.

dingram commented 1 year ago

Maybe I should pick the project up again 🤔

walmik commented 1 year ago

Absolutely!

A TS rewrite that exports ES module would be a great next plan too!