Panda3D Manual: Loading and Playing Sounds and Music
ArchitectureThe implementation of the sound system in Panda3d allows for a division of audio into two categories - Sound Effects and Music. This division is only a convenience for programmers as Panda3d allows these two audio groups to be treated individually. These differences are explained on the next page. BasicsLoading a Sound
Loading sound is done through the base = ShowBase()
These will return an object of the type
Playing/Stopping a SoundTo play sounds you can do the following:
mySound.play()
To stop a sound:
mySound.stop()
Querying Sound StatusTo check the status of a sound, call
status = mySound.status()
Example usage of this would be to stop a sound from playing only if it's currently playing.
if mySound.status() == mySound.PLAYING:
Setting VolumeThe volume can be set between 0 and 1 and will linearly scale between these.
mySound.setVolume(0.5)
Panning a SoundYou can change the balance of a sound. The range is between -1.0 to 1.0. Hard left is -1.0 and hard right is 1.0.
mySound.setBalance(-0.5)
Extra Note[python]
If Panda3D is running from an interactive prompt,
base.sfxManagerList[n].update() This is because the In interactive mode, Panda3D's frame update is suspended and does not run automatically. © Carnegie Mellon University 2010 |