Skip to content

Commit

Permalink
getStatus()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Feb 24, 2024
1 parent 0337aeb commit 53f5097
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -3393,6 +3393,10 @@
UMP.prototype.getDelta = function() {
if (this.isDelta()) return ((this[1] & 15) << 16) + (this[2] << 8) + this[3];
};
UMP.prototype.getStatus = function() {
if (this.isFlex()) return this[1] >> 6;
if (this.isData() || this.isSX()) return this[1] >> 4;
};

UMP.prototype.isTempo = function() {
return (this[0] >> 4) == 13 && (this[1] >> 4) == 1 && this[2] == 0 && this[3] == 0;
Expand Down
6 changes: 6 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ describe('UMP messages', function() {
assert.equal(msg.isNoteOff(), false);
assert.equal(typeof msg.getGroup(), 'undefined');
assert.equal(typeof msg.getDelta(), 'undefined');
assert.equal(typeof msg.getStatus(), 'undefined');
assert(msg.dump(), '\0\0\0\0');
assert.equal(msg.toString(), s);
msg = new JZZ.UMP(msg);
Expand Down Expand Up @@ -858,6 +859,7 @@ describe('UMP messages', 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.getStatus(), 0);
assert.equal(msg.getGroup(), 7);
assert.equal(msg.toString(), s);
msg = JZZ.UMP.gr(7).sxIdRequest()[0];
Expand Down Expand Up @@ -944,9 +946,13 @@ describe('UMP messages', function() {
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[0].getStatus(), 1);
assert.equal(m[1].toString(), 'd595010f 6e672074 65787420 74686174 -- Unknown Text');
assert.equal(m[1].getStatus(), 2);
assert.equal(m[2].toString(), 'd595010f 20737061 6e73206f 76657220 -- Unknown Text');
assert.equal(m[2].getStatus(), 2);
assert.equal(m[3].toString(), 'd5d5010f 34206d65 73736167 65732100 -- Unknown Text');
assert.equal(m[3].getStatus(), 3);
assert.equal(JZZ.UMP.umpCustomText(5, 5, 0, 2, 15, '')[0].toString(), 'd505020f 00000000 00000000 00000000 -- Unknown Text');
});
it('umpMetadata', function() {
Expand Down

0 comments on commit 53f5097

Please sign in to comment.