174
Chapter 15: Adding Sounds To Virtual Worlds
Example 15-1 sets all of the fields in a csAudioSamples node.
Example 15-1 Setting the Fields in a csAudioClip Object
// create a csAudioClip object
csAudioClip* clip = new csAudioClip();
// attach the audio clip to a csAudioSamples object
clip->setSamples(csAudioSamples truck_horn);
// Set the parameters of the csAudioClip object
clip->setPitch(1.0);
clip->setIntensity(1.0);
clip->setMaxIntensity(4.0);
clip->setLoop(TRUE);
clip->setDescription(“Truck horn”);
Specifying Audio Files
You use the csAudioSamples node to specify the source of the audio files and a variety
of parameters that describe those sound samples. To use the audio files specified by this
node, pass a csAudioSamples object as the argument to csAudioClip::setSamples(), for
example,
csAudioSamples* truck_horn_file = new csAudioSamples;
csAudioClip* truck_horn_style = new csAudioClip;
truck_horn_style->setSamples(truck_horn_file);
In this example, the truck_horn_file is used as the audio file for the truck_horn_style object.
getDuration Returns the duration of the playing of the sound source; subtracts
setStartTime from setStopTime.
getIsActive Returns whether or not the sound should be played.
Table 15-1 (continued) csAudioClip Fields
Field Description