When recording from the on-board DMICs and the microphone on my headset, I have noticed DC offset.
On my headset microphone, not so much, but on the DMICs there is a lot.
When recording silence, the signal rests at around -30dB on the positive side.
The easy way to remove DC offset is to apply a fairly steep high-pass filter with a low cutoff frequency, in post-production.
E.g. in Audacity you can go to Effects... -> Equalization... and apply the 100Hz Rumble EQ curve.
But perusing the WM5102 data sheet revealed that it has filters on-chip, so why not use them?
Here's my modified use case script for recording from the DMICs:
#!/bin/bash # Record from onboard DMICs to RPi. # Route through High Pass Filter to get rid of DC offset. # # IN2 --> LHPF --> AIF1TX # May want to tune the gain here # Need at least -6dB amixer -Dhw:0 cset name='IN2L Digital Volume' 128 amixer -Dhw:0 cset name='IN2R Digital Volume' 128 # DMICs are incorrectly labeled on the board. # DMICL is actually the right channel and vice versa, # so we'll swap them here. # i.e. IN2R --> LHPF1 # IN2L --> LHPF2 # Route DMICs (IN2) to LHPFs. amixer -Dhw:0 cset name='LHPF1 Input 1' IN2R amixer -Dhw:0 cset name='LHPF2 Input 1' IN2L amixer -Dhw:0 cset name='LHPF1 Mode' High-pass amixer -Dhw:0 cset name='LHPF2 Mode' High-pass amixer -Dhw:0 cset name='LHPF1 Coefficients' 240,3 amixer -Dhw:0 cset name='LHPF2 Coefficients' 240,3 # Connect outputs of LHPFs to inputs of AIF1 (I2s to RPi) amixer -Dhw:0 cset name='AIF1TX1 Input 1' LHPF1 amixer -Dhw:0 cset name='AIF1TX1 Input 1 Volume' 32 amixer -Dhw:0 cset name='AIF1TX2 Input 1' LHPF2 amixer -Dhw:0 cset name='AIF1TX2 Input 1 Volume' 32 amixer -Dhw:0 cset name='DMIC Switch' on
As can bee seen in the picture, the difference is obvious.
The top stereo track was recorded using the supplied Record_from_DMIC.sh use case script
and the bottom track with my modifications.
I have no idea about what the cut-off frequency of the filter is or how steep it is. The command
amixer -Dhw:0 cget name='LHPF1 Coefficients'
only reveals two values, both of which are zero:
numid=85,iface=MIXER,name='LHPF1 Coefficients' ; type=BYTES,access=rw------,values=2 : values=0x00,0x00
I'm guessing they represent frequency and steepness in some way, but the datasheet only has this to say about them:
"These coefficients are derived using tools provided in Wolfson’s WISCE evaluation board control software; please contact your local Wolfson representative for more details."
My tests show, though, that voice recordings are not affected in any negative way.
EDIT: Added coefficients to the script as suggested by Scott
--
Ragnar