Skip to content

Commit

Permalink
More MIDI 2.0 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Sep 20, 2023
1 parent 7d03b9b commit 1610129
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
16 changes: 9 additions & 7 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,12 @@
_M2.prototype._image = _M.prototype._image;
_M2.prototype.connect = function(arg) {
this._sink.connect(arg);
this._push(_kick, [this._sink]);
return this._thenable();
};
_M2.prototype.disconnect = function(arg) {
this._sink.disconnect(arg);
this._push(_kick, [this._sink]);
return this._thenable();
};
_M2.prototype.connected = function() { return this._sink.connected(); };
Expand Down Expand Up @@ -2975,7 +2977,7 @@
UMP.gr = function(g) {
if (g == this._gr || typeof g == 'undefined' && typeof this._gr == 'undefined') return this;
var ret = new _UMP();
if (typeof g != 'undefined') g = _ch(g);
if (typeof g != 'undefined') g = _4b(g);
ret._ch = this._ch;
ret._gr = g;
ret._sxid = this._sxid;
Expand Down Expand Up @@ -3162,12 +3164,12 @@
UMP[name] = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof this._gr != 'undefined') args = [this._gr].concat(args);
return _sliceSX(args[0], func.apply(this, args.slice(1)));
return _sliceSX(_4b(args[0]), func.apply(this, args.slice(1)));
};
_helpersUmp[name] = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof this._gr != 'undefined') args = [this._gr].concat(args);
var a = _sliceSX(args[0], func.apply(this, args.slice(1)));
var a = _sliceSX(_4b(args[0]), func.apply(this, args.slice(1)));
var g = this;
for (var i = 0; i < a.length; i++) g = g.send(a[i]);
return g;
Expand All @@ -3178,25 +3180,25 @@
var args = Array.prototype.slice.call(arguments);
if (typeof this._gr != 'undefined') args = [this._gr].concat(args);
if (typeof this._ch != 'undefined') args = [args[0]].concat([this._ch]).concat(args.slice(1));
return new UMP([0x20 + args[0]].concat(func.apply(this, args.slice(1)), [0]).slice(0, 4));
return new UMP([0x20 + _4b(args[0])].concat(func.apply(this, args.slice(1)), [0]).slice(0, 4));
};
_helpersUmp[name] = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof this._gr != 'undefined') args = [this._gr].concat(args);
if (typeof this._ch != 'undefined') args = [args[0]].concat([this._ch]).concat(args.slice(1));
return this.send([0x20 + args[0]].concat(func.apply(this, args.slice(1)), [0]).slice(0, 4));
return this.send([0x20 + _4b(args[0])].concat(func.apply(this, args.slice(1)), [0]).slice(0, 4));
};
}
function _copyHelperM1N(name, func) {
UMP[name] = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof this._gr != 'undefined') args = [this._gr].concat(args);
return new UMP([0x10 + args[0]].concat(func.apply(this, args.slice(1)), [0, 0]).slice(0, 4));
return new UMP([0x10 + _4b(args[0])].concat(func.apply(this, args.slice(1)), [0, 0]).slice(0, 4));
};
_helpersUmp[name] = function() {
var args = Array.prototype.slice.call(arguments);
if (typeof this._gr != 'undefined') args = [this._gr].concat(args);
return this.send([0x10 + args[0]].concat(func.apply(this, args.slice(1)), [0, 0]).slice(0, 4));
return this.send([0x10 + _4b(args[0])].concat(func.apply(this, args.slice(1)), [0, 0]).slice(0, 4));
};
}
_for(_helperNN, function(n) { _copyHelperNN(n, _helperNN[n]); });
Expand Down
11 changes: 7 additions & 4 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,7 @@ describe('JZZ.Widget', function() {
]);
var port = JZZ.Widget({ _receive: function(msg) { sample.compare(msg); }});
assert.throws(function() { port.gr(1); });
assert.throws(function() { port.MIDI2.gr(16); });
port.MIDI2().noteOn(0, 0, 64).gr(1).gr(1).noteOn(0, 64).gr().gr().noteOn(2, 0, 64).gr(5)
.MIDI2().noteOn(3, 0, 64).ch(5).noteOn(3, 64, 127).close();
});
Expand All @@ -1414,9 +1415,10 @@ describe('JZZ.Widget', function() {
[17, 255, 0, 0],
[18, 255, 0, 0]
]);
var port = JZZ.Widget();
var port = JZZ.Widget().MIDI2();
assert.throws(function() { port.reset(16); });
port.connect(function(msg) { sample.compare(msg); });
port.MIDI2().reset(1).gr(2).reset();
port.reset(1).gr(2).reset();
});
it('umpNoteOn', function(done) {
var sample = new test.Sample(done, [
Expand All @@ -1441,9 +1443,10 @@ describe('JZZ.Widget', function() {
[50, 22, 65, 127, 66, 18, 64, 0],
[50, 51, 127, 0, 65, 0, 0, 0]
]);
var port = JZZ.Widget();
var port = JZZ.Widget().MIDI2();
port.connect(function(msg) { sample.compare(msg); });
port.MIDI2().sxGS(1).gr(2).sxGS();
assert.equal(port.connected(), 1);
port.sxGS(1).gr(2).sxGS().disconnect();
});
it('umpBPM', function(done) {
var sample = new test.Sample(done, [
Expand Down

0 comments on commit 1610129

Please sign in to comment.