1. Norman Gray
  2. dtmfx




This is a kit for generating and interpreting DTMF tones. It should still be regarded as beta quality, but it seems pretty robust in practice.

The set of DTMF tones is specified in ITU Q.23 http://www.itu.int/rec/T-REC-Q.23/en and described on Wikipedia http://en.wikipedia.org/wiki/DTMF.

The library includes the facility to encode JSON in the audio output, encoded as DER-encoded ASN.1.

Building it requires libmad, which is available from http://www.underbit.com/products/mad/.

Command-line utilities

To build, unpack the tarball and:

$ ./configure --with-libmad=/path/to/libmad
$ make
$ make check
$ make install

If you're building from a checkout, precede that with ./bootstrap (you must have libtool, automake and autoconf installed).


$ dtmf2hex [options] [filename]

...reads DTMF tones from an MP3 or WAV file, displaying them as bytes or JSON; it can read MP3s from stdin.

$ hex2dtmf [options] [message]

...converts a sequence of bytes, or JSON, to a WAV file.

See src/c/dtmf2hex.1 and src/c/hex2dtmf.1 for manpages.

Currently, the WAV support is implemented only for little-endian (eg Intel-based) machines.

These two utilities are interfaces to a small libdtmfx library. This isn't currently documented other than by example, in the hex2dtmf.c and dtmf2hex.c sources.


There is also a small Javascript library which produces DTMF tones using the WebAudio API. See src/javascript/dtmf.js and the usage example in that directory.


Because the library can now parse JSON and encode it in the DTMF, encoded as DER, this package includes a JSON to ASN.1/DER encoder/decoder. This uses the Jason library.

In that encoding, JSON primitives – integers, floats, booleans, and null – are encoded to their DER analogues. A JSON array is encoded to a DER SEQUENCE, an object to a SET OF two-element sequences, and strings to DER ia5string objects.

The program is copyright 2012–13, Norman Gray http://nxg.me.uk. It is distributed under the terms of the GNU General Public Licence, version 2.0.