Skip to content

Commit

Permalink
UMP clock messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Jun 28, 2023
1 parent dec723f commit 3748977
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
10 changes: 6 additions & 4 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -2916,10 +2916,12 @@

var _helperNN = {
noop: function() { return [0, 0, 0, 0]; },
ticksPQN: function(n) { n = _16b(n); return [0, 0x30, n >> 8, n & 0xff]; },
delta: function(n) { n = _20b(n); return [0, 0x40 + (n >> 16), (n >> 8) & 0xff, n & 0xff]; },
clipStart: function() { return [0xf0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; },
clipEnd: function() { return [0xf0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; },
umpClock: function(n) { n = _16b(n); return [0, 0x10, n >> 8, n & 0xff]; },
umpTimestamp: function(n) { n = _16b(n); return [0, 0x20, n >> 8, n & 0xff]; },
umpTicksPQN: function(n) { n = _16b(n); return [0, 0x30, n >> 8, n & 0xff]; },
umpDelta: function(n) { n = n || 0; n = _20b(n); return [0, 0x40 + (n >> 16), (n >> 8) & 0xff, n & 0xff]; },
umpStartClip: function() { return [0xf0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; },
umpEndClip: function() { return [0xf0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; },
};
var _helperGC = {
};
Expand Down
27 changes: 17 additions & 10 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,21 +846,28 @@ describe('UMP messages', function() {
it('sxMidiSoft', function() {
assert.equal(JZZ.UMP.sxMidiSoft(5, 4, 'karaoke...').toString(), '35160020 2400046b,35266172 616f6b65,35332e2e 2e000000');
});
it('ticksPQN', function() {
assert.equal(JZZ.UMP.ticksPQN(96).toString(), '00300060');
assert.throws(function() { JZZ.UMP.ticksPQN(0x10000); });
it('umpClock', function() {
assert.equal(JZZ.UMP.umpClock(96).toString(), '00100060');
});
it('delta', function() {
assert.equal(JZZ.UMP.delta(96).toString(), '00400060');
assert.throws(function() { JZZ.UMP.delta(0x100000); });
it('umpTimestamp', function() {
assert.equal(JZZ.UMP.umpTimestamp(96).toString(), '00200060');
});
it('clipStart', function() {
var msg = JZZ.UMP.clipStart();
it('umpTicksPQN', function() {
assert.equal(JZZ.UMP.umpTicksPQN(96).toString(), '00300060');
assert.throws(function() { JZZ.UMP.umpTicksPQN(0x10000); });
});
it('umpDelta', function() {
assert.equal(JZZ.UMP.umpDelta().toString(), '00400000');
assert.equal(JZZ.UMP.umpDelta(96).toString(), '00400060');
assert.throws(function() { JZZ.UMP.umpDelta(0x100000); });
});
it('umpStartClip', function() {
var msg = JZZ.UMP.umpStartClip();
assert.equal(typeof msg.getGroup(), 'undefined');
assert.equal(msg.toString(), 'f0200000 00000000 00000000 00000000');
});
it('clipEnd', function() {
assert.equal(JZZ.UMP.clipEnd().toString(), 'f0210000 00000000 00000000 00000000');
it('umpEndClip', function() {
assert.equal(JZZ.UMP.umpEndClip().toString(), 'f0210000 00000000 00000000 00000000');
});
});

Expand Down

0 comments on commit 3748977

Please sign in to comment.