DavidGriffith / gorilla-audio

Automatically exported from code.google.com/p/gorilla-audio
MIT License
0 stars 0 forks source link

I believe there is a bug in ga.c line 769 #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
dst[i] += (gc_int32)((gc_int32)src[j] * gain * (1.0f - pan) * 2);
dst[i + 1] += (gc_int32)((gc_int32)src[j + ((srcChannels == 1) ? 0 : 1)] * gain 
* pan * 2);

Should be:

gc_float32 lmul = gain * (pan < 0.5 ? 1 : (1 - pan) * 2);
gc_float32 rmul = gain * (pan > 0.5 ? 1 : pan * 2);
dst[i] += (gc_int32)((gc_int32)src[j] * lmul);
dst[i + 1] += (gc_int32)((gc_int32)src[j + ((srcChannels == 1) ? 0 : 1)] * 
rmul);

So, the * 2 was causing loud noises to cut out when panned. 

Original issue reported on code.google.com by zel...@gmail.com on 26 Sep 2014 at 5:56