Panda3D Manual: Manipulating Sounds
Looping a SoundTo cause a sound to loop (i.e., cause it to repeat once it is finished playing) do the following:
mySound->set_loop(True); To stop a sound from looping pass False in the set_loopfunction.
mySound->set_loop(False);
Sounds can also be looped for a certain number of times:
mySound->set_loop_count(n);
Where 'n' can be any positive integer. 0 will cause a sound to loop forever. 1 will cause a sound to play only once. >1 will cause a sound to loop that many times. NOTE Setting a sound's loop count will automatically set a sound's loop flag to 0 or >1 will automatically Notes on Looping Sounds SeamlesslyLooping a sound seamlessly should be as simple as loading the sound, then calling
So the easiest way to get a reliable looping sound is to use wav files, and to use Cueing TimeThere are
mySound->length();
will return the length of a sound file in seconds.
mySound->get_time();
will get the current time the 'playback head' of a sound is at in seconds.
mySound->set_time(n);
will set the 'playhead head' of a sound to n (where is seconds). NOTE Sounds will start playing IMMEDIATELY after the command is issued, and calling Changing Playback SpeedTo change a sound's playback speed, use:
mySound->set_play_rate(n);
Where Negative numbers will play a sound backwards. Passing the value 0 will pause the sound. You can also get a sound's play rate with:
mySound->get_play_rate();
© Carnegie Mellon University 2010 |