potentially breaking change: better freq formula
now using a 4096-entry-long table for calculating final period/frequency see issue #303
This commit is contained in:
parent
03da02711a
commit
ed857b20c4
3 changed files with 22 additions and 5 deletions
|
|
@ -832,9 +832,17 @@ double DivEngine::calcBaseFreq(double clock, double divider, int note, bool peri
|
|||
|
||||
int DivEngine::calcFreq(int base, int pitch, bool period, int octave) {
|
||||
if (song.linearPitch) {
|
||||
pitch+=2048;
|
||||
if (pitch<0) pitch=0;
|
||||
if (pitch>4095) pitch=4095;
|
||||
return period?
|
||||
(base*reversePitchTable[pitch])>>10:
|
||||
(base*pitchTable[pitch])>>10;
|
||||
/*
|
||||
return period?
|
||||
base*pow(2,-(double)pitch/(12.0*128.0))/(98.0+globalPitch*6.0)*98.0:
|
||||
(base*pow(2,(double)pitch/(12.0*128.0))*(98+globalPitch*6))/98;
|
||||
*/
|
||||
}
|
||||
return period?
|
||||
base-pitch:
|
||||
|
|
@ -2850,6 +2858,10 @@ bool DivEngine::init() {
|
|||
for (int i=0; i<64; i++) {
|
||||
vibTable[i]=127*sin(((double)i/64.0)*(2*M_PI));
|
||||
}
|
||||
for (int i=0; i<4096; i++) {
|
||||
reversePitchTable[i]=round(1024.0*pow(2.0,(2048.0-(double)i)/(12.0*128.0)));
|
||||
pitchTable[i]=round(1024.0*pow(2.0,((double)i-2048.0)/(12.0*128.0)));
|
||||
}
|
||||
|
||||
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
||||
isMuted[i]=0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue