Loading and Playing Sounds and Music¶
The 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.
Loading a Sound¶
PT(AudioManager) AM = AudioManager::create_AudioManager(); PT(AudioSound) mySound = AM->get_sound("path/to/sound_file.ogg") ;
These will return an object of the type
AudioSound. It is necessary to
put the extension in the sound filename.
Playing/Stopping a Sound¶
To play sounds you can do the following:
To stop a sound:
Querying Sound Status¶
To check the status of a sound, call
status() returns a constant depending on the status of the
The sound is not working properly.
The sound is not currently playing and is ready to be played on command.
The sound is currently playing.
The volume can be set between 0 and 1 and will linearly scale between these.
Panning a Sound¶
You 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.