Codec 2
Codec2 is a low-bitrate speech audio codec (speech coding) that is patent free and open source.[1] Codec2 compresses speech using sinusoidal coding, a method specialized for human speech. Bit rates of 3200 to 700 bit/s have been successfully created. Codec2 was designed to be used for amateur radio and other high compression voice applications.
Overview
The codec was developed by David Rowe (Amateur Radio Call-Sign VK5DGR), with support and cooperation of other researchers (e.g., Jean-Marc Valin from Speex).[2] Codec2 uses sinusoidal coding to model speech. In sinusoidal coding, spoken audio is recreated by modelling speech as a sum of harmonically related sine waves with independent amplitudes called Line spectral pairs, or LSP. The fundamental frequency of the speaker's voice (pitch) and the amplitude (energy) of the harmonics is encoded, and with the LSP's are exchanged across a channel in a digital format. The LSP coefficients represent the Linear Predictive Coding (LPC) model in the frequency domain, and lend themselves to a robust and efficient quantisation of the LPC parameters.[3]
Codec2 consists of 3200, 2400, 1600, 1400, 1300, 1200, and 700 bit/s codec modes. It outperforms most other low-bitrate speech codecs. For example, it uses half the bandwidth of Advanced Multi-Band Excitation to encode speech with similar quality. The speech codec uses 16-bit PCM sampled audio, and outputs packed digital bytes. Likewise, you send it packed digital bytes, and it outputs PCM sampled audio. The audio sample rate is fixed at 8 kHz. Internally, the codec algorithms operate on 10 ms PCM frames, with each of these audio segments declared voiced (vowel) or unvoiced (consonant).
The digital bytes are in a bit-field format that have been packed together into bytes. These bit-fields are also optionally gray coded before being grouped together. The gray coding may be useful if sending raw, but normally an application will just burst the bit-fields out. The bit-fields make-up the various parameters that are stored or exchanged (pitch, energy, voicing booleans, LSP's, etc).
For example, Mode 3200, has 20 ms of audio converted to 64 Bits. So 64 Bits will be output every 20 ms (50 times a second), for a minimum data rate of 3200 bits/sec. These 64 bits are sent as 8 bytes to the application, which has to unwrap the bit-fields, or send the bytes over a data channel.
Another example is Mode 1300, which is sent 40 ms of audio, and outputs 52 Bits every 40 ms (25 times a second), for a minimum rate of 1300 bits/sec. These 52 bits are sent as 7 bytes to the application or data channel.
The codec software is open source and is freely available in a subversion (SVN) repository.[4] The source code is released under LGPL Version 2.1[5] It has been tested on Linux and MS Windows.
The codec has been presented in various conferences and has received the 2012 ARRL Technical Innovation Award,[6] and the Linux Australia Conference's Best Presentation Award.[7]
Non-Coherent PSK
Rowe has also created a frequency-division multiplex (FDM) modem which carries the digital voice (DV) in only 1.3 kHz of radio bandwidth.[8] The codec and FDM modem are used every day on amateur radio shortwave bands using both the SM1000 hardware implementation, and the FreeDV application.
This modem operates at 50 Baud with a bit-rate of 1600 bps. This is sent using sixteen QPSK FDM carriers (2-bits each), or 32-bits 50 times a second. 64-bits are needed to make a vocoder frame, thus it has a 25 Hz effective rate. The 64-bits contains 52-bits of vocoder data, and 12 bits of Forward Error Correction (Golay). Thus an effective 1300 bps is used for the vocoder. A separate BPSK carrier is sent in the middle of the spectrum (1500 Hz) for synchronization.
The ITU emission designation is J2E for phone payload, and J2D for data payload.
Coherent PSK
A new FDM modem waveform was developed for the 700 bps vocoder. This modem operates with a symbol rate of 75 Baud, using Coherent Quadrature Phase-Shift Keying (QPSK) with seven sub-carriers. A duplicate set of sub-carriers are used as a diversity channel. This diversity channel is used to combat the effects of fading with shortwave propagation. The modem will still perform well with a +/- 40 Hz tuning error.
The FDM modem sends and receives a row of sub-carriers 75 times a second. However, it takes six of these rows to make-up a modem frame. First, two pilot reference-phase rows (28-bits), then two speech vocoder rows (28-bits), and finally two more rows for the second speech vocoder frame (28-bits). The process then repeats as long as the transmitter Push-To-Talk (PTT) is keyed.
Thus, a modem frame is 84-bits total. 56-bits bits are used for speech, and 28 bits are used for the reference-phase pilots. These pilots are what makes this a coherent modem. They are used to correct the received data bit phases. The data rate is 1050 bps (75 Baud x 14-bits). The effective data rate is 700 bps (75 Baud / 6 or 12.5 Baud x 56-bits). Each row of 14-bits is sent as seven QPSK carriers (2-bits each carrier).
The modem timings are also relevant, in that each speech vocoder frame outputs 28-bits every 40 ms. Since the modem has an 80 ms modem frame, it can transport two speech vocoder frames.
There are 100 complex IQ (In-Phase and Quadrature-Phase) audio samples for each row, at a 7500 Hz rate. 600 samples total for the modem frame. Thus, 100 x 6 * 12.5 equals the 7500 Hz sample rate. Using a rate conversion filter, the application is provided an 8 kHz interface, which is much more compatible with sound cards. There are 640 complex audio samples at the 8 kHz rate. This rate conversion would not be necessary in firmware.
The FDM modem operates with a center frequency of 1500 Hz. The initial FDM sub-carrier frequencies are set using a spreading function. This changes the spacing of each sub-carrier a little bit more each sub-carrier further to the left. About 105 Hz apart on the right, to about 109 Hz apart on the left. This design, along with spectrum clipping, improves the Peak to Average Power Ratio (PAPR). The measured Crest factor is about 8.3 dB with clipping, and about 10.3 dB without clipping.
The FDM modem waveform consumes a different amount of bandwidth, depending on whether the diversity channel is enabled. About 700 Hz per group of seven sub-carriers. Normally you would want to use diversity on shortwave, but optionally on VHF and above.
The ITU emission designation is J2E for phone payload, and J2D for data payload.
Adoption
Codec 2 is currently used in several radios and Software Defined Radio Systems
References
- ^ "DCC2011-Codec2-VK5DGR" (PDF).
- ^ "A Pitch-Energy Quantizer for Codec2".
- ^ "Techniques for Harmonic Sinusoidal Coding" (PDF).
- ^ "Repository for Codec2 Source".
- ^ "Codec2 - an Open Source, Low-Bandwidth Voice Codec - Slashdot".
- ^ ARRL Technical Innovation Award in 2012
- ^ "Linux Australia 2012 conference".
- ^ "FDMDV Modem".
- ^ "FreeDV".
- ^ "FreeDV, CODEC2 and the WaveformAPI".
- ^ "Introducing the SM1000 Smart Mic".