Skip to content

Commit

Permalink
getDelta()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Aug 3, 2023
1 parent 876957e commit ed59edc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -3016,13 +3016,17 @@
UMP.prototype.getTimeSignature = function() {
if (this.isTimeSignature()) return [this[4], 1 << this[5]];
};
UMP.prototype.getDelta = function() {
if (this.isDelta()) return ((this[1] & 15) << 16) + (this[2] << 8) + this[3];
};

UMP.prototype.isTempo = function() {
return (this[0] >> 4) == 13 && (this[1] >> 4) == 1 && this[2] == 0 && this[3] == 0;
};
UMP.prototype.isTimeSignature = function() {
return (this[0] >> 4) == 13 && (this[1] >> 4) == 1 && this[2] == 0 && this[3] == 1;
};
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]); };

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"jazz-midi": "^1.7.9"
},
"devDependencies": {
"eslint": "^8.44.0",
"eslint": "^8.46.0",
"grunt": "^1.6.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
Expand Down
5 changes: 4 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ describe('UMP messages', function() {
var s = '00000000 -- NOOP';
var msg =JZZ.UMP.noop();
assert.equal(typeof msg.getGroup(), 'undefined');
assert.equal(typeof msg.getDelta(), 'undefined');
assert.equal(msg.toString(), s);
msg = new JZZ.UMP(msg);
assert.equal(msg.toString(), s);
Expand Down Expand Up @@ -860,8 +861,10 @@ describe('UMP messages', function() {
assert.throws(function() { JZZ.UMP.umpTicksPQN(0x10000); });
});
it('umpDelta', function() {
var msg = JZZ.UMP.umpDelta(96);
assert.equal(msg.getDelta(), 96);
assert.equal(msg.toString(), '00400060 -- Delta Ticks');
assert.equal(JZZ.UMP.umpDelta().toString(), '00400000 -- Delta Ticks');
assert.equal(JZZ.UMP.umpDelta(96).toString(), '00400060 -- Delta Ticks');
assert.throws(function() { JZZ.UMP.umpDelta(0x100000); });
});
it('umpStartClip', function() {
Expand Down

0 comments on commit ed59edc

Please sign in to comment.