Skip to content

Commit

Permalink
MIDI2 Context
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Mar 8, 2024
1 parent 72e7fee commit 2dc82b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -2744,19 +2744,24 @@
return 'NRPN ' + a + ' ' + b;
}
function _read_ctxt(msg) {
var mmm, kk;
var mmm, kk, tt, st, s;
var gr = 'x';
var ch = 'x';
if (msg.isMidi2) {
tt = msg[0] >> 4;
gr = (msg[0] & 15).toString(16);
if (tt == 2) {
mmm = JZZ.MIDI(msg.slice(1));
}
else return msg;
}
else mmm = msg;
if (!mmm || !mmm.length || mmm[0] < 0x80) return mmm;
if (mmm[0] == 0xff) { this._clear(); return msg; }
st = mmm[0] >> 4;
ch = (mmm[0] & 15).toString(16);
kk = gr + ch;
kk = st == 15 ? gr : gr + ch;
if (!this._cc[kk]) this._cc[kk] = {};
var st = mmm[0] >> 4;
var s;
if (st == 12) {
mmm._bm = this._cc[kk].bm;
mmm._bl = this._cc[kk].bl;
Expand Down Expand Up @@ -3432,6 +3437,7 @@
else if (c == 2) return d == 8 || (d == 9 && !this[3]);
return false;
};
UMP.prototype.label = MIDI.prototype.label;
UMP.prototype.toString = MIDI.prototype.toString;
UMP.prototype._str = function() {
var t = this._string();
Expand Down
4 changes: 2 additions & 2 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1743,12 +1743,12 @@ describe('JZZ.Context', function() {
ctxt.program(1, 1);
});
it('progName 2', function(done) {
var ctxt = JZZ.Context();
var ctxt = JZZ.Context().MIDI2().gr(2);
JZZ.MIDI.programName = function(a, b, c) { return a + ' ' + b + ' ' + c; };
ctxt.rpn(1, 2, 3);
ctxt.bank(1, 2, 3);
ctxt.connect(function(msg) {
assert.equal(msg.toString(), 'c1 01 -- Program Change (1 2 3)');
assert.equal(msg.toString(), '22c10100 -- Program Change (1 2 3)');
JZZ.MIDI.programName = undefined;
done();
});
Expand Down

0 comments on commit 2dc82b2

Please sign in to comment.