MicFFT v1.2 July 29, 1993 Written by Craig M. Walsh CIS 70701,1614 Internet: Walsh@biovx1.dnet.nasa.gov Walsh@129.97.26.1 Introduction: MicFFT is a program that samples data from a sound card or addressable analog-to-digital (ADC) port, and plots out the spectral features of the sampled waveform. The program utilizes a Fast Fourier Transform (FFT) algorithm to transform the sampled data (in the time domain) to the frequency domain. The program gets 256 Pulse Code Modulated (PCM-see below) samples from the ADC at a defined sampling rate, and then plots the transformed data. MicFFT continuously loops between sampling and plotting. Thus, the program acts somewhat like a realtime spectrum analyzer, and on fast machines with fast sound cards, is capable of impressive performance. MicFFT can be likened to spectrum analyzers found on some audio equalizers, and can provide detailed information on the spectral components and relative intensities of continuous waveforms. Improvements in version 1.2: The main problem encountered by many of you with the Media Vision Pro Audio Spectrum 16 is that MicFFT v1.1 did not run properly under Sound Blaster compatability mode. This version now explicitly supports the ProAudio Spectrum 16 (and most likely, the original ProAudio Spectrum), and will also work with this card under SB compatability mode without much trouble. Thus, if you have a PAS16, please use the -B2 option when running the program. This version also has some improvements to the interface. Now, phase and raw PCM data can optionally be plotted, along with the spectral data. Also, frequencies can be adjusted during sampling, so that the optimal sampling frequency can be selected for a particular waveform. These improvements are relatively minor, but as I'm writing this, MicFFT v2.0 is in the works, which will have much more impressive features (like a real user interface, DMA input, file I/O routines, etc.) See the section, FUTURE DIRECTIONS below for more information. Improvements in version 1.1: Since many of you heeded my call for comments in the last version, I was able to gain insight into what improvements to include in this version of MicFFT. The main problem I found was that the original version of MicFFT did not support Sound Blaster or Sound Blaster-compatible cards, even though I presumed it might. After some investigation, I found that sampling on the SB card requires quite a bit of additional code that was not included in the original version of MicFFT. Since I don't have an SB card (I have a Covox Sound Master II, and am quite happy with it so far!), I had to find someone out there with one to help out. Fortunately, Chris Pye decided to join the MicFFT "development team", and has supplied the SB sampling routines (along with additional ideas, etc.) for this new version. Now, MicFFT v1.2 has explicit support for SB 8-bit cards (16 bit sampling is, sadly, not included yet). Additionally, other cards that have Sound Blaster compatibility should also work with MicFFT (see Compatibility); I hope this time I don't eat my words! MicFFT also has a new function that provides for freezing waveform sampling and allows detailed analysis of the frozen waveform. This function has a positionable cursor-line, which can be used to determine the frequency and amplitude of a specific band on the plot. The program also has a new plotting mode that allows plots to be generated in either bar graph style, as implemented in the original version, or line graph style, which produces output that may be more suitable to certain applications. Output is also scaled in decibel (dB) steps. Some new filtering options have been added to MicFFT v1.2; Squelch allows filtering of spurious noise below a set threshold; Cosine envelope is used to reduce transformation errors resulting from sampling discontinuities (see Cosine Envelope, below). In addition, certain bugs that were not identified before the original release have been fixed (I hope). Requirements: MicFFT is a computing-intensive program and requires a fast computer for achieving rapid output. It was developed on a 33MHz 486-DX (with built-in floating-point coprocessor), a Super VGA system, and a Covox SoundMaster II sound card. Graphics modes tested include both EGA and VGA, so both will work (see Options). MicFFT will look for a coprocessor (and will run dramatically faster if one is found), but will emulate one if a coprocessor is not present. Additionally, some 286-specific code is included for speed, and thus it will not work properly on machines with lesser processors. Since the sampling routines are timed and independent of the transformation and plotting, the speed of a particular machine should not affect the accuracy of frequency output significantly, unless the sampling frequency is excessively high; only the rate at which data is plotted will be affected. Supported Sound Cards: As stated above, this version of MicFFT explicitly supports the Covox SoundMaster II (default), the Sound Blaster cards for 8- bit sampling, and the ProAudio Spectrum 16 cards. The Sound Blaster mode, which includes additional code for sending commands to control the sampling specifics, is available using the -B1 flag (see Options). The ProAudio Spectrum 16 (and perhaps the original ProAudio Spectrum) is supported, and the user must specify the -B2 option at the command line. Other cards may work as well, particularly if some means for Sound Blaster compatibility is provided by the card. The Pro Audio Spectrum 16 card will work under SoundBlaster mode as well, since it implements this compatability in the hardware of the card itself. I have tested the program with the PAS16 card, and it does work. Covox compatibility (default) is likely not explicitly provided by other sound card vendors. However, it may be generally useful to those whose cards are capable of polling the ADC independently (without explicit commands for controlling sampling); MicFFT provides a means for changing the default ADC port address. In the Covox mode, MicFFT simply looks for data at this port at a defined rate using timing routines in the program. The default port address included in the program is 22F (hex). This is actually a port address (0x220h) and ADC offset (0x00F) added together. If you have a card where a port address is given in the documentation, and an ADC input offset is also given, just add the two together (using a hex calculator) and use the -P flag to let MicFFT know which address you need to use. I realize that this discussion may be a bit technical, but I provide it so that users with cards other than the above mentioned can attempt to figure out which options to alter. I know that incompatibility is frustrating, so if you have a card which is not explicitly supported (and there is really a growing list), I will include compatibility for such cards for those who can get me specific code for PCM sampling. I prefer to have short code segments (in C, or assembler if possible) to look at rather than libraries, since I need to be able to control some of the aspects of sampling, and I need you to volunteer for testing the modified code. Contact me at the address provided (see Contacting the Author), and I will happily discuss your specific needs. (It should be noted that I am currently porting the program to Windows. This will be helpful, since compatibility would not be an issue here, so long as the hardware has the appropriate PCM driver setup in Windows.) Lesson 1. PCM sampling: Sampling is a process whereby a continuous stream of data is broken up into chunks of data usable by the sampling system. PCM sampling is a process whereby this continuous data is polled ata defined rate. Since we are interested in analog signals most of the time (the type that enter our sound cards via the ADC port), it is necessary to first transform the data from an analog representation to a digital one. This is the job of the ADC. This process is fairly complicated, but suffice it to say that an analog value (from - infinity to + infinity) is transformed to an explicit digital value. Since the digital value can represent only a discrete value, there may be some loss of resolution in this transformation. 16 bit cards (which can represent 64K different input levels) are much more accurate for this purpose than 8 bit cards (which only can reproduce 256 different levels). Also, since PCM-sampling assumes that the analog waveform has components on either side of zero (i.e. negative and positive parts of a wave), one half of the digital range is negative, the other half positive. This reduces the number of possible digital absolute value amplitudes by a factor of two, which affects the dynamic range (i.e. the lowest to highest amplitude) of a particular digital system. Digital conversion produces a sample value, and this is done at a discrete sampling frequency so that points of a continuous analog waveform are approximated by a set of digital values. These digital values can be stored into the computer's memory and played back to reproduce an approximation of the original analog waveform. The process of rebuilding an analog waveform from digital samples requires that the samples are "played back" at a rate similar to the rate at which the samples were originally obtained. To do this, each sample is transformed from a digital value to an analog value (using a digital-to- analog converter, or DAC) and this is done for all of the stored samples at the chosen sampling frequency. Thus, an approximation of the original analog waveform can be reproduced. The accuracy of sampling thus depends on two major variables: the sampling rate and the number of possible sample values. The sampling rate can affect accuracy since it defines the highest possible frequency from the original waveform that can be sampled. The Nyquist sampling theorem dictates that the sampling rate must be at least twice the frequency of the highest frequency component to be sampled. Thus, frequencies greater than one-half the sampling frequency (the Nyquist limit) will not be sampled accurately. Attempting to surpass this limit will introduce errors into the sampled waveform. To get around this limitation in practical sampling systems (e.g. digital Compact Disc recording and playback, etc.), engineers utilize low-pass filters which attenuate signals of frequencies higher than the Nyquist limit prior to digital sampling. For CDs, which have a sampling rate of 44.1 kHz, these low-pass filters begin attenuating at about 21 kHz and have reduced the signal at the Nyquist limit of 22.05 kHz almost entirely. Thus, a CD can have data sampled upto about 22 kHz, but no higher, and is thus "bandwidth-limited." Sampling any higher frequencies would create undesirable noise in the output. (Note that 44.1 kHz is chosen because it is about the lowest value for accurately sampling the spectrum of frequencies important in musical signals; about 15 Hz to 20 kHz. Any higher value would be unnecessary and would require an increase data storage, an obvious limitation for a system with two digital PCM channels and error-correction data included with the PCM data). The second limitation to accurate PCM sampling is related to the number of bits each sample contains. CD sampled material is 16- bit PCM. This corresponds to a dynamic range of about 96 decibels (dB). Systems using smaller sized samples will obviously have a lower dynamic range. Thus, they will have an inherently higher level of noise, and are inappropriate for high-fidelity reproduction of sound. Of course, the tradeoff between sound quality and data storage is an important design consideration in any PCM system. Lesson 2. Superposition: It is fairly easy to figure out what a sinewave looks like from an oscilloscope plot. You've likely heard what a sinewave sounds like; pretty boring. A simple sinewave can produce a tone. However, most sound that we hear and find pleasing has much more content than a single sinewave. Musical instruments produce waveforms with a fundamental (do not confuse with my terminology below; fundamental here refers to the primary frequency created by an instrument) frequency (sinewave) and a group of harmonic sinewaves at multiples of the fundamental. These "harmonics" give each instrument a recognizable sound, or timbre. When we break up the waveform, it is possible to show that the original waveform is thus the addition of the fundamental sinewave and all of its harmonic sinewaves. This addition is called superposition. Of course, superposition can be both additive, or destructive. Destructive superposition can actually cancel out the amplitudes of two waveforms (for example, if both are of the same frequency and amplitude, but are 180 degrees out of phase; i.e. the peak of the first wave corresponds to the trough of the second). If you listen to two sinewaves being reproduced by the FM chip on your sound card (if you have one), you will be listening to superimposed sinewaves. However, since your ear is able to pull out the discrete frequencies in the signal, you hear two sinewaves (sort of like the FFT routine described below). Pretty neat, huh? Lesson 3. Fourier Transforms: Many of you may have seen programs that take PCM sampled sound and output the data on the screen in an oscilloscope-like display. In this case, the plot is based on amplitude vs. time. It is possible to determine the relative frequency of a continuous waveform by varying the sweep-rate of such an oscilloscope, but there are better ways to gather frequency data from PCM samples. One approach is to pass the data through an algorithm called a Fast Fourier Transform (FFT) and to plot the resulting data as a magnitude vs. frequency plot. Essentially, the FFT loops thru a group of samples and pulls out all of the sinewaves contained in the sampling period (delta). Since we know the sampling rate (and thus, the time between samples), it is possible to assign frequency values to the sinewaves determined by the FFT. So, the Fourier Transform works like the superposition principle in reverse. The first sinewave is the lowest possible sinewave that can be sampled accurately by the FFT, and corresponds to the sampling frequency divided by the number of samples in delta. I refer to this as the fundamental frequency of the plot, F-fund. The frequency band plotted is twice F-fund, and the next is 3X, and so on. Thus, the plotted bands continue up by multiples of F- fund until we reach the Nyquist limiting frequency (F-Ny), which incidentally has a band number equal to 1/2 the number of samples in delta (band number is also called channel number; one band is plotted for each frequency displayed by MicFFT for a particular sampling frequency). Generally, data is plotted with linear scaling along the frequency axis, which means that each band plotted represents one frequency. However, it should be noted that frequencies located between two discrete bands will be represented as maximal deflections of the two bands on either side of this intervening frequency. Additionally, an even-band centered frequency will produce deflections of those bands adjacent to it, tapering off as we move in either direction from the center band. One should use care when ascribing a particular group of frequencies to a particular plot; as you work with MicFFT, you will get an idea of what to expect. MicFFT Usage: When you start MicFFT with the appropriate command line arguments (see Options), you will be able to begin sampling signals entering the ADC. Whistle into a microphone connected to the sound card. You should see a peak, corresponding to the frequency of the whistle. Since the whistle is produced at the lips, there is little interaction with the resonant cavities of the body that normally introduce harmonics in speech and singing. Thus, whistling approximates a sinewave and can be used to test MicFFT for simple waveforms. Vary the pitch of your whistling. By reducing the pitch, you should see this peak move to the left, thus indicating that the frequency is moving lower. By raising the pitch, the peak should move to the right of the plot (note that the degree of peak movement will be affected by the chosen sampling frequency). Note the ruler at the bottom of the plot screen. This ruler corresponds to the multiples of the fundamental frequency. Ones are in white, fives are in orange and tens are in red. You can use the ruler to get an instant idea of the relative frequency during sampling (if you are quick at math). It is now possible to freeze the plot by pressing the SPACE bar. Do this while continuing to whistle. Once the sampling has stopped and you have a frozen waveform frequency spectrum on the screen, you can use the arrow keys to move a cursor line around the plot. Move the cursor line to the peak. Below, you will see the frequency for this peak, as well as the amplitude (in magnitude returned by the FFT routine, and based on a maximum of 128; and in dB, relative to a dynamic range from 1 to 48 dB for the 8-bit samples). Note that the power density is related to the area under the peak; the magnitudes shown are plotted only for the band under the cursor line. Keys for Freeze Window: To move the cursor line around, use the LEFT or RIGHT keys for single band movements. To speed up movement around the plot, use CTRL-LEFT or CTRL-RIGHT to move ten bands for each keypress. To move to the right end of the plot, press END or PGDN; to move all the way to the left side, use HOME or PGUP. To return to the sampling mode, press the SPACE bar. To exit the program at any time (during sampling or in the freeze window), press ESC. Options: MicFFT v1.3 has a number of options which are set by command line arguments using specified flags. It is also possible to set some of these options while the program is running (see KEYBOARD OPTIONS DURING SAMPLING). Typing MicFFT at the DOS prompt without any flags will run the program with the built-in defaults. You can override these defaults using the following flags: -?: Display command line options. Also -h. -f: Change the sampling frequency. -f25000 will change the sampling frequency to 25 kHz. Valid range is from 1 Hz (which would take 256 seconds before the first plot; not recommended...) and the highest sampling rate of your sound card. For the Covox card, this is 25000 (although I've been able to get upto 34090 Hz before getting sampling problems). For the Sound Blaster, this is 13 kHz. For the ProAudio Spectrum 16, this is 88200 Hz (and I assume 44100 Hz for the original ProAudio Spectrum). Play around with this option a lot. Default is 10000. -p: Change the default ADC port address. Default is 22F (hex), which corresponds to the default for the Covox card. - f24fh will change to port address/offset 24F. If you use the Sound Blaster mode (see -b flag), the default will be 220. Note that if you supply a hexidecimal address, use an "h" following the address to signify that you are using a hex address. Decimal addresses are assumed and require no h at the end. MicFFT will report the address chosen, so you can verify that the correct address has been selected. -b: Change the sound card mode. The default is the Covox mode (see Sound Cards, above), which is -b0. For Sound Blaster (or compatible) mode, use -b1. The ProAudio Spectrum is set with - b2. -m: Scaling mode. Set to -m1 for maximum amplitude mode. In this mode, all amplitude data is scaled on the plot so that all amplitudes are scaled to the amplitude of the highest peak in the plot. Set to -m0 for log amplitude scaling; log amplitude scaling is in dB, so this may be more suitable for some signals. -m0 is the default. -l: Line mode. Set to -l1 for line plot mode. In this mode, lines are drawn between points corresponding to amplitudes of successive bands. Set to -l0 for bar graph mode. In this mode, each frequency band is plotted distinctly, from the bottom of the plot to each amplitude point. -l0 is the default. -c: Cosine envelope. Type -c to turn on the cosine envelope function. This adds a filter that prescales the data to remove discontinuities at either end of the waveform before entering the FFT routine. This may produce a more stable display for waveforms that are not rapidly changing, and will reduce the magnitudes of data around improperly centered frequencies. On some computers (particularly those without math coprocessors), this will increase the computation time somewhat. -s: Squelch mode. To remove low-level noise from the input, to clean up the plot, use -s. This removes any samples above and below the zero level. For example, -s10 will remove all PCM samples between -10 and +10. Use this option carefully, since it can create square-waves, which have a variety of frequency components that will pollute the spectrum. I do not recommend values of greater than, say 10 for 8 bit sampling. -d: DC Offset. Generally, 8 bit cards represent zero level signals as 128. To produce an AC wave centered around zero, MicFFT subtracts the DC offset (128) from the input values. It is possible that the DC offset is not perfectly centered at 128. For example, it is my experience that the PAS16 I've tested under SB compatability mode is actually centered about 108. Thus, by typing -d108 on the command line, the zero level is correctly centered. This is particularly important for the cosine envelope function, since a large DC offset will produce a corresponding deflection of the first band on the plot (i.e. the fundamental frequency band). If you encounter problems of this sort, it is recommended that you experiment with this value. Unfortunately, this version does not perform this automatically. -e and -v: Force EGA or VGA mode, respectively. The default is to use the maximum resolution of the monitor, based on the mode the monitor is set to when MicFFT is started. -e has lower resolution, but may be faster on some VGA monitors. It also produces a somewhat larger plot. -v was added for consistency. Note that all options can be entered using either the - or / switch. Case is not important, but you must not include white spaces for any particular flag, since MicFFT will ignore any options that do not conform to this syntax. Order is also not important, since the options are collected and verified before any setup occurs. I recommend that you create a batch file that has your required configuration (for example, port and plotting mode specs) along with a couple of %n's to allow additional parameters to be entered. For example: @echo off REM RUNMF.BAT -- Batch for running MicFFT with set config. MicFFT -p24Fh -m1 -l1 %1 %2 %3 %4 Keyboard Options During Sampling: MicFFT v1.2 now has a few options that can be set during the sampling period, rather than requiring command line flags for all options. The following summarizes key usage during sampling. For information regarding key usage in the Freeze Window, see above. c Toggle cosine envelope. l Toggle line/bar plot modes. m Toggle amplitude scaling (linear vs. logarithmic). a Toggle wait for data available during sampling (SB mode only). x Toggle display of phase data. s Toggle display of raw PCM data. [] Decrease or increase (respectively) sampling frequency by 10 Hz. {} Decrease or increase (respectively) sampling frequency by 100 Hz. ./ Decrease or increase (respectively) sampling frequency by 1000 Hz. Freeze sampling and display Freeze Window. Exit program. Performance and Hardware-Specific Notes: As stated above, MicFFT frequency accuracy should not be affected by different machine speeds, since the sampling is done in a loop separate from the other routines, and uses the PC's internal 8253 timer chip for accuracy in the fractional microsecond range. However, the Sound Blaster mode may not be as accurate, because a number of additional steps are required for sampling that will certainly increase the processing time. Since I don't have a Sound Blaster card, it is not possible for me to test this out. Chris Pye, who wrote the Sound Blaster routines, has observed frequency problems, but only when the sampling rate exceeded 13 kHz. Try this out for yourself. If you use a tuning fork (or some other stable frequency generator), you should get approximately similar frequency peaks at different sampling frequencies. Keep in mind that any error introduced by this extra processing will affect high sampling rates. Thus, compare low rates with very high rates. If the frequency display is stable, everything should be pretty accurate. In SB-mode, MicFFT polls the ADC port (default address at 220 hex) after testing the data available port. The data available port is set high when the ADC has sampled and confirmed the next input sample. However, you can turn off this checking using the "a" key (as described above). This will enable the program to oversample the ADC by not testing for the next sample value. It is possible to observe stair-stepping in the raw PCM samples using this approach, but it should be noted that the accuracy of the plot will also be affected. For example, this will produce sqare waves, which will have a variety of high-frequency components. It may be possible to sample at a slightly higher frequency, since this extra looping is removed from the processing. However, once the maximum sampling rate is reached, it is not possible to get any additional information. I left this in the program just as a "gee-whiz" sort of feature. If you want to do serious spectral analysis, I'd suggest not using this feature. However, you can see just how fast the program can calculate the FFTs by turning off checking and speeding up the sample rate. Just be cognisant of the limitations mentioned. I have noticed that it is not possible to sample at a rate higher than 34090 Hz (not even 34091!) on the Covox card. When I try, I get no output (or output only in the first channel). I don't know why this occurs, but it is probably related to the way in which this specific card samples data, as well as my machine's clock rate (33 MHz). I assumed that I would see a smearing of frequency at these higher rates (i.e. shifting to reflect a lower actual rate than set by the program), but rather this is a brick wall beyond which sampling doesn't work. In a way, I much prefer this, since it helps to know that the program is accurate upto this maximum rate. Again, it is important to test this out on each system, if you are really interested in accurate, high-frequency sampling. In this respect, I may move to DMA-controlled PCM sampling support for the Covox, Sound Blaster Pro and Pro Audio Spectrum cards in future releases. This would allow the card itself to do the work of ensuring accurate sampling. Of all the cards tested, the ProAudio Spectrum 16 is the most stable and is capable of impressive performance. The card is capable of sampling at 88200 Hz, which means that the entire spectrum encountered in perceptible audio signals is represented in plots produced by the program (20-20,000 Hz). This card also has a preset hardware anti-aliasing filter (in the form of a programmable capacitor network at both the input and output of the analog stages). When MicFFT is initiated, the defined sampling rate preselects the appropriate best-match filter for the chosen sampling rate. If you start the program with the - f88200 flag, all frequencies below at least 20kHz should be represented properly. Thus, I recommend adding this flag when starting the program using the ProAudio Spectrum card, unless you wish to use a lower frequency filter setting to keep aliasing out of the picture. Also, it is important that the "Digital Audio" setting (set using the command PAS * at the DOS prompt) be set, since the program does not currently adjust mixer settings. If you do not set this to zero, you will get a great deal of bothersome feedback. However, if you set this to a value of about 50% or so, it is possible to hear the different anti-aliasing filters kicking in upon initiation of sampling, if you have a signal impinging on the ADC at this point (for example, CD audio). The refresh rate (i.e. the amount of time between sampling periods) will vary, depending on the machine used. MicFFT is set up to sample 256 data points, transform and plot out the data, then repeat this. On slow machines, the refresh rate will be low; on fast machines, particularly those equipped with floating-point coprocessors, it will be impressively fast. Nevertheless, it is important to stress that the time spent processing the data is time spent not sampling. Thus, events occuring between sampling periods will be ignored. This may be problematic with time-varying signals, particularly those with substantial transient components. For this reason, it is necessary to carefully analyze the plot for such data. Sometimes, the plot will miss these transients. If this is a concern, I suggest slowing the sampling rate to the lowest allowable frequency (based on the bandwidth of the signal), as this will increase the chance of capturing this varying signal in the plot. You can freeze a waveform, but this is difficult with rapidly varying signals. A more suitable approach would be to sample the waveform and select the parts of a time-domain plot to display. Future versions of MicFFT will include this feature. Also note that the cosine envelope will reduce the refresh rate, because it adds a lot of floating-point calculations. The show PCM mode (turned on by pressing the "s" key) will also slow down the refresh rate. This is due to the extra graphics processing occuring. It is possible to cycle between off, line-draw and pixel plot for this option. I suggest pixel plot for the quickest display of the PCM data, since large-amplitude waveforms will not affect the graphing speed. The line-draw is somewhat slower for large-amplitude waveforms since the program must calculate and graph not only the endpoints, but all of the points on the line as well. Of course, the line-draw mode looks nicer. Finally, the show-phase option (toggled by the "x" key) can also slow down the refresh rate. All of the graphics options should be tested for a particular system to determine the optimal trade-off between performance and the desired information. I have gotten some flak from a variety of people about the sluggishness of the program. I was a bit suprised, because I was observing pretty suitable performance from the program on my 486DX. However, after disabling coprocessor support for the program, I was amazed at how slow the program can be. As a test, you can set an environmental variable to ignore the coprocessor if your computer is equipped with one. To do this, just type "SET NO87=Boy is this program slow!" at the DOS prompt, then run the program. This is one of those tests where you will feel pretty lucky to have a coprocessor, if you ever wondered what it was good for. I believe the speed difference is probably on the order of about 10 to 50 fold. If your computer doesn't have a coprocessor, you may wish to purchase one, particularly if you do a lot of number crunching. As far as MicFFT goes, there is pretty much no way around it. There are a LOT of calculations going on, and anytime the processor can offload some for a little cheap "parallel" processing the better. I guess I might be able to enhance performance somewhat by coding the routines entirely in assembly, but I have other things to do with my time. It is important to be cognisant of the Nyquist limit for any particular waveform, as signals with components exceding the limit will be "aliased" and not represented properly by the spectral plot. As I described above, frequencies above the Nyquist limit will produce errors (aliasing) unless these are removed from the signal before they are sampled. This is interesting in one respect: set the sampling frequency to about 4000 Hz and start a low whistle. As you increase the frequency, you will notice that the peak wraps around as it moves to the right side of the plot. If it goes far enough, it will also wrap around the left side of the plot as well. This a very graphic demonstration of aliasing. Beyond the academics, aliasing can be a serious problem to accurate spectral analysis. MicFFT does not yet have any low-pass filtering built in (although future versions may include this), so you will have to consider aliasing when chosing a particular signal and sampling frequency. If you are capable, it is possible to add a low-pass filter to the input line of your signal generator (or mic) to eliminate these higher frequencies. Your sound card may even provide for this type of bandwidth limiting (incidentally, the PAS16 does, and is set to the best match when the program starts, based on the initial frequency value). MicFFT is not designed to compete with hardware spectrum analyzers (not yet, at least). But, since these hardware analyzers are many thousands of dollars, the cost of this approach is more suitable for many applications, particularly experimentation into sound, etc. Although you may come up with interesting ideas, I don't yet recommend its use in building the next-generation Hubble Telescope, etc. However, it might work really well in analysis of Cold Fusion experiments. If you have any results in this arena, please inform me so I can buy the stock (SEC, just kidding already!). Acknowledgements: I'd like to take this opportunity to thank many of you who downloaded MicFFT v1.0 and v1.1 and sent comments to me about the program. Since I've not asked for a fee for the program, at least it gives me a little ego boost, and makes the programming a bit more fun. Your comments and criticisms have certainly made development a more enlightened process. Andy Charmatz, here at UCLA, has been a fantastic help in getting the SB routines to work with the PAS16, as well as the implementation of the PAS16-specific coding. He lent me his PAS16 so that I could test out the SB routines and find out where the real problems were occuring. As it turns out, MicFFT didn't really crash the computer when it was having problems with the PAS compatability, it was just not getting info from the data available port. So it goes for SB compatability! Incidentally, if you have a card which does not work with this program, I'd be happy to make arrangements to work some routines into the program to make it run properly. Chris Pye has been instrumental in making MicFFT compatible with Sound Blaster cards. He also provided code for the freeze- window routine and the cosine-envelope function. He knows a lot more about Fourier transforms than I (I'm a molecular biology grad student, and just a engineering/physics hacker), and I'll be working with him a lot in the future for developing better versions of the program. Additionally, the FFT routines used in this program are based on those implemented in an archive called FFT.ARC found on Compuserve by the author Steve Sampson, as well as those found in a book called Numerical Recipes in C. The 8253 timer routines (which have extraordinary accuracy) are based on a Compuserve archive called TIMERH.ARC, uploaded by the author Micahel Walraven. I am indebted to the work of these authors. Conditions of Use: MicFFT v1.2 is freeware, which means that I continue to hold the rights to the program (i.e. it is not released into the public domain). You are entitled to copy the program, and are encouraged to post the program on BBSs, distribute it to friends, etc. However, if you use the program, I ask that you contact me (see Contacting The Author) to let me know what you are using it for, its fitness, and other comments, problems, etc. When and if I decide to charge for my work, I won't require this. When I download programs I find interesting, I often notify the author out of courtesy. Usually, I get lots of ideas as well. You may find that such discourse can be fun and interesting. On the other hand, you may find that I don't know anything about this stuff. You'll just have to try me. The code for MicFFT is not available, unless you make specific arrangements with me first. The main reason for this is that I want to maintain control of the development of the program. If you have good ideas, and are proficient in coding, I'll make exceptions. Future Directions: I've initiated work on the next version, which should be available much sooner than this version has taken (I've been pretty busy with other things). The next version will definitely include DMA-based input, and perhaps if some of you contact me soon, support for other cards (like the SB Pro 16 ASP, etc). Also, I will include support for 16 bit sampling for cards where this is permissible. I may also include stereo sampling, although I've not quite determined the usefulness of it in this context (ideas? ideas?). Additionally, a few other windowing functions will be included ( Hamming-Hanning, Parzen, etc), as well as digital lowpass filtering. I am also playing around with the FM chip (Adlib compatibles) so that it will be possible to use the FM chip to produce test signals that can be analyzed (particularly useful for us speaker builders!). I have been writing some very fast graphics routines, so I hope to increase the speed of the program output by implementing them. Additionally, I will definitely provide a REAL user interface in the next version, with all the buttons, etc. I recently purchased MS Visual C++, and will eventually produce a program for Windows-based sound analysis. Contacting The Author: You can contact me at the following E-mail addresses: Compuserve 70701,1614 Internet: walsh@biovx1.dnet.nasa.gov (Incidentally, I don't work for NASA, but our mail-server here at UCLA is named this way for some strange reason). I can also be contacted by phone at my Los Angeles residence at (310) 390-0598 Please note that I'd prefer to get mail via Internet, since my Compuserve bills have been skyrocketing (and I'm just a poor, lowly grad student). You can do this on Compuserve by sending the mail to an Internet address (see the help screen for the specifics here. I don't recall offhand how to do this). I check my mail on the Internet on a daily basis; I check Compuserve much less frequently. For a super low-tech approach, you can send a post via hardcopy to: Craig Walsh 12420 Woodgreen Ave #203 Los Angeles, CA 90066 Have fun, and good luck with MicFFT v1.2. Let me know what you think.