PAG - Programmable Audio Generator
What is it?
Why would you use it?
How do you use it?
Below is an actual file, let's take a look at it:
#format WAVE 44100 16 1 dtmf.wav 1 0.2 697 50 50 1209 50 50 2 0.2 697 50 50 1336 50 50 3 0.2 697 50 50 1477 50 50 4 0.2 770 50 50 1209 50 50 5 0.2 770 50 50 1336 50 50 6 0.2 770 50 50 1477 50 50 7 0.2 852 50 50 1209 50 50 8 0.2 852 50 50 1336 50 50 9 0.2 852 50 50 1477 50 50 * 0.2 941 50 50 1209 50 50 0 0.2 941 50 50 1336 50 50 # 0.2 941 50 50 1477 50 50 A 0.2 697 50 50 1633 50 50 B 0.2 770 50 50 1633 50 50 C 0.2 852 50 50 1633 50 50 D 0.2 941 50 50 1633 50 50 s 0.2 1 1 1 1 1 1 #macros h 8675309 #start 0s1s2s3s4s5s6s7s8s9s0sAsBsCsDs*s#s hThe first line defines the format of the file to produce:
#format WAVE 44100 16 1 dtmf.wavThe format of the this line is:
#format fileType sampling bits channels fileNamefileType can be one of: WAVE, AIFF, AU
sampling is the sampling rate in Hz, such as 44100, 11025, 8000, etc
bits is the sample size, only 8 and 16 are allowed
channels is 1 or 2, for mono or stereo
fileName is, as expected, the name of the file to produce
Next come the definitions for the tones. Each tone is assigned to a character, whenever that character appears in the fourth section of the file (tones to send) it is produced. A tone can actually be defined to produce more than one frequency at a time, which is necessary in cases like DTMF where two tones must be played at the same time for each button on the phone. For example, the definition for the 1 button:
1 0.2 697 50 50 1209 50 50The definition of this line is:
character length freq1 ampL1 ampL2 ... freqN ampLN ampRNThe first letter in the line is the character assigned to that tone. Any printable or non printable character may be used, except for the tilde ~ which is actually mapped to the space character, since it is more likely you will want to define the space than the tilde. That is, you use the tilde here to define the tones to send when the space character is encountered. Hopefully that isn't too confusing.
The second value is the length (in seconds) that tone should be played for.
Next, we take values in blocks of three, such as 697 50 50 in that line. The 697 means to play 697 Hz, the 50 50 means to set the amplitude to 50% for both the left and right channels. The next set of three values is 1209 50 50 which means we want to play a second tone at the same time, of 1209 Hz, also 50% amplitude in each channel. You can have different amplitudes for each tone and channel of course, but for a given channel, the sum of all the amplitudes for all the frequencies should not exceed 100%, or distortion will result.
You can define up to ten frequencies for each character. You must specify all three values for each, including both amplitudes, even if the sound file is monophonic.
After all of the tones are defined, you define the macros, preceeded by the line:
#macrosYou must include this line, even if no macros follow. Macros are easy to define, in our example, we have one macro definition:
h 8675309This means that whenever the character h is encountered, to substitute the characters 8675309 instead. Don't define a macro using a letter already assigned to a tone.
After the macros have been defined, there should be the following line:
#startAnd following this, the text to be converted into tones. In our example:
0s1s2s3s4s5s6s7s8s9s0sAsBsCsDs*s#s hIn this case we are sending each tone tone button's tone pairs, with a space between them, as s was defined to be a 1 Hz tone of amplitude 1%, making it inaudible. Then we have the letter h, which is a macro, which means that the tones for buttons 8675309 are sent.
We do have returns in our data portion, but as we have not defined them to map to any tones, they cause no additional output.
That's really about it.
There is a text editor in the program, or you can use your own, like BBEdit. TextEdit that comes with Mac OS X doesn't always save in a plain text format. Windows users can use any editor, like Notepad, if they'd prefer.
After you have your text file opened in PAG, select Process File from the File menu. It may take a few seconds (or more!) depending on the length of the sound file being produced. After it is done, it displays a second window with some debugging results (which are also contained in three text files it produces). You can send this to me (along with the input file!) if you're having difficulties, it may help determine the problem.
PAG is only $19.99!
Before buying, you should download a copy and make sure it works on your particular configuration.
Last modified December 4, 2005