FILE LIST: FREQ.EXE executable program for PAS 16 sound cards SBFREQ.EXE executable program for Soundblaster sound cards FREQ.TXT (you are reading it) FREQ.INI initialization file for FREQ.EXE/SBFREQ.EXE FREQ.EXE: FREQ.EXE is a program for the ProAudio Spectrum/Studio 16 sound cards. It samples the input, performs an FFT, and graphs the output. 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, and windowing functions. 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. SBFREQ.EXE: SBFREQ.EXE is the equivalent to FREQ.EXE, except it 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. COMPATABILITY: This program has been tested on the following sound cards: - ProAudio Studio (freq) - Logitech Soundman (freq) - Soundblaster 16 (sbfreq) - Soundblaster (sbfreq) - Sound Galaxy 16 NX (sbfreq) - GUS MAX (sbfreq with SBOS) RUNNING UNDER WINDOWS: I have had problems with running the PAS version of the program under Windows with the latest PAS drivers (MVSOUND version 3.23 or 3.24). I don't remember having any such problems with previous versions of the PAS drivers. If switching between Windows and Freq causes the screen to be messed up, use the 'V' command to restore the display. COMMAND LINE OPTIONS: -Snumber sets the sampling rate. -Fnumber sets the length of the FFT. -Mnumber sets the scale maximum. -Bnumber sets the logarithmic base level (in tens of dB). -Tnumber sets the logarithmic top level (in tens of dB). -Gnumber sets the dB/octave gain factor. -Rnumber sets the reference frequency for dB/octave gains. -LA sets a logarithmic scale for the amplitude axis. -LF sets a logarithmic scale for the frequency axis. -W0 selects a Hamming window. (offset sine) <--default -W1 selects a Hanning window. (sine) -W2 selects a Blackman window. (two sines) -W3[,alpha] selects a Gaussian window. -W4 selects a Welch window. (quadratic) -W5 selects a Parzen window. (triangular) -W6 selects a Rectangular window. -Wfilename saves the windowing function to the specified file. -? or -H 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. Sample rate: 44100 ( same as -Snumber ) Valid sampling rates are 5000 Hz to 88200 Hz for PAS 16 cards. For Soundblaster cards, values in the same range will be accepted, however for the old 8-bit Soundblaster cards (and the Soundblaster section on PAS cards) the sampling rate cannot exceed 12000 Hz. Any value greater than this will result in a mis-labelled 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. Window function: 0 ( same as -Wnumber ) 0 selects a Hamming window. (offset sine) <--default 1 selects a Hanning window. (sine) 2 selects a Blackman window. (two sines) 3 selects a Gaussian window. 4 selects a Welch window. (quadratic) 5 selects a Parzen window. (triangular) 6 selects a Rectangular window. Log freq scale: 0 ( 1 = -LF ) 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) Log amp scale: 1 ( 1 = -LA ) 0 selects a linear amplitude scale 1 selects a logarithmic (dB) amplitude scale Base db: 7 ( same as -Bnumber ) Sets the base value for the dB amplitude scale Top db: 2 ( same as -Tnumber ) Sets the top value for the dB amplitude scale Max amp: 1.0 ( same as -Mnumber ) Sets the top value for the linear amplitude scale DB/octave gain: 0 ( same as -Gnumber ) Valid values here are 0,3,6,9, or 12. This option gives a frequency- dependent boost in the displayed amplitudes. The value specified is given in dB/octave. For example, suppose there are two signals, one an amplitude-1.0 signal at 1kHz, and the other an amplitude-0.5 signal at 2kHz. Specifying 6dB/octave will result in both of these appearing at equal amplitudes. Specifying 12dB/octave will result in the 2kHz appearing to be twice the amplitude of the 1kHz signal. Since harmonics typically are reduced in amplitude proportional to 1/frequency (6dB/octave) or to 1/frequency^2 (12dB/octave), using this option will improve the visibility of the higher harmonics in a signal. Reference frequency: 1000 ( same as -Rnumber ) This specifies the frequency of 0dB gain, when a dB/octave gain factor is being used. 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. Decay mode: 0 0 selects no decay mode (display what has just been sampled) 1 selects decay mode. In this mode the values at a frequency will decay exponentially until a new, larger value appears at this frequency. The decay rate can be set with the following option. Decay factor: 0.9 This value selects the rate at which the frequency bins decay in decay mode. The value should be less than 1, and larger than 0. 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: 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 FREQ.INI, which will be loaded as the default options. If a filename is given as the first parameter on the command line, W : Alternate among the windowing functions P : Toggle peak display mode on/off (shows the frequency of maximum amplitude) X : Toggle between logarithmic and linear frequency (x axis) scales Y : Toggle between logarithmic (dB) and linear amplitude (y axis) scales 0 : Select 0 db/octave gain 3 : Select 3 db/octave gain 6 : Select 6 db/octave gain 9 : Select 9 db/octave gain 1,2: Select 12 db/octave gain V : Redraw the video display B : 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 FREQ. Before printing, switch to the black&white display, and then press Shift-. Refer to your DOS documentation for more information on the GRAPHICS program. D : Toggle decay mode on/off. Decay mode causes the frequency bin contents to decay exponentially from their peak values. The rate of decay can be adjusted using the +/- keys. +/- : increase/decrease decay rate in decay mode : increase the amplitude scale : decrease the amplitude scale Alt- : raise top dB level for log amplitude displays Alt- : lower top dB level for log amplitude displays : Shift frequency axis to the left (show higher frequencies) : Shift frequency axis to the right (show lower frequencies) Alt- : Contract the frequency axis Alt- : Expand the frequency axis : freeze display, put up a cursor, and put up a display of frequency, phase, and amplitude information. In this mode, the H,J,K,L keys will move the cursor 10-left,1-left,1-right,10-right, respectively. Pressing will save the data to a file, with one frequency bin per line. Each line will contain {frequency} {real part} {imaginary part}. This data can then be loaded into a spreadsheet or plotting program for display. (The FFT magnitude is found by computing sqrt({real part}^2+{imag part}^2).) Pressing will resume data aquisition. For PAS16 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 THE WINDOWING FUNCTION: Several different windowing functions are available. The windowing function is a function that is multiplied by the input data to reduce the effects of the discontinuity at the ends of the data set. A rectangular window is actually no window: all data is passed through. A Parzen (triangular) window uses a trianglar weighting: the end points are multiplied by 0, the middle point by 1, with a linear ramp from 0 to 1 and back to 0 again. A Welch Window uses a quadratic weighting: the end points are multiplied by 0, the middle points by 1, with a [concave down] quadratic function from 0, up to 1, and back down to 0 again. To see the shapes of the various windows, used the -Wfilename option, and plot the data in the output file. The best way to see the effects of windows is to use a logarithmic amplitude scale, and input a sine wave (an audio test CD works great for this). If you don't have any good sine wave sources, whistling into a mic works fairly well. KNOWN PROBLEMS: (let me know if you find others) 1) The PAS version of the program does not work if the 'device=mvsound.sys' line in config.sys contains the switch "u" (this switch allows initialization of the card, but then the driver is unloaded from memory (not a TSR)). Removing this switch solves the problem. My config.sys contains the following line: devicehigh=c:\pastudio\mvsound.sys d:5 q:10 s:1,220,1,7 j:1 t:1 v:0 2) The actual sample rates must be integer divisions of the timer frequency, which is 1.19318 MHz for PAS cards, and 1.0 MHz for Soundblaster cards. This means actual sampling rates for PAS cards are: 91.78kHz, 85.23kHz, 79.55kHz, 74.57kHz, 70.19kHz, 66.29kHz, 62.80kHz, 59.66kHz, ... , 45.89kHz, 44.19kHz, 42.61kHz, etc. and the actual sampling rates for Soundblaster cards are: 45.45kHz, 43.48kHz, 41.67kHz, 40kHz, ... 22.73kHz, 22.22kHz, 21.74kHz, etc. The displayed sample rates will not reflect actual values unless the command line option specifies a rate that is an integral division of the timer frequency. 3) The PAS version of the program may crash under Windows when used with newer versions of the PAS drivers. (MVSOUND version 3.23 or 3.24.) I don't recall having these problems with previous version of the drivers. Also, there is the possibility, depending on the installed drivers, that the Windows mixer settings will be confused. This can be corrected by running the mixer program. 4) 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. WHAT'S NEW IN VERSION TWO: 1) The FFT routine has been changed to process purely real data, which can be done in about half of the time it takes to process complex data. This makes the FFT routine a little messy, but it is worth the mess! 2) The screen updating routine was changed a bit, and now runs faster than before. The main change was setting the mode and color once when the program starts, instead of every time a line was drawn. This works because I am interesting in drawing one color only, and nothing else is trying to output to the display while the program is running. 3) Changed the square root code to use a Newton-Raphson method. 4) Filled in the gaps in plots (such as log frequency scale). 5) A version is included which runs on only 386+ machines with COPROCESSORS. This program is even faster than the other version because it was written in 386/387 assembly code. 6) Removed Bartlett window function (it is essentially the same as the Parzen window function). 7) Added cursor/amplitude display during paused display. WHAT'S NEW IN VERSION THREE: 1) Skipped the assembly language version (it is too difficult to keep up with the changes in two versions of the program). The version optimized for the 386 runs as fast as the eye can see, anyway, so there was not much gain it going real time. 2) Added checking so that lines do not go beyond the limits of the display. 3) Added options for 0,3,6,9,12 dB/octave gains so that higher harmonics can be made more visible (6dB/octave gain will make harmonics whose amplitudes drop as 1/frequency to have the same amplitude; 12dB/octave will make harmonics whose amplitudes drop as 1/frequency^2 to have the same amplitude.) 4) Added a bunch of run-time options for modifying the display. 5) Added more information in the header display 6) Added an INI file for setting defaults, so that you don't have to specify all of your favorite options on the command line. 7) Allow modification of display colors (through the FREQ.INI file). 8) Background flashes a warning color when saturation of the input occurs. (This flashing can be disabled by setting the background color and the clipping warning color to the same values in the INI file.) THE SCORE FOR VERSION FOUR: 1) Added run-time commands for changing of the FFT size and sampling rate. 2) Added a command to save the current state to an INI file. 3) Added a command to toggle between color/black&white displays, so that screen-prints looked good on black&white printers. 4) Added commands for zooming in on the frequency axis. 5) Added decaying-bin display mode. 6) Added control of mic/ext/int input levels for PAS 16 cards. 7) Added help display. CREDITS: The Soundblaster code was written by Heath I. Hunnicutt (heathh@cco.caltech.edu -or- heathh@tybalt.cco.caltech.edu). The source for this code is also available via FTP, but I don't remember where. Thanks to Marko Slyz for his relentless critique of this program. Because of him, the user-friendliness was improved and many extra features have been added. The source code for a previous version of this program is available via FTP in the file FREQ3.ZIP or FREQ3.ARJ. If you have any questions or bug reports, you can contact me at: Internet: phillipv@eecs.umich.edu Compuserve: 71214,2302 Philip VanBaren 1845 Lake Lila Dr. Apt. C3 Ann Arbor, MI 48105