Smooth sound after loading state

Moved function-level static variables outside of functions and renamed them
This commit is contained in:
Dwedit
2018-03-15 19:50:46 -05:00
parent 16170cdfa7
commit b9df5f188c
3 changed files with 65 additions and 38 deletions

View File

@@ -41,8 +41,9 @@ void SexyFilter2(int32 *in, int32 count) {
}
}
int64 sexyfilter_acc1 = 0, sexyfilter_acc2 = 0;
void SexyFilter(int32 *in, int32 *out, int32 count) {
static int64 acc1 = 0, acc2 = 0;
int32 mul1, mul2, vmul;
mul1 = (94 << 16) / FSettings.SndRate;
@@ -56,12 +57,12 @@ void SexyFilter(int32 *in, int32 *out, int32 count) {
while (count) {
int64 ino = (int64) * in * vmul;
acc1 += ((ino - acc1) * mul1) >> 16;
acc2 += ((ino - acc1 - acc2) * mul2) >> 16;
sexyfilter_acc1 += ((ino - sexyfilter_acc1) * mul1) >> 16;
sexyfilter_acc2 += ((ino - sexyfilter_acc1 - sexyfilter_acc2) * mul2) >> 16;
/* printf("%d ",*in); */
*in = 0;
{
int32 t = (acc1 - ino + acc2) >> 16;
int32 t = (sexyfilter_acc1 - ino + sexyfilter_acc2) >> 16;
/* if(t>32767 || t<-32768) printf("Flow: %d\n",t); */
if (t > 32767) t = 32767;
if (t < -32768) t = -32768;