DTMF_FFT version 1.10 a DTMF & CTCSS generator and decoder & a spectrum analyzer program for DOS Copyright (C) 1996 Philip VanBaren & (C) 1997 Emil Laurentiu (YO3GGH) PROGRAM FILES: DTMF_FFT.EXE is a program for the Soundblaster compatible cards. The program samples the input, performs an FFT, and graphs the output. It also decodes and generates DTMF numbers and the sub-audible CTCSS tones. INI file and command line options provide the user with the ability to select linear/log frequency and amplitude scales as well as sampling rates, length of the FFT, DTMF generating speed, threshold DTMF and CTCSS level etc. Graphics is done using the VGA 640x480x16 video mode, so a VGA compatible card is required. The program will only run on computers with an 80386 or above processor. A coprocessor is recommended, but not required. DTMF_FFT.EXE also works with 8 bit Soundblaster and compatible cards. It looks for the environment variable "BLASTER=A220 I5 D1" to set the Soundblaster address, IRQ, and DMA. If this variable is not available, the default values (220,5,1) are used. COMMAND LINE OPTIONS: -Cnumber selects the sound card (0=SB8, 1=SB16) -Snumber sets the sampling rate. -Fnumber sets the length of the FFT. -Mnumber sets the scale maximum. -L sets a logarithmic scale for the frequency axis. -H or -? displays this message. INI File options: These options override the program defaults, but are overridden by the options specified on the command line. The red,green,blue values for the colors must be values between 0 and 63. Sound card: 0 ( same as -Cnumber ) 0: Soundblaster 8 bit cards, and compatibles (also valid: SB8) 1: Soundblaster 16 bit cards (also valid: SB16) Sample rate: 20000 ( same as -Snumber ) Valid sampling rates are 5000 Hz to 88200 Hz for Soundblaster cards. However for the old 8-bit Soundblaster cards the sampling rate cannot exceed 12000 Hz. Any value greater than this will result in a mislabelled frequency axis. For newer Soundblaster cards, sampling rates up to (and possibly beyond) 44100 Hz are possible. FFT length: 1024 ( same as -Fnumber ) Valid FFT lengths are from 8 to 2048. Longer FFTs will result in slower display updates (maximum update rate will be SampleRate/FFTlength). Computers slower than 486DX-33MHz will not be able to reach the maximum rate because they cannot perform the calculations in the available time. Log freq scale: 0 ( 1 = -L ) 0 selects a linear frequency scale (equal distances result in equal frequency differences) 1 selects a logarithmic frequency scale (equal distances result in equal frequency ratios) Max amp: 0.1 ( same as -Mnumber ) Sets the top value for the linear amplitude scale Base frequency: 0 This specifies the minimum frequency displayed on the plot. This can be used to zoom in on a particular section of the spectrum. Frequency factor: 1.0 This specifies the zoom-factor for the frequency axis. DTMF & CTCSS threshold level: 0.05 This specifies the threshold level used to discriminate the amplitude for the frequency spectral components. This level appears as an horizontal line in DTMF & CTCSS decoding modes. DTMF delay (40 - 250 ms): 80 This parameter specifies the length of each DTMF number. A standard value used by the telephone companies is 90 ms but you can modify this as you like. CTCSS active: 0xABFFFFFD, 0x0001DD2A Each bit in these two long integers enables/disables the CTCSS frequencies to be scanned. The default values are for those tones that are found on most radio transmitters Background color: 0,0,20 ( sets the background red,green,blue value ) Clipping warning color: 20,0,0 Sets the background color set when clipping occurs. WHY DOES THE SCREEN FLASH ALL OF THE TIME? That is because this color is different from the background color. The program changes the background color to this color whenever clipping of the signal is detected (the sampled signal hits the allowable signal limits.) This clipping will result in a distortion of the frequency plot (look at the spectrum of a pure whistle when clipping occurs.) The best solution to this problem is to lower the input level so that clipping does not occur. If this is not possible, you can set this color to the same value as the background color, and the screen will not longer flash. Graph color: 30,35,60 ( sets the color for the FFT graph ) Axis label color: 50,20,45 ( sets the color frequency and amplitude labels ) Border color: 40,40,40 ( sets the color for the border and tick marks ) Text color: 55,55,25 ( sets the color for text (other than labels) ) Cursor upper color: 20,20,20 ( sets the color for the upper half of the cursor ) Cursor lower color: 63,63,63 ( sets the color for the lower half of the cursor ) RUNTIME OPTIONS: While the program is running, the following commands may be used: ? : Prints a short list of commands available. E,Q : Exit from the program. F : Change the FFT length. R : Change the sampling rate. S : Save the current state to an INI file. The default INI file is DTMF_FFT.INI, which will be loaded as the default options. If a filename is given as the first parameter on the command line, the settings from that file (which can be created using the "S" command) will be used. P : Toggle peak display mode on/off (shows the frequency of maximum amplitude). L : Toggle between logarithmic and linear frequency (x axis) scales. D : Toggle DTMF decoding mode on/off. The decoded DTMF numbers are stored in an internal register and can be dialed anytime by pressing . T : Toggle CTCSS decoding mode on/off. Last decoded tone and its on/off state is displayed in real time. G : Logging on/off for the DTMF & CTCSS modes. A log file is created with time & date stamps for easy monitoring. I : Input a DTMF number and store it in memory. TAB : Generates the stored DTMF number. A : Generates a CTCSS sub-audible frequency (selectable from a CTCSS tones table). will select/deselect individual tones to be recognized in CTCSS decoding mode. Program starts with the 38 tones found on most transmitters activated. V : Redraw the video display. C : Toggle black&white/color display, useful for screen prints. Note: if you want to make a printout of the display, run the DOS program GRAPHICS.COM prior to running DTMF_FFT. Before printing, switch to the black&white display, and then press Shift-. Refer to your DOS documentation for more information on the GRAPHICS program. : increase the amplitude scale : decrease the amplitude scale : Shift frequency axis to the left (show higher frequencies) : Shift frequency axis to the right (show lower frequencies) '<' : Contract the frequency axis '>' : Expand the frequency axis : freeze display, put up a cursor, and put up a display of frequency and amplitude information. In this mode, the keys will move the cursor 1-left or 1-right. Use key and for moving the cursor with 10-left or 10-right and or for jumping at the start or end of the spectrum. Pressing will save the data to a file, with one frequency bin per line. Each line will contain {frequency} and {amplitude}. This data can then be loaded into a spreadsheet or plotting program for display. Pressing will resume data aquisition. For SB16, and SBPro cards the following keys are also available: (,) Decrease/increase the microphone input level [,] Decrease/increase the external input level {.} Decrease/increase the internal (CD) input level NOTES about DTMF and CTCSS modes: 1) The actual sample rates must be integer divisions of the timer frequency, which is 1.0 MHz for Soundblaster cards. This means actual sampling rates for Soundblaster cards are: 45.45kHz, 43.48kHz, 41.67kHz, 40kHz, ... 22.73kHz, 22.22kHz, 21.74kHz, etc. The program will compute the closest actual sampling rate to the one requested. 2) The specified sampling rate may be above what a Soundblaster can handle. If this occurs, the Soundblaster will sample at its maximum rate, and the frequency axis will not reflect the true frequencies. Typical 8 bit Soundblasters will only handle sampling rates up to 12kHz. Newer Soundblasters can handle sampling rates of at least 44.1kHz, and may be able to go beyond. 3) The band sample period is the inverse of the frequency resolution. This is independent of the sampling rate. Today's microprocessors have plenty of time for doing the IFFT computation and displaying the data even for very high sample rates during the next data sampling cycle. For the DTMF and CTCSS modes I have chosen resolutions close to the spacing of the frequencies I want to detect. That is about 40Hz for DTMF and 2.5Hz for CTCSS. That will give approximately 20 digits per second in DTMF mode and about 0.5 second delay in decoding CTCSS tones. Lowering these values will increase the decoding response time. If you have any questions, bug reports, suggestions, or additions to the code, please contact me. AUTHORS Emil Laurentiu Internet: emil@interlog.com Philip VanBaren Internet: phillipv@eecs.umich.edu HISTORY version 1.00 - first release version 1.10 - added a log feature. Now you can let the program running and all CTCSS frequencies and DTMF numbers will be logged in a file with a time stamp. - added some CTCSS frequencies not found on the usual TX handies. these frequencies can be activated/inactivated separately so only those that interest you will be recorded. - selected tones can be saved in the .ini file for later use - last CTCSS active tone is also displayed - changed delay routine for DTMF generation using processor timer rather than SB timers (which are not supported on all clones) - due to a tremendous request I've decided starting with this version to make the program sources available (hope you won't stop sending me postcards now :-). ACKNOWLEDGMENTS Most of this program and documentation were derived from Philip VanBaren program freq51 (version 5.1) who kindly made the sources for this program available. I thank him again with this opportunity. The program is mainly intended for use by radio-amateurs (HAMS) but other people might find it useful. The program decodes and generates DTMF codes and CTCSS codes (this are some "sub-audible" tones used in radio) using SoundBlaster input and output. I have striped some parts of the program that weren't important for the task of decoding and generating DTMF/CTCSS and I have supported only SB (normal ans Pro) and SB16 cards. This program is "cardware" that means if you like this program and you use it you should send me a post card. (This is a _must_, otherwise I will never upload my programs again :-). Please send me a postcard with a nature landscape from your country on the following address: Emil LAURENTIU Str. Drumea Radulescu nr.42 sect.4 Bucharest cod 75126 ROMANIA I thank those who already have sent me postcards and letters. I haven't seen them all yet but my mother tells me they are still coming. Thanks for your appreciation and nice words. For questions, bug reports, suggestions, or additions to the code concerning the DTMF and CTCSS part you can contact me at: Internet: emil@interlog.com The latest version together with some other articles and programs can be found on my WEB page. The current address is: http://www.interlog.com/~emil If that changes, use a search engine to find its new location. I am in Canada now, but please send the post-cards to the address in Romania because that one is a stable one. My latest email address (together with my PGP public key) can be found by querying the PGP key-servers (send email with subject line "MGET laurentiu" to one of these servers (for example to pgp-public-keys@kub.nl)).