Signal levels
Last updated
Last updated
One thing that you might have noticed from the passthrough example is that the output signal is not very loud. To correct this, we can add a gain factor to the process
function that multiplies each signal sample by a constant.
In order to take advantage of the architecture of the microcontroller's internal multiplier, it is recommended to use factors that are a power of 2 since in this case a multiplication corresponds to a simple binary shift of the integer values to the left. We measureddifference in processing time when tested with the first voice transformer algorithm.
In general, in DSP applications we assume that input signals are zero mean. This is no different in the case of our microphone, so that, if there is no sound, we expect a sequence of zeros. If you actually look at the input samples, however, you will almost certainly find out that this is not so. In fact, the internal circuitry in the microphone almost always adds a voltage offset, and sometimes different microphones (of the same manufacturer) will have different offsets. We typically call this shift in the waveform a DC offset/noise/bias.
DC offsets are highly undesirable since they limit the dynamic range of our system; in other words, we are "wasting" binary digits on a constant that serves no purpose.
TASK 1: From your passthrough implementation, determine the value of the offset. Is it significant compared to the range of the microphone?
Hint: put a breakpoint in the process function while being quiet; then with the debug tool, check the content of the input buffer.
We have talked about DC offset removal in Lecture 2.2.3 in the second DSP course. Recall that a DC component corresponds to a nonzero frequency value at so the idea is to use a filter with a zero in A very simple example is the so-called FIR "DC notch" whose CCDE is simply
Unfortunately this filter has the very poor frequency response shown here and, while good as a first approximation, it is not really recommended if audio quality is important to you.
A better filter is obtained by using a an IIR DC notch which, while marginally more expensive computationally, provides a much flatter frequency response over the audio frequency band:
Are you sure you are ready to see the solution? ;)
When is close to (but less than) one, we can get a magnitude response like this:
TASK 2: Assume that our input samples are between -1 and +1 and are encoded as signed 16-bit integers. Write a C function that implements an IIR DC notch with using integer arithmetic.
since and are usually close in value (audio signals do not swing wildly), the chance of overflow in the addition and subtraction is negligible