IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

2020/giles - Most phony

Author:

To build:

    make

Bugs and (Mis)features:

The current status of this entry is:

STATUS: INABIAF - please DO NOT fix

For more detailed information see 2020/giles in bugs.html.

To use:

    ./prog < dtmf.wav

    ./prog [digits] > digits.wav

where dtmf.wav is a WAV file of the dialling of a number being dialled with DTMF (Dual-tone multi frequency) (more commonly known as Touch-Tone) and [digits] is a sequence of digits that will be converted to the DTMF sound!

Try:

    ./try.sh
    ./prog < pi.wav

    # See
    ./prog 867-5309 > jenny.wav

If the script try.sh did not play a WAV file, it means you do not have SoX installed; see the FAQ on “using entries that require sound”. In this case install it and try it again or play the files jenny.wav and ioccc28.wav in a program that can play WAV files.

NOTE: the phone number of jenny.wav comes from https://en.wikipedia.org/wiki/867-5309/Jenny.

Judges’ remarks:

A cross platform utility for both encoding and decoding touch tones.

Author’s remarks:

Introduction and Usage

This program encodes and decodes dual-tone multiple frequency signals used in telephone systems, more commonly known as Touch-Tones.

If the program is executed with no arguments, it will read a WAV file from standard input, decode the touch-tones in the file, and output the corresponding digits to standard output. This program only supports WAV files that have exactly 16 bits per sample, but it allows any sample rate and any number of audio channels.

    $ ./prog < pi.wav
    31415926

If the program is executed with a command-line argument, it will generate the tones corresponding to the specified characters, writing them to standard output as a WAV file.

    $ ./prog 867-5309 | aplay

Interesting Features

Assumptions

Obfuscations

Algorithm Details

Each tone in a DTMF signal is a combination of two frequencies. The lower frequency determines which row the digit is in, and the higher frequency determines the column. There are 4 possible row frequencies and 4 possible column frequencies.

    |            | **1209 Hz** | **1336 Hz** | **1477 Hz** | **1633 Hz** |
    |------------|-------------|-------------|-------------|-------------|
    | **697 Hz** | 1           | 2 abc       | 3 def       | A           |
    | **770 Hz** | 4 ghi       | 5 jkl       | 6 mno       | B           |
    | **852 Hz** | 7 pqrs      | 8 tuv       | 9 wxyz      | C           |
    | **941 Hz** | *           | 0           | #           | D           |

This program determines which frequencies are present in the input by passing it through a set of 8 virtual resonators, each tuned to one of the frequencies used for DTMF. These can be implemented using only basic arithmetic, and they are able to ‘select’ a specific frequency from the input sound, blocking all other frequencies from reaching the output. The loudness of the sound output from each resonator can therefore be used as a measure of how much of a particular frequency was present in the input. The program then decides, over the course of one tone, which row frequency and which column frequency were most prominent.

Tones are generated using those same resonators by providing an impulse as input. An impulse can be thought of as consisting of sine-waves at all frequencies, and when it is put through one of the resonators, the result is a single pure sine wave.

Inventory for 2020/giles

Primary files

Secondary files


Jump to: top