diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index 41ef81ee..16a7c501 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -125,6 +125,9 @@ double DivPlatformSMS::NOTE_SN(int ch, int note) { if (parent->song.linearPitch==2 || !easyNoise) { return NOTE_PERIODIC(note); } + int easyStartingPeriod=16; + //int easyThreshold=round(CHIP_CLOCK/(parent->song.tuning*0.0625*pow(2.0,(float)(nbase+384)/(128.0*12.0)))/CHIP_DIVIDER); + int easyThreshold=round(log((CHIP_CLOCK/(easyStartingPeriod*CHIP_DIVIDER))/parent->song.tuning)/log(2.0)); if (note>easyThreshold) { return MAX(0,easyStartingPeriod-(note-easyThreshold)); } @@ -132,8 +135,9 @@ double DivPlatformSMS::NOTE_SN(int ch, int note) { } int DivPlatformSMS::snCalcFreq(int ch) { - if (parent->song.linearPitch==2 && easyNoise && chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2>(easyThreshold<<7)) { - int ret=(((easyStartingPeriod<<7)+0x40)-(chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2-(easyThreshold<<7)))>>7; + int easyThreshold=round(128.0*log((CHIP_CLOCK/(easyStartingPeriod*CHIP_DIVIDER))/parent->song.tuning)/log(2.0)); + if (parent->song.linearPitch==2 && easyNoise && chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2>(easyThreshold)) { + int ret=(((easyStartingPeriod<<7))-(chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2-(easyThreshold)))>>7; if (ret<0) ret=0; return ret; } @@ -464,38 +468,24 @@ void DivPlatformSMS::setFlags(const DivConfig& flags) { switch (flags.getInt("clockSel",0)) { case 1: chipClock=COLOR_PAL*4.0/5.0; - easyThreshold=84; - easyStartingPeriod=13; break; case 2: chipClock=4000000; - easyThreshold=86; - easyStartingPeriod=13; break; case 3: chipClock=COLOR_NTSC/2.0; - easyThreshold=72; - easyStartingPeriod=13; break; case 4: chipClock=3000000; - easyThreshold=81; - easyStartingPeriod=13; break; case 5: chipClock=2000000; - easyThreshold=74; - easyStartingPeriod=13; break; case 6: chipClock=COLOR_NTSC/8.0; - easyThreshold=48; - easyStartingPeriod=13; break; default: chipClock=COLOR_NTSC; - easyThreshold=84; - easyStartingPeriod=13; break; } CHECK_CUSTOM_CLOCK; @@ -569,6 +559,7 @@ void DivPlatformSMS::setFlags(const DivConfig& flags) { stereo=false; break; } + rate=chipClock/divider; for (int i=0; i<4; i++) { oscBuf[i]->rate=rate; diff --git a/src/engine/platform/sms.h b/src/engine/platform/sms.h index ce3ee5e7..41f0efe4 100644 --- a/src/engine/platform/sms.h +++ b/src/engine/platform/sms.h @@ -65,8 +65,6 @@ class DivPlatformSMS: public DivDispatch { int divider=16; double toneDivider=64.0; double noiseDivider=64.0; - int easyThreshold; - int easyStartingPeriod; bool updateSNMode; bool resetPhase; bool isRealSN;