Codec 2 is the open source and patent-free voice codec used in FreeDV, a digital voice mode used in amateur radio. Since Codec 2 is designed to be used at very low bitrates (the current version of FreeDV uses 1300bps and 700bps), it does an adequate job at encoding voice, but can't encode well other types of sounds, and thus fails poorly in the presence of noise. Hence, microphones which may be good enough for other applications can give poor results when used for FreeDV (if, for instance, they pick up too much ambient noise or have too much echo). This is a small note about how to test the microphone performance for Codec 2.
I find that a good test is just to make a "loopback" test, where you record your voice with the microphone, encode the voice with Codec 2, decode the encoded digital voice, and listen to the result with headphones to avoid feedback. Doing this in real-time allows one to tune different parameters, such as microphone gain and placement. This loopback can be done easily with the tools
c2dec from the Codec 2 package and
play from SoX.
An easy way to obtain the tools
c2dec is to compile Codec 2 from source. The source archive can be found in the FreeDV homepage (as of writing this post, the archive for the current version is codec2-0.5.tar.xz). To compile the code, run
mkdir build cd build cmake .. make
in the source folder. Then
c2dec may be found under
src/ in the build folder.
The loopback test can be run as
rec -t raw -r 8000 -e signed-integer -b 16 -c 1 - | \ ./c2enc 1300 - - | ./c2dec 1300 - - | \ play -t raw -r 8000 -e signed-integer -b 16 -c 1 -
build/src). As I'm using PulseAudio, I can select the input and output devices on the fly using
This loopback test runs Codec 2 at 1300bps. A nice thing is that there is some delay in the loop, which I find better to hear myself back properly. Variations of this loopback test are also interesting. One can replace 1300 by 700B to run Codec 2 at the 700bps mode used in FreeDV 700B. One can also remove
c2dec from the pipeline to listen to the analog audio. Note that the sampling rate is 8kHz, which is adequate for communications quality, but is far from being Hi-Fi. The parameter
-r 8000 can be replaced with
-r 44100 or
-r 48000 for Hi-Fi quality (but not when running the Codec 2 tools, which expect a 8kHz sampling rate and won't really benefit from a higher sampling rate).