diff --git a/javascript/JZZ.js b/javascript/JZZ.js index 4bd9011..c38b051 100644 --- a/javascript/JZZ.js +++ b/javascript/JZZ.js @@ -3404,6 +3404,10 @@ UMP.prototype.isDelta = function() { return this[0] == 0 && (this[1] >> 4) == 4; }; UMP.prototype.isStartClip = function() { return this.match([0xf0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); }; UMP.prototype.isEndClip = function() { return this.match([0xf0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); }; + UMP.prototype.isData = function() { return (this[0] & 0xf0) == 0x50; }; + UMP.prototype.isFlex = function() { return (this[0] & 0xf0) == 0xd0; }; + UMP.prototype.isText = function() { return (this[0] & 0xf0) == 0xd0 && (this[2] == 1 || this[2] == 2); }; + UMP.prototype.isSX = function() { return (this[0] & 0xf0) == 0x30; }; UMP.prototype.isNoteOn = function() { var c = (this[0] || 0) >> 4; var d = (this[1] || 0) >> 4; diff --git a/package.json b/package.json index df7476d..2d6e06a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "grunt-contrib-jshint": "^3.2.0", "grunt-contrib-uglify": "^5.2.2", "midi-test": "^1.2.8", - "mocha": "^10.2.0", + "mocha": "^10.3.0", "nyc": "^15.1.0", "web-audio-test": "^0.0.7", "web-midi-test": "^1.2.6" diff --git a/test/common.js b/test/common.js index b86c5d4..954f533 100644 --- a/test/common.js +++ b/test/common.js @@ -796,6 +796,10 @@ describe('UMP messages', function() { assert.equal(msg.isNoteOn(), true); assert.equal(msg.isNoteOff(), false); assert.equal(msg.getGroup(), 1); + assert.equal(msg.isData(), false); + assert.equal(msg.isFlex(), false); + assert.equal(msg.isText(), false); + assert.equal(msg.isSX(), false); assert.equal(JZZ.UMP.noteOn(1, 2, 'C#5').toString(), s); assert.equal(JZZ.UMP.ch().noteOn(1, 2, 'C#5').toString(), s); assert.equal(JZZ.UMP.ch(5).ch().noteOn(1, 2, 'C#5').toString(), s); @@ -853,6 +857,7 @@ describe('UMP messages', function() { it('sxIdRequest', function() { var s = '37047e7f 06010000 -- SysEx'; var msg = JZZ.UMP.sxId(1).sxId(1).sxId().sxId().sxIdRequest(7)[0]; + assert.equal(msg.isSX(), true); assert.equal(msg.getGroup(), 7); assert.equal(msg.toString(), s); msg = JZZ.UMP.gr(7).sxIdRequest()[0]; @@ -917,6 +922,8 @@ describe('UMP messages', function() { it('umpTimeSignature', function() { var s = 'd0100001 03021800 00000000 00000000 -- Time Signature 3/4'; var msg = JZZ.UMP.umpTimeSignature(0, '3/4'); + assert.equal(msg.isFlex(), true); + assert.equal(msg.isText(), false); assert.equal(msg.isTimeSignature(), true); assert.equal(msg.isTempo(), false); assert.equal(typeof msg.getBPM(), 'undefined'); @@ -934,6 +941,8 @@ describe('UMP messages', function() { }); it('umpCustomText', function() { var m = JZZ.UMP.umpCustomText(5, 5, 1, 1, 15, 'This is a long text that spans over 4 messages!'); + assert.equal(m[0].isFlex(), true); + assert.equal(m[0].isText(), true); assert.equal(m[0].toString(), 'd555010f 54686973 20697320 61206c6f -- Unknown Text'); assert.equal(m[1].toString(), 'd595010f 6e672074 65787420 74686174 -- Unknown Text'); assert.equal(m[2].toString(), 'd595010f 20737061 6e73206f 76657220 -- Unknown Text'); @@ -1129,6 +1138,8 @@ describe('UMP messages', function() { assert.throws(function() { JZZ.UMP.umpPnManagement(1, 2, 3, 'SS'); }); }); it('umpData', function() { + var m = JZZ.UMP.gr(0).umpData('data data data data data data'); + assert.equal(m[0].isData(), true); assert.equal(JZZ.UMP(0x50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).toString(), '50000000 00000000 00000000 00000000 -- Data'); assert.equal(JZZ.UMP.umpData(1, [])[0].toString(), '51000000 00000000 00000000 00000000 -- Data'); assert.equal(JZZ.UMP.umpData(1, '')[0].toString(), '51000000 00000000 00000000 00000000 -- Data');