Skip to content

Commit

Permalink
SysEx annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Aug 1, 2021
1 parent cfa5acc commit 82244c5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 9 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.3.7"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/jzz@1.3.8"></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.3.7"></script> // any particular version
<script src="https://unpkg.com/jzz@1.3.8"></script> // any particular version
//...
```

Expand Down
36 changes: 33 additions & 3 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.3.7';
var _version = '1.3.8';
var i, j, k, m, n;

var _time = Date.now || function () { return new Date().getTime(); };
Expand Down Expand Up @@ -2507,7 +2507,7 @@
msg._bl = this._cc[ch].bl;
if (JZZ.MIDI.programName) msg.label(JZZ.MIDI.programName(msg[1], msg._bm, msg._bl));
}
if (st == 11) {
else if (st == 11) {
switch (msg[1]) {
case 0: this._cc[ch].bm = msg[2]; break;
case 32: this._cc[ch].bl = msg[2]; break;
Expand All @@ -2526,10 +2526,40 @@
msg._nl = this._cc[ch].nl;
msg.label(_nrpn_txt(this._cc[ch].nm, this._cc[ch].nl));
}
this._cc[ch].rm = msg[2];
break;
}
}
else if (msg.isFullSysEx()) {
if (msg[1] == 0x7f) {
if (msg[3] == 4) {
if (msg[4] == 1) msg.label('Master Volume');
else if (msg[4] == 2) msg.label('Master Balance');
}
}
else if (msg[1] == 0x7e) {
if (msg[3] == 6) {
if (msg[4] == 1) msg.label('Device ID Request');
else if (msg[4] == 2) {
msg.label('Device ID Response');
}
}
else if (msg[3] == 9) {
if (msg[4] == 1) { msg.label('GM1 System On'); this._clear(); this._gm = '1'; }
else if (msg[4] == 2) { msg.label('GM System Off'); this._clear(); this._gm = '0'; }
else if (msg[4] == 3) { msg.label('GM2 System On'); this._clear(); this._gm = '2'; }
}
}
else if (msg[1] == 0x43) {
if ((msg[2] & 0xf0) == 0x10 && msg[3] == 0x4c && msg[4] == 0 && msg[5] == 0 && msg[6] == 0x7e && msg[7] == 0) {
msg.label('XG System On'); this._clear(); this._gm = 'Y';
}
}
else if (msg[1] == 0x41) {
if (msg[3] == 0x42 && msg[4] == 0x12 && msg[5] == 0x40 && msg[6] == 0 && msg[7] == 0x7f && msg[8] == 0 && msg[9] == 0x41) {
msg.label('GS Reset'); this._clear(); this._gm = 'R';
}
}
}
return msg;
}
function Context() {
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jzz",
"version": "1.3.7",
"version": "1.3.8",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand All @@ -21,7 +21,7 @@
"jazz-midi": "^1.7.5"
},
"devDependencies": {
"eslint": "^7.31.0",
"eslint": "^7.32.0",
"grunt": "^1.4.1",
"grunt-contrib-jshint": "^3.0.0",
"grunt-contrib-uglify": "^5.0.1",
Expand Down
30 changes: 30 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,36 @@ describe('JZZ.Context', function() {
});
ctxt.dataLSB(0, 0);
});
it('GM1', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI.sxGM(1);
ctxt._receive(msg);
assert.equal(msg.toString(), 'f0 7e 7f 09 01 f7 (GM1 System On)');
});
it('GM2', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI.sxGM(2);
ctxt._receive(msg);
assert.equal(msg.toString(), 'f0 7e 7f 09 03 f7 (GM2 System On)');
});
it('GM off', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI.sxGM(0);
ctxt._receive(msg);
assert.equal(msg.toString(), 'f0 7e 7f 09 02 f7 (GM System Off)');
});
it('GS', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI.sxGS();
ctxt._receive(msg);
assert.equal(msg.toString(), 'f0 41 7f 42 12 40 00 7f 00 41 f7 (GS Reset)');
});
it('XG', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI([0xf0, 0x43, 0x10, 0x4c, 0, 0, 0x7e, 0, 0xf7]);
ctxt._receive(msg);
assert.equal(msg.toString(), 'f0 43 10 4c 00 00 7e 00 f7 (XG System On)');
});
});

describe('Engine: none', function() {
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.3.6"
"jzz": "^1.3.8"
},
"contributors": [
{
Expand Down

0 comments on commit 82244c5

Please sign in to comment.