Skip to content

Commit

Permalink
Added parseInt() in MIDI parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Oct 24, 2018
1 parent ac9f25a commit 4318e53
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ by running `npm remove midi-test --save-dev`.
##### CDN

<script src="https://cdn.jsdelivr.net/npm/jzz"></script> // the latest version, or
<script src="https://cdn.jsdelivr.net/npm/jzz@0.5.8"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/jzz@0.5.9"></script> // any particular version
//...

##### CommonJS (Browserify and Node.js command line applications)
Expand Down
10 changes: 5 additions & 5 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
})(this, function() {

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

var _time = Date.now || function () { return new Date().getTime(); };
Expand Down Expand Up @@ -1465,10 +1465,10 @@
}
for (n = 0; n < 128; n++) _noteNum[n] = n;
function _throw(x) { throw RangeError('Bad MIDI value: ' + x); }
function _ch(n) { if (n != parseInt(n) || n < 0 || n > 0xf) _throw(n); return n; }
function _7b(n, m) { if (n != parseInt(n) || n < 0 || n > 0x7f) _throw(typeof m == 'undefined' ? n : m); return n; }
function _lsb(n) { if (n != parseInt(n) || n < 0 || n > 0x3fff) _throw(n); return n & 0x7f; }
function _msb(n) { if (n != parseInt(n) || n < 0 || n > 0x3fff) _throw(n); return n >> 7; }
function _ch(n) { if (n != parseInt(n) || n < 0 || n > 0xf) _throw(n); return parseInt(n); }
function _7b(n, m) { if (n != parseInt(n) || n < 0 || n > 0x7f) _throw(typeof m == 'undefined' ? n : m); return parseInt(n); }
function _lsb(n) { if (n != parseInt(n) || n < 0 || n > 0x3fff) _throw(n); return parseInt(n) & 0x7f; }
function _msb(n) { if (n != parseInt(n) || n < 0 || n > 0x3fff) _throw(n); return parseInt(n) >> 7; }
function _8bs(s) { s = '' + s; for (var i = 0; i < s.length; i++) if (s.charCodeAt(i) > 255) _throw(s[i]); return s; }
var _helperCH = {
noteOff: function(c, n, v) { if (typeof v == 'undefined') v = 64; return [0x80 + _ch(c), _7b(MIDI.noteValue(n), n), _7b(v)]; },
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": "0.5.8",
"version": "0.5.9",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions test/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ describe('MIDI messages', function() {
});
it('noteOff', function() {
assert.equal(JZZ.MIDI.noteOff(0, 'C6').toString(), '80 48 40 -- Note Off');
assert.equal(JZZ.MIDI.noteOff('0', 'C6').toString(), '80 48 40 -- Note Off');
});
it('aftertouch', function() {
assert.equal(JZZ.MIDI.aftertouch(0, 'C6', 127).toString(), 'a0 48 7f -- Aftertouch');
});
it('control', function() {
assert.equal(JZZ.MIDI.control(0, 6, 15).toString(), 'b0 06 0f -- Data Entry MSB');
assert.equal(JZZ.MIDI.control('0', '6', '15').toString(), 'b0 06 0f -- Data Entry MSB');
});
it('program', function() {
assert.equal(JZZ.MIDI.program(0, 0).toString(), 'c0 00 -- Program Change');
Expand All @@ -48,6 +50,7 @@ describe('MIDI messages', function() {
});
it('pitchBend', function() {
assert.equal(JZZ.MIDI.pitchBend(0, 300).toString(), 'e0 2c 02 -- Pitch Wheel');
assert.equal(JZZ.MIDI.pitchBend('0', '300').toString(), 'e0 2c 02 -- Pitch Wheel');
});
it('bankMSB', function() {
assert.equal(JZZ.MIDI.bankMSB(0, 15).toString(), 'b0 00 0f -- Bank Select MSB');
Expand All @@ -69,6 +72,7 @@ describe('MIDI messages', function() {
});
it('footMSB', function() {
assert.equal(JZZ.MIDI.footMSB(0, 15).toString(), 'b0 04 0f -- Foot Controller MSB');
assert.equal(JZZ.MIDI.footMSB('0', '15').toString(), 'b0 04 0f -- Foot Controller MSB');
});
it('footLSB', function() {
assert.equal(JZZ.MIDI.footLSB(0, 15).toString(), 'b0 24 0f -- Foot Controller LSB');
Expand Down

0 comments on commit 4318e53

Please sign in to comment.