Skip to content

Commit

Permalink
M2M1 SysEx
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Oct 17, 2023
1 parent 1afde0e commit 1612716
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -3415,6 +3415,24 @@
if (t == 1 || t == 2) {
this._emit(_grp(new MIDI(msg.slice(1)), g));
}
else if (t == 3) {
c = msg[1] >> 4;
n = msg[1] & 15;
if (c == 0) {
this._emit(_grp(new MIDI([0xf0].concat(msg.slice(2, 2 + n), [0xf7])), g));
this._sx[g] = undefined;
}
else if (c == 1) {
this._sx[g] = msg.slice(2, 2 + n);
}
else if (c == 2) {
if (this._sx[g]) this._sx[g] = this._sx[g].concat(msg.slice(2, 2 + n));
}
else if (c == 3) {
if (this._sx[g]) this._emit(_grp(new MIDI([0xf0].concat(this._sx[g], msg.slice(2, 2 + n), [0xf7])), g));
this._sx[g] = undefined;
}
}
else if (t == 4) {
n = msg[1] >> 4;
c = msg[1] & 15;
Expand All @@ -3434,6 +3452,7 @@
}
function M2M1() {
var self = new _M();
self._sx = [];
self._receive = _m2m1;
self._resume();
return self.MIDI2();
Expand Down
10 changes: 10 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,16 @@ describe('JZZ.M2M1', function() {
port.connect(function(msg) { sample.compare(msg); });
port.umpProgram(0, 1, 32).umpProgram(0, 1, 64, 1, 2);
});
it('sysex', function(done) {
var sample = new test.Sample(done, [
[0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7],
[0xf0, 0x00, 0x20, 0x24, 0x00, 0x04, 0x6b, 0x61, 0x72, 0x61, 0x6f, 0x6b, 0x65, 0x2e, 0x2e, 0x2e, 0xf7]
]);
var port = new JZZ.M2M1();
port.connect(function(msg) { sample.compare(msg); });
var a = JZZ.MIDI2.sxMidiSoft(0, 4, 'karaoke...');
port.gr(0).send(a[1]).send(a[2]).sxGM().send(a[0]).send(a[1]).send(a[2]);
});
});

describe('JZZ.Context', function() {
Expand Down

0 comments on commit 1612716

Please sign in to comment.