| 166 | } |
| 167 | |
| 168 | inline short DCFilter(short sample_in) |
| 169 | { |
| 170 | if (g_uDCFilterState == 0) // no sound for a while, stay 0 |
| 171 | return 0; |
| 172 | |
| 173 | if (g_uDCFilterState >= 32768) // full gain after recent sound |
| 174 | { |
| 175 | g_uDCFilterState--; |
| 176 | return sample_in; |
| 177 | } |
| 178 | |
| 179 | return (((int)sample_in) * (g_uDCFilterState--)) / 32768; // scale & divide by 32768 (NB. Don't ">>15" as undefined behaviour) |
| 180 | } |
| 181 | |
| 182 | //============================================================================= |
| 183 |