Speakfreely Speex Codec

Speakfreely is an internet telephone program, written by John Walker in the early 1990s. Since 2004 it is being maintained collaboratively at sourceforge.net. It offers some features that can't be found elsewhere, particularly with interoperability between Linux, MS Windows, and various Unix variants. Here I extend it's capability through providing a patch to incorporate the Speex codec.

Patch Details

Speex Codec

The Speex project is aimed at providing an open-source low-bitrate speech codec to complement the vorbis music encoder. It offers good voice reproduction down to 8kbps, and even lower with it's variable bit-rate options. In addition, it has a number of attractive qualities for telephony applications:

Patch Scope

These patches are still in development, and this is aimed at developers or anyone who wants to find bugs in what I've done. The main additions are:

Packet Format

It is primarily intended that the speex be transmitted over RTP, rather than the speakfreely protocol. In particular, this provides the necessary sequence numbers and timestamps. However, it should also work using the speakfreely native protocol.

I'm not using the proposed Speex RTP standard. This is because I want to use packets larger than 20ms, and also incorporate redundancy without additional packet header overhead. I don't see the compatibility issue to be a great loss, because I don't know of any other Speex over RTP application that doesn't use SIP or H323 session management.

The RTP payload consists of eight packed 20ms speex frames to span a time of 160ms. The first four frames are encoded from a 2150bps fixed-rate encoder. The second four are encoded from a separate variable bit-rate encoder, which is generally running at a higher bit-rate. These packets are sent at 80ms intervals, and under normal operation the first four (low-bit-rate) frames of each packet are discarded. However, when a packet is lost, and the following packet is available, the four redundant frames are used to bridge across the lost packet.

Now that I know how to do it, I may swap the order of the main and the redundant bits before a final release. That would allow for good compatibility between redundant and non-redundant implementations.

The adaptive jitter delay requires the presence of timestamps in the incoming packets. RTP provides this, but standard speakfreely does not implement them correctly. This patch from 20040314 provides proper timestamps, so you need at least that version at BOTH ends for adaptive jitter to work. Using the speakfreely protocol, timestamps are faked from the sequence number. This works adequately for discontinuous transmission having gaps of less than 10 seconds, and using the speex codec. To do better than that will require changes to that protocol.

Download

Unix Version

This is a patch against unix version 7.6. It also includes code for logging raw compressed to a socket. A separate C++ program listens on that socket to interleave the speaker and mike spurts. Currently it is mainly good for GSM, but I will release an OGG/Speex output version shortly.

Speex 1.1.1 or later is now used. Because it is incompatible with earlier versions, it is now statically linked. To build, unpack the speex source into a subdirectory called speex, and perform a ./configure and make in the speex directory. Then make speakfreely. Alternatively, just adjust the path to the libspeex.a file in the makefile to suit your system.

Windows Version

The windows version has been tested under the Cygwin gcc compiler in native mode, and a cross-compile using mingw32 as packaged under Debian Linux. There is a makefile and also a minimal float.h in the patch to allow it to compile.

Cygwin Build

The Makefile is designed for the speex source tarball to be unpacked in the speakfreely source directory, under a subdirectory called speex (without versioning in the name)

Once you have the original source zip and the patch in the same directory, the patch would be applied as follows:

Alternatively, you can just unzip the .update.zip file over the top of the original files in order to update the modified files.

Under Cygwin, you would need the following packages installed: gcc, mingw(I think), gzip, zip, patch, make

The pre-built version here was built with gcc, and if run from the Windows GUI, you'll find it will open up an additional console window for stdout to be displayed. That build includes status info, which shows a period (.) for each incoming packet, and some codes for special cases:

Old Versions

Versions prior to 2003-10-25 use an obsolete format.

Notes

Updates

Todo