Skip to content

Commit

Permalink
isData/Flex/Text/SX()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Feb 23, 2024
1 parent f248661 commit 0337aeb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 0337aeb

Please sign in to comment.