How to Play a Sound File
173
How to Play a Sound File
You use csAudioClip to specify how to play the sound files referenced in the
csAudioSamples node.
csAudioClip contains the following fields:
csMFString* url() const;
void setSamples(csAudioSamples* samples);
void setPitch(csFloat pitch);
void setStartTime(csTime startTime);
void setStopTime(csTime stopTime);
void setDoppler(csBool doppler);
void setLoop(csBool loop);
void setDescription(const csString& description);
csTime getDuration();
csBool getIsActive();
These set() fields have corresponding get() fields. Table 15-1 describes how these fields
are used.
Table 15-1 csAudioClip Fields
Field Description
url Specifies a WWW URL where the sound source file can be found.
setSamples Attaches the csAudioClip object to a csAudioSamples object.
setPitch Adjusts the pitch of a sound sample.
setStartTime Specifies a beginning time for the sound sample to begin playing. Time here
is an expression of clock time.
setStopTime Specifies an ending time for the sound sample to stop playing. Time here is
an expression of clock time.
setDoppler Enables the doppler effect, which is the attenuation of a sounds pitch based
on the velocity of the sound source relative to the listener, for example, when
a sound source, like a train whistle, approaches a listener rapidly, the pitch
sounds higher; when the same sound source passes the listener, the pitch
lowers.
setLoop Allows a sound file to keep playing.
setDescription Provides a description in the node of the sound source.