Fixed arpeggio

This commit is contained in:
Chris Moeller 2013-10-24 20:11:52 -07:00
parent 19af37059f
commit 80fe43cdd7

View file

@ -354,7 +354,7 @@ static const short rawAmigaPeriods[606] =
0,0,0,0,0,0,0,0,0,0,0,0,0,0 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] = static const short npertab[84] =
{ {
@ -2071,11 +2071,12 @@ static void processTremolo(player *p, mod_channel *ch)
static void fxArpeggio(player *p, mod_channel *ch) static void fxArpeggio(player *p, mod_channel *ch)
{ {
char noteToAdd;
char l; char l;
char m; char m;
char h; char h;
char noteToAdd;
char arpeggioTick; char arpeggioTick;
unsigned char i;
short *tablePointer; short *tablePointer;
noteToAdd = 0; noteToAdd = 0;
@ -2097,27 +2098,14 @@ static void fxArpeggio(player *p, mod_channel *ch)
if (p->minPeriod == PT_MIN_PERIOD) // PT/NT/UST/STK if (p->minPeriod == PT_MIN_PERIOD) // PT/NT/UST/STK
{ {
l = 0;
h = 35;
tablePointer = (short *)&rawAmigaPeriods[ch->fineTune * 37]; tablePointer = (short *)&rawAmigaPeriods[ch->fineTune * 37];
while (h >= l) for (i = 0; i < 36; ++i)
{ {
m = (h + l) / 2; if (ch->period >= tablePointer[i])
if (tablePointer[m] == ch->period)
{ {
p->tempPeriod = tablePointer[m + noteToAdd]; p->tempPeriod = tablePointer[i + noteToAdd];
break; break;
} }
else if (tablePointer[m] > ch->period)
{
l = m + 1;
}
else
{
h = m - 1;
}
} }
} }
else else
@ -2763,7 +2751,7 @@ void *playptmod_Create(int samplingFrequency)
for (i = 0; i < 85; ++i) for (i = 0; i < 85; ++i)
extendedRawPeriods[(j * 85) + i] = i == 84 ? 0 : npertab[i] * 8363 / finetune[j]; 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; extendedRawPeriods[16 * 85 + i] = 0;
p->soundFrequency = samplingFrequency; p->soundFrequency = samplingFrequency;