[NCSF] Fix PSG output.
* Changed the base timer and actually utilize the note number from the note definition even for PSG. Thanks to Kurausukun for informing me about the issue and helping to provide a sample to demonstrate the issue.
* Correct the frequency output in the debug sound view (using DeSmuME's method directly resulted in frequencies that were 3 octaves higher than what they should have been).
--- a/src/in_ncsf/SSEQPlayer/Track.cpp
+++ b/src/in_ncsf/SSEQPlayer/Track.cpp
@@ -165,8 +165,7 @@
chn = &this->ply->channels[nCh];
chn->tempReg.CR = SOUND_FORMAT_PSG | SCHANNEL_ENABLE | SOUND_DUTY(noteDef->swav & 0x7);
}
- // TODO: figure out what pNoteDef->tnote means for PSG channels
- chn->tempReg.TIMER = -SOUND_FREQ(440 * 8); // key #69 (A4)
+ chn->tempReg.TIMER = -SOUND_FREQ(262 * 8); // key #60 (C4)
chn->reg.samplePosition = -1;
chn->reg.psgX = 0x7FFF;
}
@@ -192,7 +191,7 @@
chn->flags.reset();
chn->prio = this->prio;
chn->key = key;
- chn->orgKey = bIsPCM ? noteDef->noteNumber : 69;
+ chn->orgKey = noteDef->noteNumber;
chn->velocity = Cnv_Sust(vel);
chn->pan = static_cast<int>(noteDef->pan) - 64;
chn->modDelayCnt = 0;
--- a/src/in_ncsf/XSFConfig_NCSF.cpp
+++ b/src/in_ncsf/XSFConfig_NCSF.cpp
@@ -305,7 +305,7 @@
std::wstring tmpBuf = ConvertFuncs::StringToWString(NumToHexString(chn.reg.timer)).substr(2);
buf = L"$" + tmpBuf + L" (";
- tmpBuf = wstringify((ARM7_CLOCK / 2) / static_cast<double>(0x10000 - chn.reg.timer));
+ tmpBuf = wstringify((ARM7_CLOCK / 2) / static_cast<double>(0x10000 - chn.reg.timer) / 8);
if (tmpBuf.find('.') != std::wstring::npos)
tmpBuf = tmpBuf.substr(0, tmpBuf.find('.') + 2);
buf += tmpBuf + L" Hz)";