Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Playing 8-bit raw Audio with mplayer

907 views
Skip to first unread message

Martin McCormick

unread,
Aug 14, 2009, 11:20:09 AM8/14/09
to
If one produces a raw PCM dump of /dev/dsp such as
$ cat /dev/dsp >streamfile

The result is an unsigned 8-bit 8-KHZ audio dump captured in
streamfile. If I cat streamfile >/dev/dsp, it plays so I know
that works. Has anybody successfully played such an unsigned
stream in mplayer? It would be nice to do that in order to use
the arrow keys which let you skip forward or backward at will.

A read of the man page says that u8 is one of the
accepted formats so it looks like
mplayer -quiet -format u8 streamfile
should work but no luck.

On the system in question, there is nothing broken as
far as I can tell. mplayer works beautifully on Realaudio, WMA
and gobs of other formats so I am either doing something wrong
or it can't play a /dev/dsp dump.

Thanks for suggestions.

Martin McCormick WB5AGZ Stillwater, OK
Systems Engineer
OSU Information Technology Department Telecommunications Services Group


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Tzafrir Cohen

unread,
Aug 17, 2009, 5:50:14 AM8/17/09
to
On Fri, Aug 14, 2009 at 10:09:19AM -0500, Martin McCormick wrote:
> If one produces a raw PCM dump of /dev/dsp such as
> $ cat /dev/dsp >streamfile
>
> The result is an unsigned 8-bit 8-KHZ audio dump captured in
> streamfile. If I cat streamfile >/dev/dsp, it plays so I know
> that works. Has anybody successfully played such an unsigned
> stream in mplayer? It would be nice to do that in order to use
> the arrow keys which let you skip forward or backward at will.
>
> A read of the man page says that u8 is one of the
> accepted formats so it looks like
> mplayer -quiet -format u8 streamfile
> should work but no luck.

In the worst case, convert it to a wav file:

sox -r8000 -u -c1 -8 streamfile file.wav

--
Tzafrir Cohen | tza...@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tza...@cohens.org.il | | best
ICQ# 16849754 | | friend

Martin McCormick

unread,
Aug 22, 2009, 6:00:13 PM8/22/09
to
Tzafrir Cohen writes:
> In the worst case, convert it to a wav file:
>
> sox -r8000 -u -c1 -8 streamfile file.wav

That definitely does work. Thanks.

It turned out I was reading the wrong part of the man
page so searches for what one might think works turned up
nothing. It turns out that the following will directly play the
file:

mplayer -quiet -rawaudio samplesize=1:channels=1:rate=8000 -demuxer rawaudio \
/tmp/rawaudio.tmp

I did discover an interesting little bug that is either
a misunderstanding on my part or an off-by-one situation.

If you listen to the dump with headphones or a good pair
of speakers, you can hear a rhythmic throbbing effect with a
rate of about 1 throb per second. It reminds me of the effect
you get when the tape guides on a tape machine are allowing the
tape to scue a little so the movement over the head is not
perfectly horizontal. You almost don't notice it but it is there
at times and somewhat annoying.

It made me wonder if the codec was feeding audio that
was being sampled a little faster than it should be.

I changed the sample rate to 8001 and the throb effect
doubled in speed, telling me that this was the problem but I had
gone in the wrong direction.

At 7999, the throb is totally gone and the effect is the
same as what you get if you cat a raw audio file directly to
/dev/dsp.

For all I know, it might not even show up on another
computer with a different sound card and possibly a different
time base.

I tried it on a computer I use at work that has a SBLive
sound card and I think I did still hear the slight throb effect.

I have since subscribed to the mplayer list and will
post this same description to see if somebody else can shed some
light/sound knowledge as to why the slight timing problem.

Martin McCormick WB5AGZ Stillwater, OK
Systems Engineer
OSU Information Technology Department Telecommunications Services Group

Emanoil Kotsev

unread,
Aug 22, 2009, 9:30:09 PM8/22/09
to
Martin McCormick wrote:

> mplayer -quiet -rawaudio samplesize=1:channels=1:rate=8000 -demuxer
> rawaudio \ /tmp/

This was interesting experiment, but I don't hear such a thing.

what do you see in ratio (see below) from mplayer

for me it's ratio: 8000->8000

uname -a
Linux maistor 2.6.30.4eko2 #1 SMP PREEMPT Wed Aug 12 00:57:41 CEST 2009 i686
GNU/Linux

cat /proc/asound/card*/codec* | grep Codec
Codec: SigmaTel STAC9200

player -quiet -rawaudio samplesize=1:channels=1:rate=8000 -demuxer

rawaudio /tmp/testfile
MPlayer dev-SVN-r28048-4.3.2 (C) 2000-2008 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz (Family: 6, Model: 15,
Stepping: 6)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2
/usr/share/fonts/truetype/ttf-sil-gentium/GenAI102.ttf doesn't look like a
bitmap font description, ignoring.
Cannot load bitmap
font: /usr/share/fonts/truetype/ttf-sil-gentium/GenAI102.ttf
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote
control.

Playing /tmp/testfile.
rawaudio file format detected.
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 8000 Hz, 1 ch, u8, 64.0 kbit/100.00% (ratio: 8000->8000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [oss] 8000Hz 1ch u8 (1 bytes per sample)
Video: no video
Starting playback...


Exiting... (End of file)
emanoil@maistor:/tmp$ mplayer -quiet -rawaudio
samplesize=1:channels=1:rate=8000 -demuxer rawaudio /tmp/testfile
MPlayer dev-SVN-r28048-4.3.2 (C) 2000-2008 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz (Family: 6, Model: 15,
Stepping: 6)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2
...
Playing /tmp/testfile.
rawaudio file format detected.
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 8000 Hz, 1 ch, u8, 64.0 kbit/100.00% (ratio: 8000->8000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [oss] 8000Hz 1ch u8 (1 bytes per sample)
Video: no video
Starting playback...


Exiting... (End of file)

0 new messages