pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || display || draw || event || || font || image || joystick || key || mixer || mixer_music || || mouse || movie || sndarray || surfarray || time || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Rect || Sound || Surface || || cursors || sprite ||

## Sound

Sound objects represent actual sound data. Sound objects are created from the function pygame.mixer.Sound(). Sound objects can be playing on multiple channels simultaneously. Calling functions like Sound.stop() from the sound objects will effect all channels playing that Sound object.
All sound objects have the same frequency and format as the pygame.mixer module's initialization.

fadeout | - fadeout all channels playing this sound
get_num_channels | - number of channels with sound
get_volume | - query volume for sound
play | - play sound
set_volume | - change volume for sound
stop | - stop all channels playing this sound

fadeout
`Sound.fadeout(millisec) -> None`

Fade out all the playing channels playing this sound over the. All channels playing this sound will be stopped after the given milliseconds.

get_num_channels
`Sound.get_num_channels() -> int`

Returns the number of channels that have been using this sound. The channels may have already finished, but have not started playing any other sounds.

get_volume
`Sound.get_volume() -> val`

Returns the current volume for this sound object. The value is 0.0 to 1.0.

play
`Sound.play([loops, [maxtime]]) -> Channel`

Starts playing a song on an available channel. If no channels are available, it will not play and return None. Loops controls how many extra times the sound will play, a negative loop will play indefinitely, it defaults to 0. Maxtime is the number of total milliseconds that the sound will play. It defaults to forever (-1).
Returns a channel object for the channel that is selected to play the sound.

set_volume
`Sound.set_volume(val) -> None`

Set the play volume for this sound. This will effect any channels currently playing this sound, along with all subsequent calls to play. The value is 0.0 to 1.0.

stop
`Sound.stop() -> None`

This will instantly stop all channels playing this sound.