SweepGen - An Audio Sweep Generator - David J Taylor
SweepGen turns a PC into an Audio Oscillator and Sweep Generator which
can be used for testing audio or educational purposes. In conjunction
with audio test instruments, you can make frequency response plots.
SweepGen uses the sound card in your PC to produce sinewaves that are
mathematically correct almost to CD quality, indeed it's more likely
that the quality of your PC sound card will be the limiting factor
rather than the code in SweepGen. If you are interested in programming
the sound hardware at a low level under Windows, you may find SweepGen's
source code helpful in understanding the programming techniques
involved.
Installation & Usage:
Extract SweepGen.exe from the Zip file to a suitable location, and run
it! To use the pink noise facility also requires the file pink.wav in
the same folder as SweepGen.exe. SweepGen uses no other DLLs, or
registry entries. You will be presented with a dialog box that is, I
hope, self-explantory. The program source, and some extra HTML
documentation are provided in other Zip files in the archive.
Operating modes:
SweepGen has six operating modes: fixed frequency (with no sweep),
manual sweep, white and pink noise, a slow single sweep lasting about
45 seconds intended for recording onto tape for subsequent replay and
analysis, and a fast sweep lasting about 0.75 seconds intended for use
with an oscilloscope for direct analysis of a circuit or to show the
effect of any tone controls on your audio board.
The fixed frequency and noise modes produce a continuous output, with
the noise actually being a sound lasting about 1.3 seconds that is
repeated indefinitely, giving the impression of continuous noise. White
noise has a uniform distribution of energy across the frequency range,
whereas the pink noise decays uniformly at 3dB per octave, and therefore
sounds more muffled.
In the slow sweep mode, there is an option to momentarily mute the
output around half-octave boundaries (e.g. from 255 to 257 Hz) so that
you can determine the approximate frequency of any peak or trough
without having to continually monitor the display. The frequency of
the last marker is noted.
In the fast sweep mode, there is a choice between a continuous or
stepped change of frequency, the steps allowing easier discrimination
on the 'scope. Also, there is a 3:1 duty cycle to allow the 'scope to
retrace and retrigger.
In both sweep modes, the sweep may be linear or logarithmic in
frequency, with log being more suitable for examining a broad frequency
response and linear more suitable for narrow band filters.
In manual sweep mode there are two methods to alter the frequency.
Method 1. Ensure that the Stop/Start button has the focus, and then
use the Page Down and Page Up keys to control the direction and
activation of the sweep. Because of the double-buffering used to keep
the sound card busy, there will be a slight delay between releasing
either key and the sweep stopping. Starting and stopping the generator
with the Start/Stop button will ensure that it has the focus. This
method suits someone who wishes to hold down a key for continuous,
smooth frequency change.
Method 2. Ensure the trackbar (slider-like control) has the focus.
You can then either drag the slider, or use the Page Down/Page Up, or
Down Arrow and Up Arrow keys to change frequency. This method is
quicker if you wish to manually sweep a frequncy range looking for
resonances. Because the TrackBar control can queue up several key
presses to process at one time, you must "peck" at the keys for each
change of frequency rather than holding them down continuously.
With method 2, you can also uncheck the "Lock L + R frequencies"
checkbox to obtain independent frequency control.
Frequency ranges:
You can program any frequency range you want into Sweep, but if you make
the maximum less than the minimum, you'll only get one frequency! There
is no check against programming a frequency in excess of 22.05KHz, so
you can observe the effects of aliasing.
For convenience, there are four preset frequency ranges called:
wide: 20Hz .. 20KHz hf: 1KHz .. 15KHz
speech: 300Hz .. 3KHz lf: 50Hz .. 1KHz
Output levels:
SweepGen has a choice of fixed output levels selectable from 0dB to
-26dB in 1dB steps. There will be a brief delay between selecting a new
output level and the actual output changing since, the internal sinewave
lookup table has to be recomputed, the output buffers refilled, and sent
to the Wave device. There is also a deliberate delay to avoid many
quick changes being processed since this is aurally rather distracting.
Output phase:
There are three modes of output operation. Normally, both left and
right channels are indentical, i.e. in-phase. Optionally, you can make
the channels out-of-phase which can be useful for checking the relative
phase of a pair of loudspeakers. If the two speakers are out of phase,
there will be less bass output. The channels option allows you to hear
this effect directly. The third output mode provides for independent
control of channel amplitude. The program does not provide a
mono-summed mode where two different frequencies at different
amplitudes are fed equally to each channel.
Release History:
V2.0.0 1996 Jun 01 Version for 32-bit Delphi
Add more output levels
Allow for smooth or stepped fast sweep
Improve generation to about 15-bit accuracy
Release to public domain
V2.0.2 1996 Dec 30 Add white noise option
V2.0.4 1997 Jan 10 Add manual slow sweep controlled by PageUp & PageDown keys
(Start button must have the focus)
Add two more output levels
Add octave markers
V2.0.6 1997 Mar 09 Add TrackBar for manual frequency control
Reversed interpretation of PageUp & PageDown keys
V2.1.0 1997 May 03 Replace output level buttons by slider control
Use 2-channel output buffer for all modes
Allow independent Left and Right frequencies
Allow in-phase, out-of-phase or independent channel levels
Add HTML documentation
V2.2.0 1997 May 31 Version for Delphi 3.0
Make sine table generator use symmetry for faster startup
Change max_buffer_samples to allow 1.3 seconds of audio
- this allows exactly 50ms per fast sweep segment
Correct two truncated buffer writes at end of slow sweep
Use array of pre-computed frequencies for slow sweep
Add programmed sweep mode (experimental)
Add ability to save sweeps as a file
V2.2.2 1997 Oct 05 Version for Delphi 3.01
Don't progress programmed mode
Add Pink noise mode
Notes:
The program is written for Borland's Delphi 3.01, and most source is
included. You do not need access to Delphi 3.01 to run SweepGen, but
you WILL need sound hardware on your PC capable of full CD sampling rate
operation (i.e. 16-bit, mono, 44.1KHz - such as SoundBlaster 16 or
later). If SweepGen cannot open that audio format it will complain.
I have seen some cards sold as 16-bit that only actually offer 12-bit
performance. The program runs on Windows 95 and Windows NT 4.0.
To measure your sound card itself, you may also find it helpful to have
a CD with a white-noise or frequency sweep source. Two I have
discovered are:
Denon, Audio Technical CD 38C39-7147, 1984-5
(includes white noise, but perhaps not now available?)