Implement all vibrato waveforms
This commit is contained in:
parent
fb103e61bc
commit
0e47b13d83
1 changed files with 19 additions and 1 deletions
20
xmeffects.js
20
xmeffects.js
|
|
@ -65,7 +65,7 @@ function eff_t0_4(ch, data) { // vibrato
|
||||||
}
|
}
|
||||||
|
|
||||||
function eff_t1_4(ch) { // vibrato
|
function eff_t1_4(ch) { // vibrato
|
||||||
ch.periodoffset = Math.sin(ch.vibratopos * Math.PI / 32) * ch.vibratodepth;
|
ch.periodoffset = getVibratoDelta(ch.vibratotype, ch.vibratopos) * ch.vibratodepth;
|
||||||
if (isNaN(ch.periodoffset)) {
|
if (isNaN(ch.periodoffset)) {
|
||||||
console.log("vibrato periodoffset NaN?",
|
console.log("vibrato periodoffset NaN?",
|
||||||
ch.vibratopos, ch.vibratospeed, ch.vibratodepth);
|
ch.vibratopos, ch.vibratospeed, ch.vibratodepth);
|
||||||
|
|
@ -75,6 +75,24 @@ function eff_t1_4(ch) { // vibrato
|
||||||
ch.vibratopos &= 63;
|
ch.vibratopos &= 63;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getVibratoDelta(type, x) {
|
||||||
|
var delta = 0;
|
||||||
|
switch (type & 0x03) {
|
||||||
|
case 1: // sawtooth (ramp-down)
|
||||||
|
delta = ((1 + x * 2 / 64) % 2) - 1;
|
||||||
|
break;
|
||||||
|
case 2: // square
|
||||||
|
case 3: // random (in FT2 these two are the same)
|
||||||
|
delta = x < 32 ? 1 : -1;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default: // sine
|
||||||
|
delta = Math.sin(x * Math.PI / 32);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
function eff_t1_5(ch) { // portamento + volume slide
|
function eff_t1_5(ch) { // portamento + volume slide
|
||||||
eff_t1_a(ch);
|
eff_t1_a(ch);
|
||||||
eff_t1_3(ch);
|
eff_t1_3(ch);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue