X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=sound.c;h=f95b0505abd111b22532bde7d4fd0e84cd84cafa;hp=7e130fab3b4864b7d143fad596ba94eda684cf86;hb=87e3eef5be4a5de92f97ee211ae4035d8d4b6494;hpb=d447f17f693875013eed05ff3a2fce79cbe0b5f2 diff --git a/sound.c b/sound.c index 7e130fa..f95b050 100644 --- a/sound.c +++ b/sound.c @@ -39,13 +39,10 @@ #include "svga.h" #include "sound.h" -uint32 soundtsinc; -uint32 soundtsi; +uint32 Wave[2048+512]; +int16 WaveFinalMono[2048+512]; -uint32 Wave[2048]; -int16 WaveFinalMono[2048]; - -EXPSOUND GameExpSound={0,0,0}; +EXPSOUND GameExpSound={0,0,0,0,0,0}; uint8 trimode=0; uint8 tricoop=0; @@ -63,7 +60,7 @@ uint32 soundtsoffs=0; #undef printf uint16 nreg; -int32 lengthcount[4]; +static int32 lengthcount[4]; extern int soundvol; @@ -81,8 +78,10 @@ static const uint32 SNoiseFreqTable[0x10]= }; static uint32 NoiseFreqTable[0x10]; -static int32 nesincsize32; -int64 nesincsize; +int32 nesincsize; +uint32 soundtsinc; +uint32 soundtsi; + static const uint8 NTSCPCMTable[0x10]= { @@ -574,7 +573,7 @@ static void RDoPCM(int32 end) for(V=start;V>4]+=out; - sqacc[0]-=nesincsize32; + sqacc[0]-=nesincsize; if(sqacc[0]<=0) { rea: @@ -710,7 +709,7 @@ static void RDoSQ2(int32 end) for(V=start;V>4]+=out; - sqacc[1]-=nesincsize32; + sqacc[1]-=nesincsize; if(sqacc[1]<=0) { rea: @@ -764,7 +763,7 @@ static void RDoTriangle(int32 end) freq<<=17; for(V=start;V>16; - acc2+= (int32) (((int64)((diff-acc2)*lowp))>>16); + flt_acc += (diff*highp)>>16; + flt_acc2+= (int32) (((int64)((diff-flt_acc2)*lowp))>>16); *in=0; - *outMono = acc2*7 >> 2; // * 1.75 + *outMono = flt_acc2*7 >> sh; // * 7 >> 2 = * 1.75 // if (acc2 < min) { printf("min: %i %04x\n", acc2, acc2); min = acc2; } // if (acc2 > max) { printf("max: %i %04x\n", acc2, acc2); max = acc2; } } @@ -923,17 +923,6 @@ int FlushEmulateSound(void) GameExpSound.Fill(end&0xF); FilterSound(Wave,WaveFinalMono,end>>4); -// printf("count %d, num ints %d\n", end, (end >> 4)); - if(FCEUGameInfo.type==GIT_NSF) - { - int x;//,s=0,si=end/1024; - for(x=0;x<1024;x++) - { - //WaveNSF[x]=WaveFinal[s>>4]; - WaveNSF[x]=WaveFinalMono[x]; - //s+=si; - } - } if(end&0xF) Wave[0]=Wave[(end>>4)]; @@ -948,9 +937,9 @@ int FlushEmulateSound(void) return(end); } -int GetSoundBuffer(int32 **W) +int GetSoundBuffer(int16 **W) { - *W=WaveNSF; + *W=WaveFinalMono; return inbuf; } @@ -1008,8 +997,7 @@ void SetSoundVariables(void) GameExpSound.RChange(); // nesincsizeLL=(int64)((int64)562949953421312*(double)(PAL?PAL_CPU:NTSC_CPU)/(FSettings.SndRate OVERSAMPLE)); - nesincsize=(int64)(((int64)1<<17)*(double)(PAL?PAL_CPU:NTSC_CPU)/(FSettings.SndRate * 16)); // 308845 - 1832727 - nesincsize32=(int32)nesincsize; + nesincsize=(int32)(((int64)1<<17)*(double)(PAL?PAL_CPU:NTSC_CPU)/(FSettings.SndRate * 16)); // 308845 - 1832727 PSG_base=(uint32)(PAL?(long double)PAL_CPU/16:(long double)NTSC_CPU/16); for(x=0;x<0x10;x++) @@ -1029,6 +1017,8 @@ void SetSoundVariables(void) if(highp>(1<<16)) highp=1<<16; if(lowp>(1<<16)) lowp=1<<16; + + flt_acc=flt_acc2=0; } void FixOldSaveStateSFreq(void)