SndDoImmediate
SndDoImmediate Send commands to an open and linked synthesize
#include <Sound.h> Sound Manager
SndChannelPtr chan; a pointer to a sound channel
SndCommand *cmd; specifies the sound command
returns Error Code; 0=no error
The SndDoImmediate function operates much like SndDoCommand, except
that it bypasses the existing command queue of the sound channel and sends the
specified command directly to the synthesizer. This routine also overrides any
waitCmd, pauseCmd, or syncCmd commands that may have already been
received by the synthesizer
chan a pointer to a sound channel
cmd is the specific sound to be played
Returns: an operating system Error Code.
noErr (0) No error
badChannel (-205) Channel is corrupt or unusable

Notes: Unlike SndDoCommand, SndDoImmediate loops indefinitely when you
pass it a freqDurationCmd command. To cause the sound to play for the
specified duration, send a quietCmd command into the channel.
The Table below lists the sound commands that you can send using
SndDoCommand, SndDoImmediate, or (in several cases) SndControl.
Table Sound commands
Command Description
ampCmd Changes the amplitude (or loudness) of a sound. If no
sound is currently playing, then ampCmd sets the
amplitude of the next sound to be played. The amplitude
is sent in param1 and should be an integer in the range
0 to 255. You can send ampCmd to any of the available
synthesizers.
param1 desired amplitude
param2 0 (ignored on input and output)
availableCmd Determines if the initialization parameters passed in
param2 are supported by the synthesizer to which
this command is sent. The result is returned in
param1; the result is 1 if the synthesizer supports
the desired characteristics and 0 if it does not. You can
send availableCmd to any of the available synthesizers,
but you must send it by using SndControl.
param1 0 on input; result of command on output
param2 initialization parameters
bufferCmd Plays a buffer of sampled sound data. If the high bit of
the command is set, param2 is interpreted as an offset
from the beginning of the 'snd ' resource containing the
command to the sound data. If the high bit is not set,
param2 is interpreted as a pointer to the sound data.
You can send bufferCmd only to the sampled sound
synthesizer.
param1 0 (ignored on input and output)
param2 offset or pointer to sound data
callBackCmd Executes the callback procedure specified as a
parameter to SndNewChannel. Both param1 and
param2 are application-specific; you can use these
two parameters to send data to your callback routine.
You can send callBackCmd to any of the available
synthesizers.
param1 application- defined
param2 application- defined
flushCmd Removes all commands currently queued in the
specified sound channel. A flushCmd command does not
affect any sound that is currently in progress. You can
send flushCmd to any of the available synthesizers, but
you should send it by using SndDoImmediate.
param1 0 (ignored on input and output)
param2 0 (ignored on input and output)
freqCmd Changes the frequency (or pitch) of a sound. If no
sound is currently playing, then freqCmd causes the
synthesizer linked to the specified channel to begin
playing indefinitely at the frequency specified in
param2. If, however, the channel is linked to the
wave-table or sampled sound synthesizer and no
instrument is installed in the channel, no sound is
produced. The param2 parameter must contain a value
in the range 0 to 127. The freqCmd command is
identical to the freqDurationCmd command, except that
no duration is specified to a freqCmd command. You can
send freqCmd to any of the available synthesizers.
param1 0 (ignored on input and output)
param2 desired frequency
freqDurationCmd Plays the frequency specified in param2 for the
duration specified in param1. The param2 parameter
must contain a value in the range 0 to 127. You can send
freqDurationCmd to any of the available synthesizers.
param1 duration in half-milliseconds (0 to
32,767)
param2 desired frequency
getAmpCmd Determines the current amplitude (or loudness) of a
sound. The amplitude is returned in an integer variable
whose address you pass in param2 and is in the range 0
to 255. You can send getAmpCmd to any of the available
synthesizers.
param1 0 (ignored on input and output)
param2 pointer to amplitude variable
getRateCmd Determines the sample rate of the sampled sound
currently playing. The current rate of the channel is
returned in a Fixed variable whose address you pass in
param2 of the sound command. You can send
getRateCmd only to the sampled sound synthesizer, but
you should send it by using SndDoImmediate.
param1 0 (ignored on input and output)
param2 pointer to rate variable
loadCmd Determines the CPU load factor that would be incurred
by a new channel of sound having the initialization
parameters specified in param2. The load factor
returned in param1 is the percentage of CPU processing
power that the specified sound channel would require.
You can send loadCmd to any of the available
synthesizers. You should send loadCmd using
param1 0 on input, load factor on output
param2 initialization options
nullCmd Does nothing. You can send nullCmd to any of the
available synthesizers.
param1 0 (ignored on input and output)
param2 0 (ignored on input and output)
pauseCmd Pauses any further command processing in a channel
until resumeCmd is received. You can send pauseCmd to
any of the available synthesizers.
param1 0 (ignored on input and output)
param2 0 (ignored on input and output)
quietCmd Stops the sound that is currently playing. You can send
quietCmd to any of the available synthesizers, but you
should send it by using SndDoImmediate.
param1 0 (ignored on input and output)
param2 0 (ignored on input and output)
rateCmd Sets the rate (or pitch) of a sampled sound that is
currently playing. The new pitch is set to the value
specified in param2. You can send rateCmd only to the
sampled sound synthesizer.
param1 0 (ignored on input and output)
param2 desired rate of sound
reInitCmd Resets the initialization parameters specified in
param2 for the specified channel. You can send
reInitCmd to any of the available synthesizers.
param1 0 (ignored on input and output)
param2 initialization options
restCmd Rests a channel for a specified duration. The duration
is specified in half-milliseconds in param1. You can
send restCmd to any of the available synthesizers.
param1 duration in half-milliseconds (0 to
32,767)
param2 0 (ignored on input and output)
resumeCmd Resumes command processing in a channel that was
previously paused by pauseCmd. You can send
resumeCmd to any of the available synthesizers.
param1 0 (ignored on input and output)
param2 0 (ignored on input and output)
soundCmd Installs a sampled sound as a voice in a channel. If the
high bit of the command is set, param2 is interpreted
as an offset from the beginning of the 'snd ' resource
containing the command to the sound data. If the high bit
is not set, param2 is interpreted as a pointer to the
sound data. You can send soundCmd only to the sampled
sound synthesizer.
param1 0 (ignored on input and output)
param2 offset or pointer to sound data
syncCmd Synchronizes multiple channels of sound. A syncCmd
command is held in the specified channel, suspending
all further command processing. The param2
parameter contains an identifier that is arbitrary. Each
time the Sound Manager receives syncCmd, it
decrements the count parameter for each channel
having that identifier. When the count for a specific
channel reaches 0, command processing in that channel
resumes. You can send syncCmd to any of the available
synthesizers.
param1 count
param2 identifier
timbreCmd Changes the timbre (or tone) of the sound currently
being played by the square-wave synthesizer. You can
send timbreCmd only to the square-wave synthesizer.
param1 desired timbre (0 to 255)
param2 0 (ignored on input and output)
totalLoadCmd Determines the total CPU load factor for all existing
sound activity and for a new sound channel having the
initialization options specified in param2. You can send
totalLoadCmd to any of the available synthesizers. You
should send totalLoadCmd using SndControl.
param1 0 on input, load factor on output
param2 initialization options
versionCmd Determines which version of the specified synthesizer
is available. The result is returned in param2. The
high word of the result indicates the major revision
number, and the low word indicates the minor revision
number. For example, version 2.0 of a synthesizer
would be returned as 0x00020000. You can send
versionCmd to any of the available synthesizers, but
you must send it by using SndControl.
param1 0 (ignored on input and output)
param2 0 on input; version of synthesizer on
output
waitCmd Suspends further command processing in a channel
until the specified duration has elapsed. You can send
waitCmd to any of the available synthesizers.
param1 duration in half-milliseconds (0 to
65,535)
param2 0 (ignored on input and output)
waveTableCmd Installs a wave table as a voice in the specified
channel. The param1 parameter specifies the length of
the wave table, and the param2 parameter is a pointer
to the wave-table data itself. You can send
waveTableCmd only to the wave-table synthesizer.
param1 length of wave table
param2 pointer to wave-table data