Re: [Ekiga-list] Bad sound quality because of missing low pass filter

2010-03-02 Thread Damien Sandras
Le lundi 01 mars 2010 à 22:47 -0500, Christian Jaeger a écrit :

 Hello
 
 I'm using Ekiga and Twinkle with the Diamondcard.us service as my main
 phone service. People are telling me every now and then that the sound
 quality is pretty poor, and in fact when I listen to my voice on the
 echo service it's always been quite much worse than when using a
 normal phone I think. It's regardless of the codec used, all that
 are offered by Diamondcard are using 8000 Hz sampling rate. And I'm
 using a headset and have checked sound quality locally, which is just
 fine, as I can verify for example with (the bfr command is to delay
 playback, so you can hear the echo better):
 
 arecord -t raw -f dat -r 22050 -c 1 | bfr -m 33075 | aplay -t raw -f
 dat -r 22050 -c 1 -
 
 Now 8000 Hz is of course lower, and in fact when using that rate:
 
 arecord -t raw -f dat -r 8000 -c 1 | bfr -m 12000 | aplay -t raw -f
 dat -r 8000 -c 1 -
 
 it sounds exactly as in the echo test. Now one thing I know is that if
 you sample a signal, you need a low pass before the quantization, at
 half the sample rate or lower, to remove frequencies that are too high
 to be represented in the digitalized data. If the low pass is missing,
 the high frequencies are turned to noise instead. So what happens when
 a program samples data at a low frequency, will it somehow make the
 sound card tune a low pass to the correct cut-off frequency when the
 sample rate is changed? Sounds rather unlikely, and in fact the echo
 test at 8000 Hz sounds exactly like suffering from that problem: you
 can't distinguish s from f anymore, which may just be unavoidable
 with no frequency spectrum above 4000 Hz, but worse, they sound very
 loud and noisy, and for example an combined s and vowel, like they
 often appear in french (e.g. bourgeoisie I think, I'm not a native
 french speaker), sound really awful. Now there's a way to remedie
 this: low-pass filtering can also be done computationally, so we can
 digitize at say DAT quality (48000 Hz) and resample down to 8000
 samples/second programmatically, which is what the following command
 line is doing:
 
 arecord -t raw -f dat -c 1 | bfr -m 36000 | sox -t raw -r 48000 -s -2
 -c 1 -  -t raw -r 8000 - resample -ql |bfr -m 6000 | aplay -t raw -f
 dat -r 8000 -c 1 -
 
 It sounds more hollow/muffled now, but much cleaner. No loud noises
 anymore for sharp consonants.
 
 Would doing this in VoIP programs improve perceived sound quality for
 the listener? I would expect so, but haven't been able to test. (All I
 know is that more often than not I'm using Skype to call people now
 (Skype-out service), because people are telling me they hear me
 better.)
 
 Note that you can very well say you're wrong, we don't need a
 low-pass, just use a higher sampling rate then it sounds just fine,
 which is of course partially true, with higher sampling rates the
 relevance of a low-pass decreases quickly as the spectrum of
 frequencies that are higher than half the sample rate becomes narrower
 (and an increasing part of the consonant frequency range is digitized
 correctly instead of as noise). But given that at least Diamondcard
 only offers 8000 Hz, and there may be valid reasons for this (like
 maybe the phone system is still using that frequency), what's your
 position on this?
 


Isn't it waht the plughw:0,0 special ALSA device is supposed to do by
itself ?
We rely on it.

-- 
 _ Damien Sandras
(o-  
//\Ekiga Softphone : http://www.ekiga.org/
v_/_   Be IP   : http://www.beip.be/
   FOSDEM  : http://www.fosdem.org/
   SIP Phone   : sip:dsand...@ekiga.net
   
___
ekiga-list mailing list
ekiga-list@gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-list

Re: [Ekiga-list] Bad sound quality because of missing low pass filter

2010-03-02 Thread Dave Higton
On 2010-03-02, Christian Jaeger wrote:

 Hello
 
 I'm using Ekiga and Twinkle with the Diamondcard.us service as my main
 phone service. People are telling me every now and then that the sound
 quality is pretty poor, and in fact when I listen to my voice on the
 echo service it's always been quite much worse than when using a
 normal phone I think. It's regardless of the codec used, all that
 are offered by Diamondcard are using 8000 Hz sampling rate. And I'm
 using a headset and have checked sound quality locally, which is just
 fine, as I can verify for example with (the bfr command is to delay
 playback, so you can hear the echo better):
 
 arecord -t raw -f dat -r 22050 -c 1 | bfr -m 33075 | aplay -t raw -f
 dat -r 22050 -c 1 -
 
 Now 8000 Hz is of course lower, and in fact when using that rate:
 
 arecord -t raw -f dat -r 8000 -c 1 | bfr -m 12000 | aplay -t raw -f
 dat -r 8000 -c 1 -
 
 it sounds exactly as in the echo test. Now one thing I know is that if
 you sample a signal, you need a low pass before the quantization, at
 half the sample rate or lower, to remove frequencies that are too high
 to be represented in the digitalized data. If the low pass is missing,
 the high frequencies are turned to noise instead. So what happens when
 a program samples data at a low frequency, will it somehow make the
 sound card tune a low pass to the correct cut-off frequency when the
 sample rate is changed? Sounds rather unlikely, and in fact the echo
 test at 8000 Hz sounds exactly like suffering from that problem: you
 can't distinguish s from f anymore, which may just be unavoidable
 with no frequency spectrum above 4000 Hz, but worse, they sound very
 loud and noisy, and for example an combined s and vowel, like they
 often appear in french (e.g. bourgeoisie I think, I'm not a native
 french speaker), sound really awful. Now there's a way to remedie
 this: low-pass filtering can also be done computationally, so we can
 digitize at say DAT quality (48000 Hz) and resample down to 8000
 samples/second programmatically, which is what the following command
 line is doing:
 
 arecord -t raw -f dat -c 1 | bfr -m 36000 | sox -t raw -r 48000 -s -2
 -c 1 -  -t raw -r 8000 - resample -ql |bfr -m 6000 | aplay -t raw -f
 dat -r 8000 -c 1 -
 
 It sounds more hollow/muffled now, but much cleaner. No loud noises
 anymore for sharp consonants.
 
 Would doing this in VoIP programs improve perceived sound quality for
 the listener? I would expect so, but haven't been able to test. (All I
 know is that more often than not I'm using Skype to call people now
 (Skype-out service), because people are telling me they hear me
 better.)
 
 Note that you can very well say you're wrong, we don't need a
 low-pass, just use a higher sampling rate then it sounds just fine,
 which is of course partially true, with higher sampling rates the
 relevance of a low-pass decreases quickly as the spectrum of
 frequencies that are higher than half the sample rate becomes narrower
 (and an increasing part of the consonant frequency range is digitized
 correctly instead of as noise). But given that at least Diamondcard
 only offers 8000 Hz, and there may be valid reasons for this (like
 maybe the phone system is still using that frequency), what's your
 position on this?

You've discovered aliasing.  It sounds pretty bad at 8 kHz sampling
rate, doesn't it?

I suspect you have a poorly engineered sound card.  It /should/, as
you suggest, have proper low pass filtering, but apparently it
doesn't.  You can often get away with gentle anti-alias filtering
for a 48 kHz sampling rate, but not 8 kHz.

Ideally, the sound card would sample everything at 48 kHz and then
decimate by a factor of 6 using proper low-pass digital filtering.
It sounds as if yours simply sub-samples everything instead, which
aliases almost everything between 4 kHz and 48 kHz and folds it
into the up-to-4 kHz band.

Maybe a better sound card would do what you want.  (I'm sorry, I
don't have any recommendation.)

Dave


NICE CTI Systems UK Limited (NICE) is registered in England under company 
number, 3403044. The registered office of NICE is at Tollbar Way, Hedge End, 
Southampton, Hampshire SO30 2ZP.

Confidentiality: This communication and any attachments are intended for the 
above-named persons only and may be confidential and/or legally privileged. Any 
opinions expressed in this communication are not necessarily those of NICE. If 
this communication has come to you in error you must take no action based on 
it, nor must you copy or show it to anyone; please delete/destroy and inform 
the sender by e-mail immediately.

Monitoring: NICE may monitor incoming and outgoing e-mails.

Viruses: Although we have taken steps toward ensuring that this e-mail and 
attachments are free from any virus, we advise that in keeping with good 
computing practice the recipient should ensure they are actually virus free.
___
ekiga-list mailing list

Re: [Ekiga-list] Bad sound quality because of missing low pass filter

2010-03-02 Thread Christian Jaeger
Well, I wouldn't say my hardware is cheap; it's a ThinkPad T61 laptop,
worth around 1800 USD when bought new about 2.5 years ago.

Christian.
___
ekiga-list mailing list
ekiga-list@gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-list


Re: [Ekiga-list] Bad sound quality because of missing low pass filter

2010-03-02 Thread Christian Jaeger
 Isn't it waht the plughw:0,0 special ALSA device is supposed to do by
 itself ?
 We rely on it.


How would I configure Ekiga (3.2.6-1 from Debian sid) to use that one?

Or even, how do I change that device string to actually read from the right
input? Since this is silent:

arecord -D plughw:0,0 -t raw -f dat -r 8000 -c 1 | bfr -m 12000 | aplay -t
raw -f dat -r 8000 -c 1 -

regardless of whether I choose the internal mic or the headset as input
source in alsamixer.

Christian.
___
ekiga-list mailing list
ekiga-list@gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-list