sf.Sound Class Reference
sf.Sound defines the properties of a sound such as position, volume, pitch, etc.
Default constructor : Sound()
Construct the sound from its parameters : Sound(Buffer, Loop = False, Pitch = 1., Volume = 100., X = 0., Y = 0., Z = 0.);
Buffer : Sound buffer to play (None by default)
Loop : Loop flag (False by default)
Pitch : Value of the pitch (1. by default)
Volume : Volume (100. by default)
X : X position (0. by default)
Y : Y position (0. by default)
Z : Z position (0. by default)
Copy constructor : Sound(Copy) where Copy is a sf.Sound instance.
Attributes
Paused
Playing
Stopped
Methods
GetAttenuation()
Get the attenuation factor.
GetBuffer()
Get the source buffer. Returns a new sf.SoundBuffer object.
GetLoop()
Tell whether or not the Sound is looping.
GetMinDistance()
Get the minimum distance.
GetPitch()
Get the sound pitch.
GetPlayingOffset()
Get the current playing position of the sound.
GetPosition()
Get the sound position in the world. Returns a tuple.
GetStatus()
Get the status of the sound (stopped, paused, playing).
GetVolume()
Get the sound volume.
IsRelativeToListener()
Tell if the sound's position is relative to the listener's position, or if it's absolute.
Pause()
Pause the sound.
Play()
Play the sound.
SetAttenuation(Attenuation)
Set the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener. The default attenuation factor 1.0.
Attenuation : New attenuation factor for the sound
SetBuffer(Buffer)
Set the source buffer.
Buffer : New sound buffer to bind to the sound
SetLoop(Loop)
Set the Sound loop state.
Loop : True to play in loop, false to play once
SetMinDistance(MinDistance)
Set the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume. The default minimum distance is 1.0.
MinDistance : New minimum distance for the sound
SetPitch(Pitch)
Set the sound pitch. The default pitch is 1.
Pitch : New pitch
SetPlayingOffset(TimeOffset)
Set the current playing position of the sound.
TimeOffset : New playing position, expressed in seconds
SetPosition(X, Y, Z)
Set the sound position in the world.
X,Y,Z : Position of the sound in the world
SetRelativeToListener(Relative)
Make the sound's position relative to the listener's position, or absolute. The default value is false (absolute)
Relative : True to set the position relative, false to set it absolute
SetVolume(Volume)
Set the sound volume.
Volume : Volume (in range [0, 100])
Stop()
Stop the sound.