PC speaker: add option to reset phase on freq chan

ge

some motherboards do so
This commit is contained in:
tildearrow 2024-01-11 14:50:53 -05:00
parent 8a14435b4a
commit 53c625354b
3 changed files with 11 additions and 1 deletions

View file

@ -373,6 +373,9 @@ void DivPlatformPCSpeaker::tick(bool sysTick) {
if (chan[i].keyOff) {
on=false;
}
if (freq!=chan[i].freq && resetPhase) {
pos=0;
}
freq=chan[i].freq;
if (chan[i].keyOn) chan[i].keyOn=false;
if (chan[i].keyOff) chan[i].keyOff=false;
@ -610,6 +613,7 @@ void DivPlatformPCSpeaker::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/PCSPKR_DIVIDER;
speakerType=flags.getInt("speakerType",0)&3;
resetPhase=flags.getBool("resetPhase",false);
oscBuf->rate=rate;
switch (speakerType) {

View file

@ -51,7 +51,7 @@ class DivPlatformPCSpeaker: public DivDispatch {
FixedQueue<RealQueueVal,2048> realQueue;
std::mutex realQueueLock;
bool isMuted[1];
bool on, flip, lastOn, realOutEnabled;
bool on, flip, lastOn, realOutEnabled, resetPhase;
int pos, speakerType, beepFD, realOutMethod;
float low, band;
float low2, high2, band2;