Skip to content

Commit

Permalink
M2M1 and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Oct 16, 2023
1 parent b9858e7 commit 1afde0e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
23 changes: 13 additions & 10 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -3405,25 +3405,28 @@
JZZ.MIDI2 = UMP;
_J.prototype.MIDI2 = UMP;

function _16_7(n) {
return n ? (n >> 9) || 1 : 0;
}
function _16_7(n) { return n ? (n >> 9) || 1 : 0; }
function _grp(m, g) { m.gr = g; return m; }
function _m2m1(msg) {
if (msg.isMidi2) {
var m, n;
var n, c;
var t = msg[0] >> 4;
var g = msg[0] & 15;
if (t == 1 || t == 2) {
m = new MIDI(msg.slice(1));
m.gr = g;
this._emit(m);
this._emit(_grp(new MIDI(msg.slice(1)), g));
}
else if (t == 4) {
n = msg[1] >> 4;
c = msg[1] & 15;
if (n == 8 || n == 9) {
m = new MIDI([msg[1], msg[2], _16_7(msg[4] * 256 + msg[5])]);
m.gr = g;
this._emit(m);
this._emit(_grp(new MIDI([msg[1], msg[2], _16_7(msg[4] * 256 + msg[5])]), g));
}
else if (n == 12) {
if (msg[3]) {
this._emit(_grp(new MIDI([0xb0 + c, 0, msg[6]]), g));
this._emit(_grp(new MIDI([0xb0 + c, 32, msg[7]]), g));
}
this._emit(_grp(new MIDI([msg[1], msg[4]]), g));
}
}
}
Expand Down
26 changes: 21 additions & 5 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1494,16 +1494,11 @@ describe('JZZ.Widget', function() {
assert.equal(port.connected(), 1);
port.xgMasterTuningA(0, 440).gr(0).xgMasterTuningA(440).disconnect();
});

it('xgMasterTuningA', function() {
var s = '30164310 4c000006 -- SysEx,30314000 00000000 -- SysEx,30164310 4c000000 -- SysEx,30340004 00000000 -- SysEx';
assert.equal(JZZ.UMP.xgMasterTuningA(0, 440).toString(), s);
assert.equal(JZZ.UMP.gr(0).xgMasterTuningA(440).toString(), s);
});




it('umpBPM', function(done) {
var sample = new test.Sample(done, [
[209, 16, 0, 0, 2, 250, 240, 128, 0, 0, 0, 0, 0, 0, 0, 0],
Expand All @@ -1520,6 +1515,27 @@ describe('JZZ.Widget', function() {
});
});

describe('JZZ.M2M1', function() {
it('noteO/Off', function(done) {
var sample = new test.Sample(done, [
[0x91, 0x3c, 0x7f], [0x81, 0x3c, 0],
[0x91, 0x3c, 0x01], [0x81, 0x3c, 0],
[0x90, 0x00, 0x7f]
]);
var port = new JZZ.M2M1();
port.connect(function(msg) { sample.compare(msg); });
port.noteOn(0, 1, 'C5').noteOff(0, 1, 'C5', 0).noop().umpNoteOn(0, 1, 'C5', 1).umpNoteOff(0, 1, 'C5').MIDI1().noteOn(0, 0);
});
it('program', function(done) {
var sample = new test.Sample(done, [
[0xc1, 32], [0xb1, 0, 1], [0xb1, 32, 2], [0xc1, 64]
]);
var port = new JZZ.M2M1();
port.connect(function(msg) { sample.compare(msg); });
port.umpProgram(0, 1, 32).umpProgram(0, 1, 64, 1, 2);
});
});

describe('JZZ.Context', function() {
it('reset', function() {
var ctxt = JZZ.Context();
Expand Down

0 comments on commit 1afde0e

Please sign in to comment.