Panda Project/Sound in Panda
From MCIS Wiki
Sound in panda3d uses a free sound libray called FMOD which is capable of playing wav,mp3,wma,midi etc files in panda.
Contents |
The code consists of the following:
To create a sound:
mySound1 = loader.loadSfx("SoundFile.wav")
You must have the file extension in the file name for this to work!
To play the sound
mySound1.play()
To stop the sound playing
mySound1.stop()
You can also loop a sound by adding the following code before calling mySound1.play()
mySound1.setLoop(True)
To set a number of loops to play.
mySound1.setLoopCount(n)
Where n is the number of loops 0 runs the loop for infinity.
The volume of the paticular sound relative to other sounds is set by calling. Values are from 0-1
mySound.setVolume(0.5)
You can also set the balance of the sound playing by calling the following where -1.0 is hard left, and 1.0 is hard right.
mySound.setBalance(-0.5)
getTime(), setTime() and length().
