ECE-1021

HOMEWORK #B

(Last Mod: 27 November 2010 21:38:40 )

ECE-1021 Home


DTMF WAV File Writer

Write a program that prompts the User for the following information:

From this, generate a WAV file that consists of the touch-tone signals for the entered phone number.

Your program should interpret the characters in the phone number string as follows:

Be aware, originally only 24 of the 26 alphabetic characters where mapped to phone digits and many older phones only show those 24 letters. However, there is a standard mapping involving all 26 letters. If the phone you are looking at doesn't have all 26, look at a different phone. Also note that your character mapping should be case independent meaning that 'r' and 'R' should both produce the same result.

The DTMF standard actually includes a total of 16 tones. The remaining four tones correspond to the digits A through D (hex) that reside in a fourth column to the right of the standard phone pad. You may ignore this for what you are doing.

The Dialing Speed is simply how many digits the WAV file will play per second. If the User enters 5, then the WAV file should start a new digit every 1/5th of a second.

The Dwell Time is what fraction of the time allocated for playing one digit is actually used to produce the tones at full amplitude. For example, if the User has entered a Dialing Speed of 5 then the time allocated for each digit is 200 milliseconds. If a Dwell Time of 50% has been entered, then the tone associated with that digit should play at full amplitude for 100 ms (50% of 200 ms) and should be centered within the 200 ms time window.

The Transition Time is what total fraction a given digit's time should be used to ramp the tone amplitude from zero (silence) to full amplitude and back. The ramp-up at the beginning of the tone and the ramp-down at the end of the tone should be symmetrical. For instance, in the Dwell Time example above, if the User were to specify a Transition Time of 20%, then 10% of the total time would be used to ramp-up the tone and 10% would be used to ramp-down the tone. Any remaining time allocated for that digit should be silent. The end result for the 200 ms associated with any given tone in this example is that the first 15% of the period (30 ms) would be silent, the next 10% (20 ms) would be used to ramp the amplitude of the tone signal from zero to full amplitude, the next 50% (100 ms) would be taken up by the full amplitude signal, the next 10% (20 ms) would be a ramp-down of the amplitude back to silence, and the remaining 15% (30ms) would be silent.

The sampling rate is how many tone samples there are per second. Typical telephone switching networks limit the signal content to the range of 300 Hz to 3300 Hz and use a sampling rate of 8kHz. 

The Number of Channels determines whether both tones used to produce a digit's signal are combined mathematically before being output to the file as a mono (one channel) signal or if the two tones are kept separate and put out to two different channels (stereo). If the stereo option is chosen, the left channel should contain the low frequency tone and the right channel should contain the high frequency tone.


The following traces are the low and high frequency DTMF tones associated with digit 5.

When these are added together (by averaging so that the peak signal is still bounded by ±1) the following composite signal is produced:

The two separate tones may be sent to different channels (left and right) in a stereo WAV file or the single composite waveform may be sent to a single channel in a monaural WAV file.

If sent as is, namely that the tones start abruptly and end abruptly, there will be annoying high frequency clicks when it is played back. To suppress these, the tones are smoothly ramped up from zero amplitude to full amplitude and, after playing at full volume for the appropriate length of time, are ramped back down to zero. This can be easily accomplished using an envelope function which is used to scale the base waveform via multiplication.

An envelope function having a 30% Dwell Time and a 50% Transition Time is shown below:

The resulting final waveforms (blue) when the signals are multiplied by the envelope function are:

Stereo WAV File - Left Channel

Stereo WAV File - Right Channel

Monaural WAV File