Subject: Re: NetBSD plays .wav ultra fast
To: Ignatios Souvatzis <is@netbsd.org>
From: Brett Lymn <blymn@baesystems.com.au>
List: current-users
Date: 07/19/2001 21:46:19
According to Ignatios Souvatzis:
>
>If you play 8kHz samples at 48 kHz without doing serious digital (or analog)
>filtering, it will be MUCH worse than simple 8kHz. You'll hear 5 mirror images
>(in the frequency domain) plus, possibly, the 8kHz carrier.
>

Correct, but the filtering requirements for such a conversion are not
that onerous - a couple of taps on a digital filter should do it (2
multiplies, 2 adds - more modern processors even have the instructions
to do the macc in one step...3DNow, MMX and so on).  Simplistically,
you just copy the sample so you have 6 of them in a row and pass them
through the filter - voila, instant rate change.

Things get tricky when you want to go from a sample rate that is not a
nice, neat, multiple of the hardware's sample frequency.  Doing an
interpolation of 30kHz sampling to 48kHz is a touch more tricky, you
have to do a combination of interpolation and decimation to get it
right (I think interpolate by 8 then decimate by 5 is the best you can
do).

I wonder if we could just limit the driver to integer multiples of the
hardware sample frequency....

FWIW performing operations on every single byte in an audio stream is
not that onerous.  I made some patches to xamp to allow it to work on
8-bit sound cards (these patches are in pkgsrc), I did this by bit
shifting every byte in then data stream right by 8 bits.  The impact
on the machine (a lowly 486 laptop) was only a couple of percent over
what xamp normally took anyway.  Yes, the sound fidelity was not good
but it did drown out the screaming brats on the train nicely ;-)

-- 
===============================================================================
Brett Lymn, Computer Systems Administrator, BAE SYSTEMS
===============================================================================