panda3d.core.AudioSound

from panda3d.core import AudioSound
class AudioSound

Bases: TypedReferenceCount

Inheritance diagram

Inheritance diagram of AudioSound

play() → None

For best compatibility, set the loop_count, volume, and balance, prior to calling play(). You may set them while they’re playing, but it’s implementation specific whether you get the results. - Calling play() a second time on the same sound before it is finished will start the sound again (creating a skipping or stuttering effect).

stop() → None
setLoop(loop: bool) → None

loop: false = play once; true = play forever. inits to false.

getLoop() → bool
setLoopCount(loop_count: int) → None

loop_count: 0 = forever; 1 = play once; n = play n times. inits to 1.

getLoopCount() → int
setTime(start_time: float) → None

Control time position within the sound, in seconds. This is similar (in concept) to the seek position within a file. The value starts at 0.0 (the default) and ends at the value given by the length() method.

The current time position will not change while the sound is playing; you must call play() again to effect the change. To play the same sound from a time offset a second time, explicitly set the time position again. When looping, the second and later loops will start from the beginning of the sound.

If a sound is playing, calling getTime() repeatedly will return different results over time. e.g.

PN_stdfloat percent_complete = s.get_time() / s.length();
getTime() → float
setVolume(volume: float) → None

0 = minimum; 1.0 = maximum. inits to 1.0.

getVolume() → float
setBalance(balance_right: float) → None

-1.0 is hard left 0.0 is centered 1.0 is hard right inits to 0.0.

getBalance() → float
setPlayRate(play_rate: float) → None

play_rate is any positive PN_stdfloat value. inits to 1.0.

getPlayRate() → float
setActive(flag: bool) → None

inits to manager’s state.

getActive() → bool
setFinishedEvent(event: str) → None

Set (or clear) the event that will be thrown when the sound finishes playing. To clear the event, pass an empty string.

getFinishedEvent() → str
getName() → str

There is no set_name(), this is intentional.

length() → float

return: playing time in seconds.

set3dAttributes(px: float, py: float, pz: float, vx: float, vy: float, vz: float) → None

Controls the position of this sound’s emitter. px, py and pz are the emitter’s position. vx, vy and vz are the emitter’s velocity in UNITS PER SECOND (default: meters).

set3dMinDistance(dist: float) → None

Controls the distance (in units) that this sound begins to fall off. Also affects the rate it falls off. Default is 1.0 CloserFaster, <1.0 FartherSlower, >1.0

get3dMinDistance() → float
set3dMaxDistance(dist: float) → None

Controls the maximum distance (in units) that this sound stops falling off. The sound does not stop at that point, it just doesn’t get any quieter. You should rarely need to adjust this. Default is 1000000000.0

get3dMaxDistance() → float
getSpeakerMix(speaker: int) → float

*_speaker_mix and *_speaker_level(s) serve the same purpose. *_speaker_mix is for use with FMOD. *_speaker_level(s) is for use with Miles. Both interfaces exist because of a significant difference in the two APIs. Hopefully the difference can be reconciled into a single interface at some point.

setSpeakerMix(frontleft: float, frontright: float, center: float, sub: float, backleft: float, backright: float, sideleft: float, sideright: float) → None
getSpeakerLevel(index: int) → float
setSpeakerLevels(level1: float, level2: float, level3: float, level4: float, level5: float, level6: float, level7: float, level8: float, level9: float) → None
getPriority() → int
setPriority(priority: int) → None
configureFilters(config: FilterProperties) → bool
status() → SoundStatus
Return type

SoundStatus

output(out: ostream) → None
write(out: ostream) → None
static getClassType() → TypeHandle
Return type

TypeHandle

enum SoundStatus
enumerator BAD = 0
enumerator READY = 1
enumerator PLAYING = 2