I’ve been prototyping microphone amplifiers for SmartMic. Although I’m not much on an analog guy I’m getting somewhere. Note the tiny SOT-23 op-amp soldered to a header!
We want to be able to handle electret and dynamic microphones, and have 0 to 40dB gain (trimmer adjustable). Here are the transistor and op-amp versions:
Note the DC coupling to the STM32F4 ADC, we want this to be about half scale on the ADC. I’m using the internal 12 bit ADC and DAC to handle the audio signals rather than an external PCM Codec. This seems to be working out pretty well so far. I sample at 16 kHz and don’t worry about anti-alias or reconstruction filtering – I figure the rig’s xtal filter and audio filtering will handle that. Seems to work.
With the transistor version I am concerned about repeatability across manufacture runs and temperature. For example the emitter resistor is AC bypassed so the spread of Beta’s will mean varying gain, or the DC offset might vary. The low Ve bothers me too. However by tweaking the various C values we could tailor the freq response which might be useful. On balance I think we might run with the op-amp version.
To test the amplifiers I speak into the microphone and sample a phrase using the ADC on my STM32F4 Discovery board running a unit test program that uploads the sample to my laptop via USB. This software converts the 12 bit unsigned samples to signed 16 bit samples. I can then plot the signal using Octave and check the DC offset and peak-peak levels:
Then I apply some sox and Codec 2 command line magic:
david@bear:~/tmp/codec2-dev/src$ sox -r 16000 -s -2 ~/stlink/stm_out.raw -r 8000 -t raw - lowpass 3300 highpass 100 | ./c2enc 1300 - - | ./c2dec 1300 - - | sox -t raw -r 8000 -s -2 - smartmic_micamp_1300.wav
Likewise with the logitech USB headset I used as a comparison, which was set as the default input sound device:
david@bear:~/tmp/codec2-dev/src$ rec -t raw -r 8000 -s -2 -c 1 logitech.raw
david@bear:~/tmp/codec2-dev/src$ ./c2enc 1300 logitech.raw - | ./c2dec 1300 - - | sox -t raw -r 8000 -s -2 - logitech_1300.wav vol 2
…..which lets me listen to the mic signals after encoding/decoding with Codec 2. It’s amazing what Unix style “stdin/stdout” tools strung together can do. Very quick prototyping.
I generally use my little laptop speaker to listen as (i) it makes Codec 2 sound better which strokes my ego and (2) it’s close to the sort of speaker Codec 2 will be used for in the real world. Here are some samples:
|Opamp, Yaseu MH31 dynamic|
|$15 Logitech USB headset|
The levels aren’t all exactly the same. To my ears the dynamic mic seems to have less low frequency response, not sure if that is good or bad. HF radio mics are generally tailored to maximise speech energy at those frequencies most important for intelligibility. This causes SSB modulation to allocate more transmit power to these regions of the speech spectrum, enhancing the received signal in the noisy, fading HF channel. Digital Voice doesn’t have the same relationship between the source audio spectrum and transmitted power, so the frequency response is less important from a transmitted “punch” point of view. This may mean traditional HF radio microphones and audio filtering is not needed and may even be harmful in a digital voice world.
We have found however, that the microphone and/or frequency response of the source audio can dramatically affect the Codec 2 speech quality. We are trying to gather more information on that and work out why.