[#5] implement volume effect vibrato

This commit is contained in:
Andy Sloane 2015-11-20 17:42:01 -08:00
commit 65a2ea2863
2 changed files with 19 additions and 6 deletions

9
test/effects.js vendored
View file

@ -94,8 +94,9 @@ exports['test 4xy vibrato'] = function(assert) {
[[-1, -1, -1, 4, 0x02]], // --- -- -- 402
[[-1, -1, -1, 4, 0x10]], // --- -- -- 410
[[-1, -1, -1, 4, 0x00]], // --- -- -- 400
[[-1, -1, -1, 0, 0x00]], // --- -- -- 000 - no vibrato
[[-1, -1, -1, 0, 0x00]], // --- -- -- --- - no vibrato
[[-1, -1, -1, 4, 0x00]], // --- -- -- 400 - resume vibrato @ pos 0
[[-1, -1, 0xb2, 0, 0x00]], // --- -- V2 --- - volume effect vibrato
];
// I should really be testing ch.doff directly
XMPlayer.xm.tempo = 3;
@ -151,6 +152,12 @@ exports['test 4xy vibrato'] = function(assert) {
XMPlayer.nextTick(); // row 5 tick 1
p = -16*12 * Math.log(ch.doff / p0) / Math.log(2);
assert.equal(p.toFixed(3), "-1.546", 'row 5 tick 1 period -1.546');
XMPlayer.nextTick(); // row 5 tick 2
p = -16*12 * Math.log(ch.doff / p0) / Math.log(2);
assert.equal(p.toFixed(3), "-1.414", 'row 5 tick 2 period -1.414');
XMPlayer.nextTick(); // row 6 tick 0
p = -16*12 * Math.log(ch.doff / p0) / Math.log(2);
assert.equal(p.toFixed(3), "-1.269", 'row 6 tick 0 period -1.269');
};
exports['test Axy volume slide'] = function(assert) {

6
xm.js
View file

@ -207,6 +207,12 @@ function nextRow() {
ch.vol = Math.max(0, ch.vol - (v & 0x0f));
} else if (v >= 0x90 && v < 0xa0) { // fine volume slide up
ch.vol = Math.min(64, ch.vol + (v & 0x0f));
} else if (v >= 0xa0 && v < 0xb0) { // vibrato speed
ch.vibratospeed = v & 0x0f;
} else if (v >= 0xb0 && v < 0xc0) { // vibrato w/ depth
ch.vibratodepth = v & 0x0f;
ch.voleffectfn = player.effects_t1[4]; // use vibrato effect directly
player.effects_t1[4](ch); // and also call it on tick 0
} else if (v >= 0xc0 && v < 0xd0) { // set panning
ch.pan = (v & 0x0f) * 0x11;
} else {