
Search

Support DFF
If you shop at Amazon anyway,
consider using this link. We receive a few cents from each purchase.
Thanks.
Support DFF
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.

Contact
Feedback:
Send an e-mail with your
comments about this program (or anything else).

|
| |
Problem Description
SoundGen generates complex wave forms and sends then to the PC sound card as
'.wav' formatted streams.
 |
 |
| Sine |
Trumpet? |
 |
 |
| Composite Sawtooth |
Composite Square |
Background & Techniques
Math and Engineering students sooner or later discover the Fourier Analysis miracle -
any stable waveform may be decomposed into a set of sine waves of appropriate
frequency, phase and amplitude. I recall working for hours to
convince myself that this could really be true. Similarly we may generate a
set of sine waves which, when summed will reproduce any waveform. So, for
example, if we start with a basic sine wave and then add another with twice the
frequency and half the amplitude and one with three times the frequency and 1/3
the amplitude, etc. the resulting waveform starts looking like a sawtooth
wave.
Here's a summary of the main features of the program:
 | Generate sounds with an arbitrary number of frequency components
and save them as '.snd' files. |
 | Each frequency component has a unique frequency, phase, amplitude and
wave shape. Normally you will be using Sine waves to build composite
sounds, but "Square", "Sawtooth" and
"Triangular" shapes are also available. |
 |
Sound files may be created, changed and deleted. Predefined sample definitions are provided for
 |
Composite Square Wave: Sum(1/N* sin(N*wt)) for all odd N. |
 |
Composite Sawtooth Wave: Sum(1/N* sin(N*wt)) for all N. |
 |
and a few others. |
|
 |
The frequency and amplitude of sounds may be scaled for playback using the
"Volume" and "Frequency" track bars. These affect the playback only and do not change the sound file definitions. |
 |
Left click on a sound name (the left-most list) to select a new sound. Right click to bring up a menu of available actions.
This list is initially populated with all sound files located in the same
folder as the SoundGen program. |
 |
For a selected sound, the right side list shows a list of the frequency
components of the sound.
 | Click to select a component, |
 | use Enter (or double click) to
modify, |
 | Press the Insert key to create a new component, or |
 | Delete key delete a selected components. |
 | Click the check box to included/exclude a particular component
from
the composite sound. |
|
 | A "Wave View" page displays a few cycles of the
currently generated waveform.
|
Notes for programmers:
 | Memory streams are used to hold one second's worth
of generated waveforms. The streams are played using the PlaySound
function from MMSystem unit. The SND_LOOP parameter
causes the sound to play continuously until stopped. |
 | Procedure MakeComplexSound does the bulk of the work in preparing
the formatted stream for PlaySound. |
 | A CheckBoxList is used to display frequency component information.
Clicking the checkbox will include or exclude that particular
components. There is a quirk that must be handled when using the
OnCheckClick exit - clicking the checkbox also triggers the OnClick
exit. I set a flag in OnCheckExit to indicate to OnClick the
type of click that occurred. |
Addendum October 8, 2005: I needed a "click" sound
today for a Metronome program. I decided to modify SoundGen to create
it. So we added a "duration" field which controls how
long the sound plays. Five milliseconds of almost any waveform will
produce a nice click sound, but triangle wave shapes sound best to me. I
also added a "Save as Wave file" button to save the files
created. The original version, and now sounds with duration set to
0, generate 1 second's worth of sound that play in a continuous
loop. When such files are saved as wave files, the one second's
worth is saved. Duration is now saved and reloaded for sound
definition files also.
Running/Exploring the Program
Suggestions for Further Explorations
| Created: November 11,2003 |
Modified: May 18, 2009
|
|