Signal levels
Last updated
Was this helpful?
Last updated
Was this helpful?
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 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.
We have talked about DC offset removal in in the . 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:
When is close to (but less than) one, we can get a magnitude response like this:
Are you sure you are ready to see the solution? ;)
In the function we will use the key points we saw in the section on :
The above DC notch is better than the simple one-step difference, but it can be made better with respect to its fixed-point implementation.