NES: fix high pitch being out of tune

This commit is contained in:
tildearrow 2022-02-17 21:59:48 -05:00
parent 7d9749d0ef
commit eafc3078cf
2 changed files with 4 additions and 4 deletions

View File

@ -4927,8 +4927,8 @@ int DivEngine::calcBaseFreq(double clock, double divider, int note, bool period)
int DivEngine::calcFreq(int base, int pitch, bool period, int octave) {
if (song.linearPitch) {
return period?
int(base*pow(2,-(double)pitch/(12.0*128.0))/(98.0+globalPitch*6.0)*98.0):
(int(base*pow(2,(double)pitch/(12.0*128.0))*(98+globalPitch*6))/98);
round(base*pow(2,-(double)pitch/(12.0*128.0))/(98.0+globalPitch*6.0)*98.0):
(round(base*pow(2,(double)pitch/(12.0*128.0))*(98+globalPitch*6))/98);
}
return period?
base-pitch:

View File

@ -198,9 +198,9 @@ void DivPlatformNES::tick() {
int ntPos=chan[i].baseFreq;
if (ntPos<0) ntPos=0;
if (ntPos>252) ntPos=252;
chan[i].freq=(parent->song.properNoiseLayout)?(15-(chan[i].baseFreq&15)):(noiseTable[ntPos]);
chan[i].freq=(parent->song.properNoiseLayout)?(15-(chan[i].baseFreq&15)):(noiseTable[ntPos])-1;
} else {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1;
if (chan[i].freq>2047) chan[i].freq=2047;
}
if (chan[i].keyOn) {