Skip to content

Commit

Permalink
MIDI 2.0 - experimental support
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Jul 2, 2023
1 parent 838ce10 commit d5deb3e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 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/[email protected].4"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/[email protected].5"></script> // any particular version
//...
```

##### CDN (unpkg)

```html
<script src="https://unpkg.com/jzz"></script> // the latest version, or
<script src="https://unpkg.com/[email protected].4"></script> // any particular version
<script src="https://unpkg.com/[email protected].5"></script> // any particular version
//...
```

Expand Down
28 changes: 12 additions & 16 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.6.4';
var _version = '1.6.5';
var i, j, k, m, n;

/* istanbul ignore next */
Expand Down Expand Up @@ -2425,7 +2425,7 @@
function _hexx(x) {
var a = [];
for (var i = 0; i < x.length; i++) {
if (i && !(i % 4)) a.push(' ');
if (i && i % 4 == 0) a.push(' ');
a.push(__hex(x[i]));
}
return a.join('');
Expand Down Expand Up @@ -2921,7 +2921,7 @@
umpTicksPQN: function(n) { n = _16b(n); return [0, 0x30, n >> 8, n & 0xff]; },
umpDelta: function(n) { n = n || 0; n = _20b(n); return [0, 0x40 + (n >> 16), (n >> 8) & 0xff, n & 0xff]; },
umpStartClip: function() { return [0xf0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; },
umpEndClip: function() { return [0xf0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; },
umpEndClip: function() { return [0xf0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; }
};
var _helperGN = {
umpTempo: function(g, n) { return [0xd0 + g, 0x10, 0, 0, n >> 24, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff, 0, 0, 0, 0, 0, 0, 0, 0]; },
Expand All @@ -2932,23 +2932,19 @@
if (m) {
nn = parseInt(m[1]);
cc = parseInt(m[2]);
if (nn > 0 && nn < 0x100 && cc > 0 && !(cc & (cc - 1))) {
dd = 0;
for (cc >>= 1; cc; cc >>= 1) dd++;
return [0xd0 + g, 0x10, 0, 1, nn, dd, cc, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
}
else if (a == parseInt(a) && b == parseInt(b)) {
if (a > 0 && a < 0x100 && b > 0 && !(b & (b - 1))) {
nn = a;
dd = 0;
cc = b;
for (cc >>= 1; cc; cc >>= 1) dd++;
return [0xd0 + g, 0x10, 0, 1, nn, dd, cc, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
nn = parseInt(a);
cc = parseInt(b);
}
if (nn > 0 && nn < 0x100 && cc > 0 && !(cc & (cc - 1))) {
dd = 0;
for (cc >>= 1; cc; cc >>= 1) dd++;
cc = Math.round(nn * 32 / (1 << dd));
if (cc < 0x100) return [0xd0 + g, 0x10, 0, 1, nn, dd, cc, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
throw RangeError('Wrong time signature ' + a + (typeof b == 'undefined' ? '' : '/' + b));
},
}
};
var _helperGC = {
};
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.6.4",
"version": "1.6.5",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand All @@ -22,7 +22,7 @@
"jazz-midi": "^1.7.9"
},
"devDependencies": {
"eslint": "^8.43.0",
"eslint": "^8.44.0",
"grunt": "^1.6.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
Expand Down
3 changes: 2 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ describe('UMP messages', function() {
assert.equal(JZZ.UMP.gr(0).umpBPM(120).toString(), s);
});
it('umpTimeSignature', function() {
var s = 'd0100001 03020000 00000000 00000000 -- Time Signature 3/4';
var s = 'd0100001 03021800 00000000 00000000 -- Time Signature 3/4';
var msg = JZZ.UMP.umpTimeSignature(0, '3/4');
assert.equal(msg.isTimeSignature(), true);
assert.equal(msg.isTempo(), false);
Expand All @@ -894,6 +894,7 @@ describe('UMP messages', function() {
assert.equal(JZZ.UMP.gr(0).umpTimeSignature(3, 4).toString(), s);
assert.throws(function() { JZZ.UMP.gr(0).umpTimeSignature('1/5'); });
assert.throws(function() { JZZ.UMP.gr(0).umpTimeSignature(4, 3); });
assert.throws(function() { JZZ.UMP.gr(0).umpTimeSignature(100, 4); });
assert.throws(function() { JZZ.UMP.gr(0).umpTimeSignature(); });
});

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.6.4"
"jzz": "^1.6.5"
},
"contributors": [
{
Expand Down

0 comments on commit d5deb3e

Please sign in to comment.