Copyright: Copyright (c)1996 R. S. Horne


gram3 Index
Spectrogram 3.2 Index

PRINCIPLES OF OPERATION

SYSTEM REQUIREMENTS

SPECTROGRAM ANALYSIS PARAMETERS

Sample Characteristics

FFT Selection

FFT Window

Time Scale Selection

Display Characteristics

Computing the Spectrogram

THE SPECTROGRAM DISPLAY

MODIFYING SPECTROGRAMS

SPECTROGRAM PLAYBACK

DATA LOG

Points

Spectrum

AUDIO RECORDING AND ANALYSIS

SCANNING FILES OR AUDIO INPUT

Scrolling Spectrogram Display

Spectrum Analyzer Scope Display

SAVING AUDIO AND BITMAP FILES

SIMULTANEOUS OPERATION

LIMITATIONS

PROBLEM REPORTING

DISTRIBUTION

Copyright ©1996 R.S. Horne


PRINCIPLES OF OPERATION

Most ordinary sounds are complex combinations of individual frequency components or harmonics with a wide range of frequency and intensity.  A spectrogram is simply a plot of the frequency components of such an audio signal as a function of time.  In this Spectrogram program, digital audio recordings (PCM format) are analyzed to produce a plot of frequency versus time, with harmonic intensity represented by a variable color scale.  These spectrograms reveal the fascinating hidden frequency structure of audio signals and can be used for identifying or classifying particular sounds.

Spectrogram uses a mathematical Fast Fourier Transform (FFT) to perform the frequency analysis.  FFTs are usually specified by the number of input data points used in each calculation, which are always powers of two (512, 1024, 2048, etc).  The frequency resolution of the spectrogram is always the digital sampling rate of the audio signal divided by the number of FFT data points.  The greater the number of FFT data points, the finer the frequency resolution of the spectrogram.  The maximum frequency computed by the FFT and the upper frequency limit of the spectrogram will be half the digital sampling rate.

The choice of sampling rate depends entirely on the highest frequencies in the audio signal.  The rule of thumb is to use a sampling rate that is twice the highest frequency in the audio signal.  That is, if you expect to have no frequency components above 11KHz, then a sampling rate of 22KHz is adequate.  If you examine a spectrogram and see that all of the signal is concentrated in lower frequency components at the bottom of the display then it is a good bet that the recording was sampled at too high a rate, wasting a significant amount of memory.  By varying the sampling rate and the number of FFT input data points, the frequency resolution and frequency span of the spectrogram can be chosen to best fit the audio signal of interest.  Don't fall into the habit of automatically recording everything at a 44 KHz sampling rate.  Lower rates often result in much better spectrogram displays

Spectrogram provides two basic modes of operation, "Analyze" and "Scan." Analyze functions store the audio signal and spectrogram display bitmap in RAM and allow manipulation of the analysis parameters to achieve the best possible display of the data.  Scan functions do not store the audio signal or display bitmap and so do not allow manipulation of the analysis parameters.  However, scanning of either a data file or audio input will provide a real-time high resolution display of audio data of unlimited length.


SYSTEM REQUIREMENTS

 Spectrogram requires Windows 95 or Windows NT 4.0.  Spectrogram does not run properly under Win 3.1 or Win 32s.

 Spectrogram runs best with 16MB or more of RAM memory.  You can run Spectrogram with only 8MB of RAM.  However, not all functions for modifying the Spectrogram display will be available.

Spectrogram is designed for use with 256 colors.  Use of more that 256 colors is not recommended.

Spectrogram processes PCM format digital audio data such as .wav sound files but cannot convert compressed audio data.

In order to record and play back sound samples, you will need a Windows compatible sound card installed.  However, a sound card is not necessary in order to analyze and display audio spectrograms.


SPECTROGRAM ANALYSIS PARAMETERS

Choose "Analyze File" from the "File" menu to load a digital sound sample file.  Once a file has been selected, you will be presented with a dialog box named "Choose Analysis Parameters" for selecting the parameters of the frequency analysis.  To select the default values, just press the OK button.  You can also make changes in any of the parameters to customize the analysis.


ANALYSIS PARAMETERS - Sample Characteristics

You can choose any value of sample rate from 5513 Hz to 44100 Hz.  If you have selected a .wav file, the sample rate displayed will be the rate used in the original recording.  If you have selected a raw data file, a sample rate of 11025 Hz will be initially assumed, and you should enter the correct value if necessary.  In order to enter a sample rate value, first click the "New" button in the Sample Characteristics group.  Then enter the new value in the text box and click the "OK" button.

You can also choose the beginning and ending location in the selected file (in milliseconds) to be analyzed.  Initially, the starting and ending location of the entire file will be displayed.  If you make no change here, the entire file will be analyzed.  For a very large file, it may be necessary to select a smaller time interval for analysis in order not to exceed available RAM memory.

You also have a choice of 8 bit or 16 bit data resolution.  Pick the value which you know corresponds to the data file you are analyzing.  If you are loading a .wav file, the correct value will already be shown.  If this is a raw data file, 16 bit data will be assumed, but it is up to you to specify the correct value.


ANALYSIS PARAMETERS - FFT Selection

You have a choice of 512, 1024, or 2048 point FFTs for the frequency analysis.  The frequency resolution of your spectrogram will be the digital sampling rate divided by this FFT point size.  You should use 512 points routinely.  Use 1024 or 2048 point FFTs only for high resolution analysis.  The higher resolution FFTs require more time to compute the spectrogram.  For this reason it is sometimes preferable to decrease sampling rate when recording audio data if increased frequency resolution is needed, rather than to use a higher resolution FFT.


ANALYSIS PARAMETERS - FFT Window

Spectrogram provides both narrowband (NB) and broadband (BB) processing options.  Narrowband processing produces a high resolution display which resolves the individual harmonics of the audio sample.  Narrowband processing is the normal Spectrogram mode of operation.

For specialized analysis of speech formants a broadband processing mode is provided. The FFT window width can be reduced from the maximum value by filling a portion of the input data buffer with zeroes.  This technique broadens the frequency response of the FFT and produces a display which smooths over the individual harmonics to show broad areas of intensity.  The smaller the FFT window width the greater the output smoothing. The default broadband FFT window width is 8 ms, however you can choose the value which gives the best results for a particular combination of sampling rate and FFT selected.


ANALYSIS PARAMETERS - Time Scale Selection

You can also select a time scale in milliseconds which corresponds to the time interval between the calculation of each FFT.  To obtain greater time resolution in the spectrogram, choose a smaller value for the time scale.  Each vertical line in the spectrogram display represents the output of one FFT calculation.  The FFT data input window is stepped sequentially through the data, performing an FFT calculation at each step.  The time scale selected determines the length of the step between each FFT and thus the total width of the Spectrogram display.  The time scale can be assigned any value between 1 ms and 500 ms.  Experiment with these values to pick the time scale which best displays the audio signal of interest.


ANALYSIS PARAMETERS - Display Characteristics

You are given a choice of display attenuation in order to reduce clutter in noisy digital recordings.  Attenuation can be selected to be any value between 0 and 36 dB.  Use a threshold of 0 dB regularly, and select greater attenuation only if necessary to reduce clutter.

You also have a choice of four color palettes; color on a black background (CB), color on a gray background (CG), black on a white background (BW), and white on a black background (WB).  For a CB or CG display, red represents the strongest frequency components and dark blue the lowest.  For a BW display, darker black represents the strongest components, while for a WB display, brighter white represents the strongest components.


ANALYSIS PARAMETERS - Computing the Spectrogram

Once you are satisfied with the Analysis Parameters, click "OK" to begin processing and display of a spectrogram of the audio data file.  The program will step sequentially through the audio file, calculate an FFT at each step, and display the results in the Spectrogram window.  You can stop the process at any time by clicking the "Stop" button or pressing "Esc."


THE SPECTROGRAM DISPLAY

The spectrogram display reveals the digital signal as a frequency versus time plot with signal amplitude at each frequency represented by intensity (or color).  A continuous readout of cursor position in frequency (Hz) and time (milliseconds) is displayed at the bottom left of the window.  A coordinate grid can also be added by clicking the "Toggle Grid" button.

You can also use the mouse pointer to measure time and frequency differences on the spectrogram display.  Click and hold down the right mouse button to establish a reference point in frequency and time.  Then as you move the mouse, the differences in frequency and time at the mouse position will be displayed at the bottom left of the Spectrogram window.  Releasing the right mouse button returns the mouse cursor to normal operation.

The width of the spectrogram display is limited only by the display screen.  Maximizing the spectrogram window will expand the display horizontally to fill the screen.  If the spectrogram width is greater than screen width, you can use the horizontal scroll bar at the bottom of the display to position the spectrogram side-to-side.

The height of the spectrogram display is limited by the size of the FFT chosen for analysis.  Only 256 raster lines are needed for a 512 point FFT.  The 1024 and 2048 point FFTs require 512 and 1024 raster lines respectively.  Maximizing the spectrogram window will expand the display vertically to the size required by the FFT if not limited by the screen height.  If the spectrogram height is greater than the screen height, use the vertical scroll bar at right of the window to position the spectrogram top-to-bottom.

To maximize the Spectrogram window to fill the entire screen, select a 1024 point FFT and then maximize the Spectrogram window.  Only by selecting an FFT of 1024 points or greater will the display fill the entire screen.


MODIFYING SPECTROGRAMS

Once you have computed a spectrogram, you may want to make changes to its length, vertical or horizontal scale, threshold or color to improve the frequency analysis.  Choose "Parameters - Change" from the File Menu to bring up a dialog box to "Modify Analysis Parameters."  The parameters which can be changed here are identical to those used to define the original spectrogram.

Frequently you will want to select a portion of the spectrogram for modification rather than the entire length.  You can drag select this section from the spectrogram display.  Position the mouse pointer at the desired starting point, press the left mouse button and drag the mouse to the desired ending point and then release the mouse button.  The dialog box will then appear with the starting and ending locations filled according to your selection.

You can return to your starting spectrogram prior to any modification by choosing "Parameters - Restore" from the File menu.  The starting spectrogram display is established the first time you choose "Parameters - Change" after analyzing a new data file or recording a new sample.  You can return to the starting spectrogram again and again until you analyze a new data file or record a new sample.  Note that this function is not available if you have only 8MB of RAM memory.

You can change the palette of a completed spectrogram by choosing "Change" from the "Colors" menu.  A dialog box will give you the same color choices available in Display Characteristics.    Click the "Try It" button to preview your color selection.  Click the "OK" button to implement your selection and return to the Spectrogram.  Note that these controls are not available if you are operating with more than 256 colors.


SPECTROGRAM PLAYBACK

If you have a windows compatible sound card installed, you will also be able to play back the spectrogram by clicking the 'Play' or 'Play Wdw' buttons.  The Play button plays back the entire length of the .wav file, while the Play Wdw button plays back only that portion of the spectrogram which is visible in the Spectrogram Window.


DATA LOG

This program provides an automatic data logging capability for researchers who wish to record the time, frequency, and harmonic level of events in an audio file.  You can either save the dB signal level and time of individual points on the spectrogram, or you can save the amplitude and phase of every frequency component in the spectrum at a given point in time.  Choose “Log Data - Points” or “Log Data - Spectrum” from the file menu to make your selection.


DATA LOG - Points

To save the dB signal level and time of individual points, choose "Log Data - Points" from the File menu after computing a spectrogram. After you select a file name, a dialog box for recording of events will be presented.  Data is saved in a text file which records an event identifier (usually a letter of the alphabet), the frequency, the time, and the harmonic level in dB (20 log amplitude)at the selected event on the spectrogram.  Events to be recorded are defined by the researcher, and could be such things as signal start, signal stop, highest pitch, lowest pitch, highest level, or lowest level, etc.  Click the left mouse button on the event of interest on the spectrogram display, and the corresponding data log values will be computed and entered.  Enter an event identifier by clicking one of the buttons marked "a" through "h" or by typing an entry in the text box provided.  Click "Enter Data" to record the event to your data log file, and then move on to the next event and repeat the process.  Enter as many  events as needed, and then choose "Save/Exit" to close and save your data log file.  Opening an existing data log file will allow you to append data without starting a new file.


DATA LOG - Spectrum

To save the amplitude and phase of every frequency component, choose "Log Data - Spectrum" from the File menu after computing a spectrogram.  After you select a file name, a dialog box for recording of events will be presented.  Data is saved in a text file which records each FFT output point, frequency, amplitude (16 bit), and phase. Click the left mouse button on the event of interest on the spectrogram display, and the spectrum will be displayed in the dialog box.  Choose "Save/Exit" to close and save your data log file.


AUDIO RECORDING AND ANALYSIS

If you have a Windows compatible sound card installed you will be able to record and analyze an audio sample through a microphone or line input attached to your sound card.  Choose "Record Audio" from the File menu to initiate recording.  You will be presented with a file dialog box to select the filename of your recording, followed by a "Record Audio" dialog box to select Sample Characteristics and Display Characteristics.

Sample Characteristics include sample rate, sample resolution, and sample length.  If you choose a sample length of 10, 20, or 30 seconds, your sample will be both stored on disk and stored in RAM for immediate spectrum analysis.  You can also choose "Any" sample length for a sample which is limited only by the size of your hard drive.  In this case, the sample will be stored on your hard drive but not stored in RAM for immediate spectrum analysis.  To analyze this sample, you must process it separately using the Choose Analysis Parameters dialog.

Display Characteristics during recording include attenuation, palette and latency.  Display attenuation and palette controls are identical to those described under Display Characteristics.   Latency here is the length of time (in milliseconds) that it takes for your sound card to process a data sample and record it in memory.  If the latency value is set too low for your particular sound card, the spectrogram display during recording will be distorted and unusable.  A spectrogram display which shows a series of closely spaced vertical spikes probably has the latency value set too low.  Choose the lowest value of latency that produces an undistorted spectrogram display.  Most sound cards operate with a latency of less that 100 msec.  However, there are exceptions, and you should experiment with this value to obtain the best spectrogram display.  Also note that if the latency value is too large, there will be a noticeable delay between the occurrence of a sound event and its appearance on the spectrogram display.


SCANNING FILES OR AUDIO INPUT

Also with a Windows sound card, you can scan either audio files or microphone and line audio input to produce a real-time display of the frequency content of the audio signal. Choose "Scan File" or "Scan Audio" from the File menu.  A dialog box will be presented for selection of sample resolution (8 or 16 bit) and sample rate.

Choose "Scroll" for a scrolling spectrogram display or "Scope" for an audio spectrum analyzer scope display.  Scanning an audio signal does not save the audio data or display bitmap in RAM, so manipulation of the display parameters and replay is not possible.  However, scanning is not limited by the length of the audio sample and it provides a real-time capability not available when doing detailed analysis of the audio signal.

One purpose of the Scan File function is to allow the selection of smaller time intervals for analysis from within very large wave files.  If a wave file is too large to fit in RAM for detailed analysis, the file will automatically be scanned in real time until the "Stop" button is clicked.  A detailed spectrogram analysis will then be calculated at that point.  The "Scan File" dialog box gives you the option to enable or disable this detailed analysis at the scan file stop point.  Choose "Analysis On" or "Analysis Off" buttons from the "Analysis at Stop" group box.


SCANNING - Scrolling Spectrogram Display

Either audio input or recorded audio data files can be scanned using a scrolling spectrogram display.  Scrolling display characteristics for scanning files or audio input are the same as described under Audio Recording and Analysis. The scrolling spectrogram display uses a 512 point FFT in narrowband mode to produce a real-time scrolling display of harmonic structure as a function of time.  Scanning an audio signal does not save the audio data or display bitmap in RAM, so manipulation of the display parameters and replay is not possible.  However, scanning is not limited by the length of the audio sample and it provides a real-time capability not available when doing detailed analysis of the audio signal.


SCANNING - Spectrum Analyzer Scope Display

Either audio input or recorded audio data files can be scanned using a spectrum analyzer scope display.  The spectrum analyzer scope display uses a 512 point FFT in narrowband mode as an audio spectrum analyzer.  A real-time display of harmonic amplitude versus frequency, updated 20 times a second or more, is possible.  Scanning an audio signal does not save the audio data or display bitmap in RAM, so manipulation of the display parameters and replay is not possible.  However, scanning is not limited by the length of the audio sample and it provides a real-time capability not available when doing detailed analysis of the audio signal.


SAVING AUDIO AND BITMAP FILES

You can save a .wav file of the digital audio of your spectrogram by choosing "Save Wave" from the File Menu.  You can also save a bitmap of the Spectrogram Window by choosing "Save Bitmap" from the File Menu.  You can choose to save either the visible section of the display bitmap by choosing "Window Bitmap," or the entire display bitmap including area outside the display window by choosing "Entire Bitmap."


SIMULTANEOUS OPERATION

You can run the Spectrogram program multiple times simultaneously in order to compare different sound samples with each other.  However, only one program at a time can access the sound card.  This means that only one program at a time can record, playback, or scan audio data.


LIMITATIONS

With only 8MB of RAM, conservation of memory resources is necessary.  To save memory under these conditions, the "Parameters - Restore" function is not available on systems with 8MB of RAM.

If you are using 8MB of RAM and you encounter a severe slowing of the program or lengthy disk activity, the program requires more RAM than you have available and Windows is attempting to use the hard drive as virtual memory.  The only solution to this problem is to analyze only small sound samples of short duration, or to install more RAM.

Spectrogram runs best on systems using 256 colors.  Because the program must update the screen many times a second, the large bitmaps of true color screens will slow Spectrogram significantly.  So use 256 colors for the best performance.  Also, not all of the palette controls are available with more than 256 colors.

If you are using a colorful screen background bitmap, Spectrogram can change the background to odd looking colors while running.  This isn't a bug.  Spectrogram must take control of all bitmap color assignments in order to produce its own display.  Your background will be restored when Spectrogram is closed.

Any other programs running simultaneously can interfere with Spectrogram, particularly programs which access the hard drive while Spectrogram is scanning a file or recording to disk.  For best performance, shut down these other programs.

Don't expect to be able to scan wave files direct from a CD ROM drive.  Instead, copy any wave files to be scanned to your hard drive.  You can analyze any file from a CD ROM drive.  However, real-time scanning puts a heavy load on your computer and doesn't leave much time for data transfer from disk.  CD ROM drives are just not fast enough yet.  Of course, CD music disks can be scanned by connecting the audio output of your CD player to the input of your sound card and using the "Scan Audio" function.

Likewise, don't expect to be able to scan wave files direct from a floppy disk, or to record direct to a floppy disk.  You can analyze any file from a floppy disk, but real-time scanning or recording is not possible using floppy disks.

Please don't automatically record everything at 44kHz.  Lower sampling rates are often a better choice to produce high resolution spectrograms.


PROBLEM REPORTING

Programs can only be improved if users provide feedback to the author.  I can be reached at the following address for you to report any bugs or to provide comments or feedback.  I encourage anyone with a question or suggestion to contact me at rshorne@mnsinc.com.


DISTRIBUTION

Spectrogram is Copyright 1994 - 96 by Richard S. Horne and may be distributed as freeware as long as it is not modified in any way and as long as this Help File is included.