Skip to content

Commit

Permalink
M2M1 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Nov 2, 2023
1 parent dd903c9 commit 01d3a88
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ by running `npm remove midi-test --save-dev`.

```html
<script src="https://cdn.jsdelivr.net/npm/jzz"></script> // the latest version, or
<script src="https://cdn.jsdelivr.net/npm/jzz@1.7.3"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/jzz@1.7.4"></script> // any particular version
//...
```

##### CDN (unpkg)

```html
<script src="https://unpkg.com/jzz"></script> // the latest version, or
<script src="https://unpkg.com/jzz@1.7.3"></script> // any particular version
<script src="https://unpkg.com/jzz@1.7.4"></script> // any particular version
//...
```

Expand Down
7 changes: 5 additions & 2 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
})(this, function() {

var _scope = typeof window === 'undefined' ? global : window;
var _version = '1.7.3';
var _version = '1.7.4';
var i, j, k, m, n;

/* istanbul ignore next */
Expand Down Expand Up @@ -538,8 +538,9 @@
_M2.prototype = new _R();
_M2.prototype._sxid = _M.prototype._sxid;
_M2.prototype._receive = function(msg) { this._sink._receive(msg); };
function _midi2(msg) { return msg.isMidi && !msg.isMidi2 ? new MIDI(msg) : UMP.apply(null, arguments); }
_M2.prototype.send = function() {
this._push(_receive, [UMP.apply(null, arguments)]);
this._push(_receive, [_midi2.apply(null, arguments)]);
return this._thenable();
};
_M2.prototype._image = _M.prototype._image;
Expand Down Expand Up @@ -1636,6 +1637,7 @@
}
MIDI.prototype = [];
MIDI.prototype.constructor = MIDI;
MIDI.prototype.isMidi = function() { return 1; };
var _noteNum = {};
MIDI.noteValue = function(x) { return typeof x == 'undefined' ? undefined : _noteNum[x.toString().toLowerCase()]; };
MIDI.programValue = function(x) { return x; };
Expand Down Expand Up @@ -2948,6 +2950,7 @@
}
UMP.prototype = [];
UMP.prototype.constructor = UMP;
UMP.prototype.isMidi = function() { return 2; };
UMP.prototype.isMidi2 = true;
UMP.prototype.dump = function() {
var i;
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jzz",
"version": "1.7.3",
"version": "1.7.4",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('MIDI messages', function() {
});
it('noteOn', function() {
var msg = JZZ.MIDI.noteOn(1, 'C5', 20);
assert.equal(msg.isMidi(), 1);
assert.equal(msg.getChannel(), 1);
assert.equal(msg.getNote(), 60);
assert.equal(msg.getVelocity(), 20);
Expand Down Expand Up @@ -773,6 +774,7 @@ describe('UMP messages', function() {
it('noop', function() {
var s = '00000000 -- NOOP';
var msg =JZZ.UMP.noop();
assert.equal(msg.isMidi(), 2);
assert.equal(msg.isNoteOn(), false);
assert.equal(msg.isNoteOff(), false);
assert.equal(typeof msg.getGroup(), 'undefined');
Expand Down Expand Up @@ -1546,13 +1548,15 @@ describe('JZZ.M1M2', function() {
describe('JZZ.M2M1', function() {
it('noteO/Off', function(done) {
var sample = new test.Sample(done, [
[0x91, 0x3c, 0x7f], [0x91, 0x3c, 0x7f],
[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);
port.send(JZZ.MIDI.noteOn(1, 'C5')).send(JZZ.UMP.noteOn(0, 1, 'C5'))
.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, [
Expand Down
2 changes: 1 addition & 1 deletion web-midi-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"web-midi-api"
],
"dependencies": {
"jzz": "^1.7.3"
"jzz": "^1.7.4"
},
"contributors": [
{
Expand Down

0 comments on commit 01d3a88

Please sign in to comment.