View Single Post
Mara's Avatar
Posts: 1,310 | Thanked: 820 times | Joined on Mar 2006 @ Irving, TX
#138
Originally Posted by maacruz View Post
Regarding this patch which causes so much paranoia around here I have been studying it today and it is a really nice feature to add, although it actually is not completely correct.

The chip actually has a proper hi-pass filter so no need to use the de-emph filter for this purpose (have a look at the data sheet referenced in the patch). Both hi-pass and de-emph are first order IIR filters.

Actually, as you can see in the attached graphic (ellip), the filter coefficients used are wrong, since the intended cutoff frequency is 0.01 of the Nyquist frequency (that is, 0.01*24000=240Hz) while the real cutoff frequency is half of the intended (that's because he calculated the coefs using an elliptic filter simulation, good for higher order, instead of just Butterworth).

Actually, as it has already been said, speakers protection is implemented in pulseaudio. This is bad for two and a half reasons:
1) pulseaudio eats a lot of cpu
1.5) I hate pulseaudio.
2) mplayer and friends can bypass pulseaudio (actually I bypass pulseaudio in mplayer) and damage the speakers accidentally.
This driver allows to implement all audio filtering in hardware, so 0 cpu usage.

With a little work we can:
1a) Reverse engineer pulseaudio Nokia filters for the different audio output profiles and calculate the coeficients for the IIR filters
1b) Enable a hi-pass filter to protect the speakers, no matter pulseaudio. The cutoff frequency proposed in the patch is around 240 Hz, but if we perform step 1a we can learn what cutoff frequency is Nokia using.
2) Disable filtering in pulseaudio lowering cpu usage by 66% and use some script to load them when the audio profile changes.

To do step 1a, only one question is needed: How to redirect PA output to a file instead of the pcm device? Then feed PA with pure sinusoids in thirds of octave frequencies and calculate the gain, then some algebra for the coefficients.

I'll start by enabling the hi-pass filter with correct coefficients instead of the de-emph filter.

EDIT: I forgot to mention, the right coefficients are 31770, -31770, 30771 instead of 32276, -32276, 31785. Calculated using "iir(1, 'hp', 'butt', [0.01 0], [0 0])" in scilab.
If I'm understanding this right the (high pass) filter purpose is to reject low frequencies (bass) from reaching the speakers? I agree that the tiny speakers N900 has, there is no benefit to push them the bass frequencies. They are not able to reproduce them anyway. All you'd get is just distorted harmonics of the bass, which I find to be very annoying and ruin the listening experinece.

Personally I do not believe you can "blow up the speakers" with the little audio amp N900 has. However, the filter benefits should be reduced distorsion and also lower power consumption since the amp doesn't need drive the bass enegy to speaker.

Just to make sure the filter is not in the audio path to headphones? I do not want to filter the bass out from headphone port.
 

The Following 2 Users Say Thank You to Mara For This Useful Post: