PC speaker: fix cut freq

issue #1307
This commit is contained in:
tildearrow 2023-08-01 16:00:13 -05:00
parent 0c606103e3
commit f1b560cce9
2 changed files with 16 additions and 5 deletions

View file

@ -190,9 +190,6 @@ const char** DivPlatformPCSpeaker::getRegisterSheet() {
return regCheatSheetPCSpeaker;
}
const float cut=0.05;
const float reso=0.06;
void DivPlatformPCSpeaker::acquire_unfilt(short** buf, size_t len) {
int out=0;
for (size_t i=0; i<len; i++) {
@ -229,8 +226,8 @@ void DivPlatformPCSpeaker::acquire_cone(short** buf, size_t len) {
}
}
float next=(pos>((freq+16)>>1) && !isMuted[0])?1:0;
low+=0.04*band;
band+=0.04*(next-low-band);
low+=cut*band;
band+=cut*(next-low-band);
float out=(low+band)*0.75;
if (out>1.0) out=1.0;
if (out<-1.0) out=-1.0;
@ -612,6 +609,17 @@ void DivPlatformPCSpeaker::setFlags(const DivConfig& flags) {
rate=chipClock/PCSPKR_DIVIDER;
speakerType=flags.getInt("speakerType",0)&3;
oscBuf->rate=rate;
switch (speakerType) {
case 1:
cut=2.0*sin(M_PI*1900.0/rate);
reso=0.0;
break;
default:
cut=2.0*sin(M_PI*2375.0/rate);
reso=0.06;
break;
}
}
void DivPlatformPCSpeaker::notifyInsDeletion(void* ins) {

View file

@ -57,6 +57,9 @@ class DivPlatformPCSpeaker: public DivDispatch {
float low, band;
float low2, high2, band2;
float low3, band3;
float cut;
float reso;
unsigned short freq, lastFreq;
unsigned char regPool[2];