From 80fe43cdd73168bad896f1ca66e5184b502b15dc Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Thu, 24 Oct 2013 20:11:52 -0700 Subject: [PATCH] Fixed arpeggio --- Frameworks/playptmod/playptmod/playptmod.c | 36 ++++++++-------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/Frameworks/playptmod/playptmod/playptmod.c b/Frameworks/playptmod/playptmod/playptmod.c index 2fa6d44f5..8eca66850 100644 --- a/Frameworks/playptmod/playptmod/playptmod.c +++ b/Frameworks/playptmod/playptmod/playptmod.c @@ -354,7 +354,7 @@ static const short rawAmigaPeriods[606] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; -static short extendedRawPeriods[16 * 85 + 13]; +static short extendedRawPeriods[16 * 85 + 14]; static const short npertab[84] = { @@ -2071,15 +2071,16 @@ static void processTremolo(player *p, mod_channel *ch) static void fxArpeggio(player *p, mod_channel *ch) { - char noteToAdd; char l; char m; char h; + char noteToAdd; char arpeggioTick; + unsigned char i; short *tablePointer; - + noteToAdd = 0; - + arpeggioTick = p->modTick % 3; if (arpeggioTick == 0) { @@ -2094,42 +2095,29 @@ static void fxArpeggio(player *p, mod_channel *ch) { noteToAdd = LO_NYBBLE(ch->param); } - + if (p->minPeriod == PT_MIN_PERIOD) // PT/NT/UST/STK { - l = 0; - h = 35; - tablePointer = (short *)&rawAmigaPeriods[ch->fineTune * 37]; - while (h >= l) + for (i = 0; i < 36; ++i) { - m = (h + l) / 2; - - if (tablePointer[m] == ch->period) + if (ch->period >= tablePointer[i]) { - p->tempPeriod = tablePointer[m + noteToAdd]; + p->tempPeriod = tablePointer[i + noteToAdd]; break; } - else if (tablePointer[m] > ch->period) - { - l = m + 1; - } - else - { - h = m - 1; - } } } else { l = 0; h = 83; - + tablePointer = (short *)&extendedRawPeriods[ch->fineTune * 85]; while (h >= l) { m = (h + l) / 2; - + if (tablePointer[m] == ch->period) { p->tempPeriod = tablePointer[m + noteToAdd]; @@ -2763,7 +2751,7 @@ void *playptmod_Create(int samplingFrequency) for (i = 0; i < 85; ++i) extendedRawPeriods[(j * 85) + i] = i == 84 ? 0 : npertab[i] * 8363 / finetune[j]; - for (i = 0; i < 13; ++i) + for (i = 0; i < 14; ++i) extendedRawPeriods[16 * 85 + i] = 0; p->soundFrequency = samplingFrequency;