Analogue Input DC Offsets

19 Jul 2011

I want to try out a few simple DSP effects on audio like adding or multiplying two audio inputs and returning the result as an audio output. If the DC offset is not removed, this can't possibly work, especially with the multiplying example. Has anyone got a simple work-around for this problem?

I have already produced a phasing effect by adding audio to a slightly delayed copy of the same signal with the delay varying a little. I fixed the DC offset by subtracting 32768 from the summed signals. I don't like this because the 32768 was a guess.

Is there a better answer?

20 Jul 2011

You haven't posted the schematic but my guess is you have 2 (equal) resistors for the DC offset and a coupling capacitor to isolate the DC from your source. AnalogIn gives you 0.0-1.0 range for 0.0-3.3V input (i.e. zero offset). With the resistors you (probably) added 1.15V bias resulting in 0.5 offset. It is usually sufficient to just subtract the 0.5. The only thing you should not do is use a pure integrator because the residual offset will cause infinite growth of your signal. You can also dynamically remove the offset with a high-pass filter or by subtracting the long-term average of the signal.

20 Jul 2011

Thanks. I didn't post a schematic because the question does not really depend on the input source but you were right in your assumptions.

I have decided to subtract 32768 (or 0.5) from the sampled signal inputs and store that in a buffer of signed integers (or floats). Then the input streams can be added or multiplied. Immediately before outputting I'll add 32768 (or 0.5) to restore the DC level. If this works, I should be able to share a couple of cool audio processing effects.

I'll think about the other techniques which also sound really useful.

20 Jul 2011

My solution for Audio Phasing with schematic and code is here ...

http://www.softwareforeducation.com/wikileki/index.php?title=Audio_phasing

Thanks for the help.

22 Jul 2011

Is the code running as fast as possible? You don't seem to be sampling at a specific rate. This makes it really hard to actually do any sort of meaningful signal processing..

22 Jul 2011

This was my second program after "Hello Word" so I have gone for the simplest possible approach, also with teaching other beginners in mind. The code is running at the fastest possible rate as I have added no time delays. I agree that this is not ideal but the mbed does not seem to spend much time wandering off and processing other stuff so the timing seems good enough. The evidence is that it really works. If there were timing problems, the phasing frequencies would shift up and down and this was not noticeable.

I wonder if the ADC and DAC always take the same time to complete a conversion.

The only other mbed audio processing code I have found was an echo effect. That code was similar to mine.

I'd be delighted if a more experienced mbed user could post a better solution here. Reading other posts, it looks as though there are several hardware level tricks that could be used.