[mythtv-users] Really bad sound quality from /dev/dsp1

Jim Carter jimc at math.ucla.edu
Tue Nov 25 23:58:10 UTC 2008


The Penguin is embarassingly losing a competition with Media Center
Edition.  I think I've figured out all the configuration issues except
for one, which is a showstopper: on NTSC channels the sound fades in
and out: at its best its quality approaches (but does not reach) that 
of the card's ALSA source, but most of the time it sounds like the
actors smoke six packs per day and are speaking their lines underwater. 
They are not chipmunked, i.e. the sound frequency is right.  
On a VOIP connection I would start looking for a codec mismatch.

Hardware configuration:
System: Dell Dimension 4600
CPU: Pentium 4 at 2.4 GHz, hyperthread
Memory: 256 Mb
Chipset: ICH5
TV Card: pcHD-5500 (Conexant CX23880/1/2/3 PCI Video and Audio Decoder)
Sound: Intel Corporation 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller
Graphics: nVidia Corporation NV18 [GeForce4 MX 440 AGP 8x] 

Software: 
OpenSuSE 10.3, kernel 2.6.22.19-0.1-default (supports hyperthread)
mythtv-{everything}-0.21-18 from Packman
lame-3.98.2-0.pm.3 from Packman
Modules are the ones included with the mainline kernel (not hacked).
Modules loaded (edited): cx88xx cx8802 cx88_alsa cx8800 
	cx88_dvb snd_mixer_oss snd_pcm_oss

Myth configuration summary:
Two capture cards are defined: DVB (the pcHD-5500's digital radio) and
V4L (the NTSC radio). For the latter, the sound source is /dev/dsp1.
The frontend sends sound to ALSA:default.  Recording profiles are mostly
unchanged from installation except the sample rate is set to 48000Hz,
video is compressed with MPEG-4 and audio with MP3 (lame).

Here's what I did to narrow down the problem area.  
1.  Authentic music played to the ALSA default sink (ICH5) sounds normal,
proving that the speakers, headphones, sound card and ALSA library are
functional.  
2.  When I play a NVU file with VLC the sound is equally bad, proving 
that the frontend has no blame here.  
3.  Uncompressed audio sounds identical, proving that lame is not lame.
4.  Now with Myth stopped I did "ttv KCET" to make it tune a station.
5.  arecord -D hw:1,0 -f dat | aplay -f dat
where dat means -f S16_LE -c 2 -r 48000.   This gives "perfect" sound.
This is what I want to be listening to, and what MCE delivers most of
the time.
6.  aplay -f U8 -c 2 -r 8000 /dev/dsp1 gives the same sound as the Myth
backend is compressing into the NVU file, which pretty well lets the
backend off the hook.  Myth is recording the sound it is given, which
is bad.
7.  aplay -f U8 -c 1 -r 16000 /dev/dsp1
Sounds a lot like -c 2 -r 8000, but there's a high-pitched crackly 
overlay, not very loud.  

I copied a sound clip from /dev/dsp1 to a file using "dd", and looked
with "od": it is definitely 8 bits per sample, and 16000 octets per
second ("dd" does timing and reports this).  It's hard to tell by
eyeball whether the sound is stereo or mono, but the Nyquist frequency
is half the sample rate, and I can't believe stereo at 4kHz, so most
likely it's mono.

Thinking that clipping might be the problem, I tried turning down the
volume, both with "alsamixer -c 1" and with "v4lctl volume 50%" [etc.]
Alsamixer's GUI showed volume changes on the capture device, and "v4lctl
list" also showed volume changes, but no effect could be heard; the
sound was equally loud and equally bad.  "v4lctl volume mute on" (or
off) did mute/unmute the sound.

At this point I'm inclined to blame ALSA OSS emulation, saying that
Myth is in a "garbage in, garbage out" mode.  I tried using aoss to run
the backend, but it still opened /dev/dsp1 (seen in /proc/$PID/fd) and 
produced bad sound.  

According to the mailing list, and forum postings elsewhere, lots of
other people can make MythTV work; some even report nearly "out of the
box" results.  Can anyone suggest anything more I can do?  My thoughts
have been along these lines:

1.  Make the backend take sound from ALSA hw:1,0, the normal sound
source for this TV card.  That would be best, as it's 16 bits per sample
at 48000Hz.  NTSC sound is nowhere near this good, but 8 bits at 8000Hz
stereo or 16000Hz mono seems kind of anemic.

2.  Get the backend to actually use the OSS API rather than just 
opening the raw device.  Then aoss could divert it to the ALSA device.
But I have no idea how to use either the OSS or ALSA API, so hacking
like this would be a long and frustrating process.

3.  Figure out how to turn down the volume in the pcHD-5500, supposing
that clipping is causing the problem (which actually I doubt because the
sound sometimes is fairly good yet is equally loud as the bad majority).

3.  Specify magic undocumented parameters to some ALSA component, to 
make the OSS emulation better.  For example if you did a rate change
from 48000Hz to 16000Hz by keeping every third sample you might get
alias effects, which an exponential filter would suppress.  I 
experimented with specifying a plug device, but couldn't make the rate
and format changes happen.

James F. Carter          Voice 310 825 2897    FAX 310 206 6673
UCLA-Mathnet;  6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: jimc at math.ucla.edu  http://www.math.ucla.edu/~jimc (q.v. for PGP key)


More information about the mythtv-users mailing list