Defined in sound.h and sound.c
There are three groups of functions that provide sound support. The 'sample'
functions are for playing sounds from a .wav file, the 'stream' functions generate
simple sounds on the fly. The third group are the parameter functions for both.
Loads a .wav file into memory.
Returns the address of the sample.
Removes the specified sample out of memory. You should do this at the
end of your program for all samples loaded with ts_loadsample.
Starts playing the specified sample in the background (i.e. the function
gives control back to your program right away, it does not wait until the end of the sample).
Volume, pan, and whether the sample is looped or played only once are controlled by the
parameter functions below.
A program running with REALTIME priority will not play samples.
Returns the voice number that was allocated for the sample or negative if no voices were
available.
Alters the parameters of a sample while it is playing
(which is useful for manipulating looped sounds). Volume, pan and the loop flag can be
manipulated. Normally, changing parameter values does not influence a playing sample, so the
parameters have to be set before playing the sample. With this function you can impose the
parameter changes on a sample while it is playing.
Stops playing the specified sample.
Generates & plays a sound in the foreground (i.e. the
function does not give control back to your program before the sound has stopped playing).
After the specified time the sound stops and control goes back to your program.
The volume and pan of the sound are controlled by the parameter functions below.
The standard sound is a sine wave of 800Hz. The frequency of the wave can be changed with
ts_sinefreq. You can replace the sine wave with a sound generating function of your own.
In contrast to the sample functions, the sound functions also work in programs running with
REALTIME priority.
Same as ts_playstream,
but stops playing the sound if a response is given. Parameters and return value are the same as
other response registration functions.
Sets the volume of samples or sounds to be played. Accepts values between 0
and 255. Default is 255.
The values are on a linear scale, our ears' sensitivity is logarithmic. This means the
audible difference between values 1 and 2 will be about the same as the difference between 100
and 200.
The output volume also depends on your Windows's volume settings. If these are set to 0,
you will hear nothing, even if you set the ts_volume to its maximum. sndvol32.exe
controls the Windows sound volume (choose start menu - run, and type sndvol32 to open it). Both
'Volume control' and 'Wave' should be set to the maximum for optimal results.
The balance should be set to the center.
Returns the previous value.
Sets the pan of samples or sounds to be played. Accepts values between 0 (all
sound to the left) and 255 (all sound to the right). Default is 127 (centered).
The panning also depends on your Windows's balance settings. See the previous entry for
more information about setting the balance in Windows.
Returns the previous value.
Controls whether samples will be looped or played only once. Accepts ON and OFF
as argument. Returns the previous value.
Sets the frequency of the sine wave function. Default is 800. Maximum is
half of the samplerate (see below).
Returns the previous value.
Replace the sine function
with your own sound generating function.
Helper function that draws a graphical representation of the values
generated by the sound function currently in use.
Sets the size of the stream buffer used by the sound
streams. Default is 1024 bytes. Increase if there are cracks in the sound. Decrease if the
sound doesn't stop playing fast enough after a response or after the end of the playing
interval.
Returns the previous value.
Sets the number of samples per second. The samplerate
influences the sound quality (higher is better). The maximum sound frequency that can be
achieved is half of the samplerate. A rate of 44100 samples per second is cd quality, 11025 is
telephone quality. Default is 22050.
Returns the previous value.
Returns a pointer to the previous sound function.
Makes an audio stream using the current samplerate, streambuffer size,
volume and pan.
Returns the address of the newly created audio stream.
Removes the specified audio stream from memory. You should do this at the end of your
program for all streams created with ts_makestream.
Fills the buffer of the specified audio stream with values generated by the current sound
generating function.