Audio sampling and compression
human
Posts: 14
I've been playing with the 'Microphone to Headphones' object recently. (http://obex.parallax.com/object/79)
I'm trying to take 8000 samples per second, compress and decompress them again using A-law, and play back the audio.
The A-lawed audio sounds pretty noisy. I'm pretty sure that my A-law implementation is working as intended. To double-check, I've piped the raw audio samples to my laptop in order to compress and decompress them using 'sox'. The result of this sounds noisy, too.
As my understanding of electronics is very limited, I'm wondering what exactly the 'Microphone to Headphones' object does.
Does it return straight PCM samples? Are they suited to being used as input to A-law without further processing?
Thank you!
I'm trying to take 8000 samples per second, compress and decompress them again using A-law, and play back the audio.
The A-lawed audio sounds pretty noisy. I'm pretty sure that my A-law implementation is working as intended. To double-check, I've piped the raw audio samples to my laptop in order to compress and decompress them using 'sox'. The result of this sounds noisy, too.
As my understanding of electronics is very limited, I'm wondering what exactly the 'Microphone to Headphones' object does.
Does it return straight PCM samples? Are they suited to being used as input to A-law without further processing?
Thank you!
Comments
If you want to use just the Propeller, don't use adjacent I/O pins for the ADC function (you'll have to modify the program to match).
The was a thread long ago on an open-source guitar special effects box using the Propeller. Some of these issues came up there and were addressed in the design.
The "Microphone to Headphones" object / demo repeatedly digitizes the signal from the board's microphone ... at a fixed rate ... and leaves the digital value where another cog can convert that back to analog using PWM (and an analog filter).
I'm using the Propeller Demo Board, so the pins are identical to those used in the microphone to headphones object (8,9).
So if I understood correctly, you're saying it's normal behavior that on the Demo Board, the microphone to headphone object (that just plays back the audio signal it just digitized) sounds fine, while compressing and decompressing the audio signal in between recording and playing back necessarily leads to significant noise?
The code I'm writing is a proof-of-concept, so a little noise is probably acceptable. I just want to make sure it's caused by the hardware so it's not the software's fault.
http://www.thatcorp.com/2181-series_Trimmable_Blackmer_IC_Voltage-Controlled_Amplifiers.shtml
There's a little noise inherent in the successive approximation ADC technique used and in the use of filtered PWM for the DAC technique. If this is a problem after dealing with the above crosstalk, you can always use an external ADC. For the DAC, you can switch to a resistor ladder like what's used for video and VGA or an external DAC.
-Phil
(indeed noise contains a lot of information and compression seeks to throw away information,
throwing away noise is a great way to reduce information content.
Anyway back to the A-law thing - are you converting sample-by-sample without carrying
an error term forwards? It usually better to carry the error forward from sample to sample, as
this leads to more accuracy at low-frequencies.
It may be worth taking your digitized samples and putting them right back out again to see what it sounds like so that you have an idea of the noise level in the raw sample stream. DAC chips can be pricey, but it is easy enough to construct a 12 bit R2R DAC with a good handful of resistors and an op amp. Currently I have a LTC8043 on the breadboard, but I actually liked the results I got a while back with the DIY R2R.
You mentioned your sample rate, but did not say if you had any type of filters on your input. Given the rate of 8ksps, you should have the input filtered to limit at 4khz otherwise if there are any signals of a higher frequency than that, they will be aliased down to below 4khz and will present as additional noise. Also...............
If you are pretty new to this and have limited electronics background, a good book to read on this and more would be "Real Time Programming - Neglected Topics" by Caxton C Foster, copyright 1981. This book offers a good 40k foot overview of sampling and other topics with a few looks below the clouds, and serves as a great guide to where you want to go next in these areas.