Functions > Reading and Writing Files > Example: Signal Generation
  
Example: Signal Generation
Signal Synthesis
Consider a dual-tone multi-frequency (DTMF) signal. These signals are commonly used for touch tone telephone dialing and remote control functions. DTMF signals are composed of one high frequency and one low frequency sinusoidal signal. A table of common tones is shown below.
Digital Phone Keypad
High Tone Group
1209 Hz
1336 Hz
1477 Hz
1633 Hz
Low
697 Hz
1
2
3
A
Tone
770 Hz
4
5
6
B
852 Hz
7
8
9
C
Group
941 Hz
*
0
#
D
For example, to generate the tone for the number 5 button, mix the 770 Hz signal from the Low Tone Group with the 1336 Hz signal from the High Tone Group.
In this example, use PTC Mathcad to generate the # tone.
1. Define the number of channels, sample rate and resolution.
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Set the time duration and the number of data points.
Click to copy this expression
Click to copy this expression
3. Calculate the time interval and generate two arrays, one for indexing and one for time.
Click to copy this expression
Click to copy this expression
Click to copy this expression
4. Set the amplitude of the signal and choose the two frequencies required to generate the # tone.
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. Use the sin function to generate the signal, and plot it.
Click to copy this expression
Click to copy this expression
6. Use the WRITEWAV function to write the signal to a WAV file using the specified parameters.
Click to copy this expression
If the specified bit resolution is 1-8, the data is written to the file as unsigned byte data. The limits of unsigned byte data are 0-256 (28). If the bit resolution is 9-16, word data (two bytes) is written to the file. The limits on word data are –32768 - +32767 (215).
7. Try changing the frequencies for the DTMF signal and then play the sound file. The sound is similar to a touch-tone telephone.
Exponential Ramp in Frequency
Another useful signal in audio testing is the exponential ramp in frequency.
1. Define an exponential ramp in frequency signal.
Click to copy this expression
2. Define the sample rate, the resolution, and the number of channels.
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Define the following parameters for the new signal.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
4. Use the sin function to generate the signal, then use the length function to find its length
Click to copy this expression
Click to copy this expression
5. Use WRITEWAV to write the signal to a new file.
Click to copy this expression
6. Plot the signal.
Click to copy this expression