1 bit audio encoding algorithm

I am trying to make an audio playback device which uses a OTP EPROM to store audio as a specially encoded bitstream (1 bit resolution). The bit stream is played into an RC low pass filter, and the output is the original audio signal (plus noise, quantization error, etc.. but more or less the original). This makes for a very simple audio playback circuit, which would include a clock, an eprom, and an rc filter. The "problem" is generating that special 1 bit bitstream from the original audio signal. I think generating it on a computer and then programming the bitstream into the EPROM would be a good way to do it. I was thinking of modelling the response of the RC filter on the computer, and then for each bit in the bit stream, picking 0 or 1 depending on which makes the output of the RC filter closer to the original audio signal. Someone else has done this:

formatting link

Problem is, his DOS encoder software doesnt work on my computer (I tried DOSBOX to no avail).

I am experienced in C so I could write my own program, but I am not sure how to correctly model the RC filter response to a bit stream. Could someone lead me in the right direction here? I want to be able to tell the program what bit rate, and what values for R and C, and then dump a .wav file into it and have it spit out the 1 bit bitstream and the predicted output of the RC filter (to compare it to the original file).

Also, is there a way to calculate how big the EPROM needs to be in order to playback 1 second of audio with a 4096hz bandwidth? (highest frequency component of signal is about 4 khz).

Reply to
acannell
Loading thread data ...

Sigma delta converters are used in audio to deliver high fidelity to "1-bit DACs" which is pretty much where you're going. Your requirements can be much lower but there are some significant figures of merit that are important to figuring out your needs.

What's an acceptable signal to noise in your 4kHz bandwidth? CD-quality gives around 100dB while phone conversations may be more like 45dB (these numbers are rough).

If you use a simple RC filter, you need a flat frequency response for the audio outside the 4kHz passband until the filter can finally block a significant amount of noise. So, even for a very low level signal you will have high frequency background noise at roughly a constant power. How much of full scale is okay?

You might find some general help by looking up Sigma Delta converters and understanding the digital filter topologies they use. You might even find a software simulator that could give you the 1-bit results but I wouldn't hold out high hopes.

For CD quailty audio, 128x oversampling (or 1Mb/s for 4kHz) is pretty common. Your needs may be significantly lower.

You *can* get 16Mbit SPI Flash memories in 1 piece quantites for under $3. I ahve a 4Mbit part quoted for production at $0.50. Is EPROM really where you need to be?

Reply to
John_H

:> Also, is there a way to calculate how big the EPROM needs to be in :> order to playback 1 second of audio with a 4096hz bandwidth? (highest :> frequency component of signal is about 4 khz).

: Sigma delta converters are used in audio to deliver high fidelity to "1-bit : DACs" which is pretty much where you're going. Your requirements can be : much lower but there are some significant figures of merit that are : important to figuring out your needs.

: What's an acceptable signal to noise in your 4kHz bandwidth? CD-quality : gives around 100dB while phone conversations may be more like 45dB (these : numbers are rough).

: If you use a simple RC filter, you need a flat frequency response for the : audio outside the 4kHz passband until the filter can finally block a : significant amount of noise. So, even for a very low level signal you will : have high frequency background noise at roughly a constant power. How much : of full scale is okay?

: You might find some general help by looking up Sigma Delta converters and : understanding the digital filter topologies they use. You might even find : a software simulator that could give you the 1-bit results but I wouldn't : hold out high hopes.

: For CD quailty audio, 128x oversampling (or 1Mb/s for 4kHz) is pretty : common. Your needs may be significantly lower.

: You *can* get 16Mbit SPI Flash memories in 1 piece quantites for under $3. : I ahve a 4Mbit part quoted for production at $0.50. Is EPROM really where : you need to be?

I agree with the idea to use a DELTA-SIGMA modulator to encode the data to 1-bit resolution.

Your required dynamic range (SNR) will determine the parameters of the delta-sigma modulator, the most important of which are the order of the modulator and the oversampling ratio. The problem is that you aren't likely to have very good performance if you only use a single-pole RC filter to filter out the quantization noise on playback. The rule-of-thumb is that the order of the filter used to remove the quantization noise of the Delta Sigma modulator must be 1 order greater than that of the modulator itself (The noise transfer function of an nth order modulator is usually chosen to be an nth order highpass filter.) Given that the order of the modulator can't be less than 1, you'd need at least a 2-pole (2nd order) filter to effectively take out the quantization noise.

I'm not sure that you'll find a more efficient way of coding to

1-bit than using a Delta-Sigma modulator.

As far as software that simulates Delta-Sigma modulators goes, if you are a MATLAB user, there is a Delta-Sigma toolbox available from the Mathworks Website. I think you need to have a MATLAB license, in addition to the DSP toolbox and Control toolbox to use it. This toolbox is quite useful.

Hope that helps...

Joe

Reply to
<jwelser

There is a cute way to make a DAC from a single R-C.

Just shift in a serial data stream, lsb first, into an R-C having a tau of 0.6931 of the bit rate (ie, ln(2)). Each bit decays by 0.5 each clock, so if you sample the cap voltage at the end of the stream, it properly weights the bits.

You can make an N-bit dac for any N, with one RC! Just watch the tolerances.

John

Reply to
John Larkin

No problem at all. In days of yore, they just used a simple zero-crossing detector, and counted microseconds from one zero-crossing to the next. It makes a remarkably faithful reproduction, at least on the built-in PC speaker. ;-)

I think generating it on a computer and then programming

This is way too much analysis. What you get out of your sigma-delta converter, or zero-crossing duplicator, is raggedy audio that needs to be flitered. Just do an RC filter based on your bandwidth.

Good Luck! Rich

Reply to
Rich Grise

I've wanted a sample-and-hold function in a master-slave configuration of track & hold blocks the same way a register is made from two latches. Outside the old LM398A with 4us and longer settling times and high glitch energies, I haven't found anything high performance that isn't a track & hold.

What would be your component of choice for sampling that cap value?

Reply to
John_H

Reply to
acannell
[... one bit audio ...]

I did this sort of thing back in the mists of time. All you really need is a comparitor and a CD4013 and some Rs and Cs to encode audio as digital. You can improve things quite a bit if you use more than just one RC in the filter.

ASCII art:

In ----!+\\ ----- ! >-------!D Q!---+----------- digital out --!-/ clk-!> ! ! ! ! ! ! ! ----- ! ! ! +---/\\/\\----+---/\\/\\---- ! R3 ! R1 --- \\ --- / R2 ! \\ GND ! --- --- ! GND

The trick is to make the R2 just big enough that the flip-flop toggles when the signal is held at the 1/2 Vcc point. You need the same filter for the reconstruction. A voice is quite easy to understand but music sounds like hell.

In real life, R2 can be left out of the reconstruction one.

Try looking up "bochs" You need to have a real MS-DOS floppy but you can run most anything under it.

/* just to make it C code */ #define ever (1; #define and 2; #define a 3, #define day 4) #define do { #define this #define all #define done

Vc = 0; /* set the initial capacitor voltage */

for ever and a day do this delay(SomeDelay); Vin = DAC(0); Vc += (Vin - Vc) * TC_Factor; all done

Now you just need to work out the right TC_Factor as the usual

exp(-t/RC)

Look for a copy of "sox" it will convert *.wav into a column of numbers for you. From there it will be easy.

What is the amplitude of this 4096Hz? How many poles can we add to your filter? How much noise can you stand?

If the 4096 has to be rail to rail, the filter's cut off will have to be above this point.

The the size of the output sawtooth when the flip-flop is toggling is more or less what determines the quanization noise in the result.

You get about 20dB per decade per pole of filter. You know the number of decades between the amplitude of the 4096Hz and the sawtooth so you can figure out the toggle frequency. Twice that gives you the clock.

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

Why in the world would you do that? Well, never mind that for the moment. Would this pink noise only be going when audio playback is going? If so, it could be in the recording along with the reproduced audio. I wonder if this has something to do with, or is an attempt at dithering (adding noise to give a better reproduction of the signal - it may sound counterproductive, but it works). If so, this noise is being added in the wrong place, and it's already included/automatically done in a sigma-delta converter.

I'd think you'd want to keep noise at a minimum regardless.

Reply to
Ben Bradley

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.