Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Mar 12, 2024
1 parent 4a63fa2 commit 614248c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
26 changes: 13 additions & 13 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -2777,20 +2777,20 @@
this._cc[kk].sx = undefined;
}
}
else if (tt == 4) {
st = msg[1] >> 4;
ch = (msg[1] & 15).toString(16);
kk = gr + ch;
if (!this._cc[kk]) this._cc[kk] = {};
if (st == 12) {
if (msg[3] & 1) {
this._cc[kk].bm = msg[6];
this._cc[kk].bl = msg[7];
}
msg._bm = this._cc[kk].bm;
msg._bl = this._cc[kk].bl;
if (JZZ.MIDI.programName) msg.label(JZZ.MIDI.programName(msg[4], msg._bm, msg._bl));
}
else if (tt == 4) {
st = msg[1] >> 4;
ch = (msg[1] & 15).toString(16);
kk = gr + ch;
if (!this._cc[kk]) this._cc[kk] = {};
if (st == 12) {
if (msg[3] & 1) {
this._cc[kk].bm = msg[6];
this._cc[kk].bl = msg[7];
}
msg._bm = this._cc[kk].bm;
msg._bl = this._cc[kk].bl;
if (JZZ.MIDI.programName) msg.label(JZZ.MIDI.programName(msg[4], msg._bm, msg._bl));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

29 changes: 19 additions & 10 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1754,17 +1754,26 @@ describe('JZZ.Context', function() {
});
ctxt.program(1, 1);
});
it('progName 3', function(done) {
var ctxt = JZZ.Context().MIDI2().gr(2);
it('progName 3', function() {
var ctxt = JZZ.Context();
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(), '22c10100 -- Program Change (1 2 3)');
JZZ.MIDI.programName = undefined;
done();
});
ctxt.program(1, 1);
var msg = JZZ.MIDI2.bank(0, 1, 2, 3);
ctxt._receive(msg[0]);
ctxt._receive(msg[1]);
msg = JZZ.MIDI2.program(0, 1, 1);
ctxt._receive(msg);
assert.equal(msg.toString(), '20c10100 -- Program Change (1 2 3)');
msg = JZZ.MIDI2.umpProgram(0, 1, 2);
ctxt._receive(msg);
assert.equal(msg.toString(), '40c10000 02000000 -- Program Change (2 2 3)');
msg = JZZ.MIDI2.umpProgram(0, 1, 2, 3, 4);
ctxt._receive(msg);
assert.equal(msg.toString(), '40c10001 02000304 -- Program Change (2 3 4)');
// coverage
JZZ.MIDI.programName = undefined;
ctxt._receive(msg);
msg = JZZ.MIDI2.umpNoteOn(0, 0, 0, 0);
ctxt._receive(msg);
});
it('rpn 0', function(done) {
var ctxt = JZZ.Context();
Expand Down

0 comments on commit 614248c

Please sign in to comment.