Skip to content

Commit

Permalink
gs/xgMasterFineTuningF()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Nov 18, 2021
1 parent 74432ae commit 658dd84
Show file tree
Hide file tree
Showing 3 changed files with 13 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 @@ -1803,6 +1803,8 @@
gsMasterVolume: function(n) { return _helperNC.sxGS.call(this, [0x40, 0, 4, _7b(n)]); },
gsMasterVolumeF: function(x) { return _helperNC.gsMasterVolume.call(this, MIDI.to7b(_01(x))); },
gsMasterFineTuning: function(a, b, c, d) { a = _splitMasterTuning(a, b, c, d); return _helperNC.sxGS.call(this, [0x40, 0, 0, a[0], a[1], a[2], a[3]]); },
gsMasterFineTuningF: function(x) { if (x != parseFloat(x) || x < -1 || x > 1) throw RangeError('Must be a value from -1 t0 1: ' + x);
return _helperNC.gsMasterFineTuning.call(this, [Math.floor(x * 1000) + 0x400]); },
gsMasterCoarseTuning: function(n) { return _helperNC.sxGS.call(this, [0x40, 0, 5, _7b(n)]); },
gsMasterCoarseTuningF: function(x) { return _helperNC.gsMasterCoarseTuning.call(this, 0x40 + (x - x % 1)); },
gsOctaveTuning: function(c, n, x) { return _helperNC.sxGS.call(this, [0x40, 0x10 + [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15][_ch(c)], 0x40 + MIDI.octaveValue(n), _7b(x)]); },
Expand All @@ -1811,6 +1813,8 @@
xgMasterVolume: function(n) { return _helperNC.sxXG.call(this, [0, 0, 4, _7b(n)]); },
xgMasterVolumeF: function(x) { return _helperNC.xgMasterVolume.call(this, MIDI.to7b(_01(x))); },
xgMasterFineTuning: function(a, b, c, d) { a = _splitMasterTuning(a, b, c, d); return _helperNC.sxXG.call(this, [0, 0, 0, a[0], a[1], a[2], a[3]]); },
xgMasterFineTuningF: function(x) { if (x != parseFloat(x) || x < -1 || x > 1) throw RangeError('Must be a value from -1 t0 1: ' + x);
return _helperNC.xgMasterFineTuning.call(this, [Math.floor(x * 1000) + 0x400]); },
xgMasterCoarseTuning: function(n) { return _helperNC.sxXG.call(this, [0, 0, 6, _7b(n)]); },
xgMasterCoarseTuningF: function(x) { return _helperNC.xgMasterCoarseTuning.call(this, 0x40 + (x - x % 1)); },
xgOctaveTuning: function(c, n, x) { return _helperNC.sxXG.call(this, [8, _ch(c), 0x41 + MIDI.octaveValue(n), _7b(x)]); },
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ describe('MIDI messages', function() {
assert.equal(JZZ.MIDI.gsMasterFineTuning(0, 1, 2, 3).toString(), 'f0 41 7f 42 12 40 00 00 00 01 02 03 3a f7');
assert.equal(JZZ.MIDI.gsMasterFineTuning(0x123).toString(), 'f0 41 7f 42 12 40 00 00 00 01 02 03 3a f7');
assert.throws(function() { JZZ.MIDI.gsMasterFineTuning(); });
assert.equal(JZZ.MIDI.gsMasterFineTuningF(0).toString(), 'f0 41 7f 42 12 40 00 00 00 04 00 00 3c f7');
assert.equal(JZZ.MIDI.gsMasterFineTuningF(1).toString(), 'f0 41 7f 42 12 40 00 00 00 07 0e 08 23 f7');
assert.equal(JZZ.MIDI.gsMasterFineTuningF(-1).toString(), 'f0 41 7f 42 12 40 00 00 00 00 01 08 37 f7');
assert.throws(function() { JZZ.MIDI.gsMasterFineTuningF(2); });
assert.equal(JZZ.MIDI.gsMasterCoarseTuning(0x41).toString(), 'f0 41 7f 42 12 40 00 05 41 7a f7');
assert.equal(JZZ.MIDI.gsMasterCoarseTuningF(1).toString(), 'f0 41 7f 42 12 40 00 05 41 7a f7');
assert.equal(JZZ.MIDI.gsMasterTranspose(0x41).toString(), 'f0 41 7f 42 12 40 00 05 41 7a f7');
Expand All @@ -667,6 +671,10 @@ describe('MIDI messages', function() {
assert.equal(JZZ.MIDI.xgMasterFineTuning(0, 1, 2, 3).toString(), 'f0 43 10 4c 00 00 00 00 01 02 03 f7');
assert.equal(JZZ.MIDI.xgMasterFineTuning(0x123).toString(), 'f0 43 10 4c 00 00 00 00 01 02 03 f7');
assert.throws(function() { JZZ.MIDI.xgMasterFineTuning(); });
assert.equal(JZZ.MIDI.xgMasterFineTuningF(0).toString(), 'f0 43 10 4c 00 00 00 00 04 00 00 f7');
assert.equal(JZZ.MIDI.xgMasterFineTuningF(1).toString(), 'f0 43 10 4c 00 00 00 00 07 0e 08 f7');
assert.equal(JZZ.MIDI.xgMasterFineTuningF(-1).toString(), 'f0 43 10 4c 00 00 00 00 00 01 08 f7');
assert.throws(function() { JZZ.MIDI.xgMasterFineTuningF(2); });
assert.equal(JZZ.MIDI.xgMasterCoarseTuning(0x41).toString(), 'f0 43 10 4c 00 00 06 41 f7');
assert.equal(JZZ.MIDI.xgMasterCoarseTuningF(1).toString(), 'f0 43 10 4c 00 00 06 41 f7');
assert.equal(JZZ.MIDI.xgMasterTranspose(0x41).toString(), 'f0 43 10 4c 00 00 06 41 f7');
Expand Down

0 comments on commit 658dd84

Please sign in to comment.