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 || || color || cursors || sprite ||

## Channel

Channel objects represent a single channel of sound. Each channel can only playback one Sound object at a time. If your application only requires simply sound playback, you will usually not need to bother with the Channel objects, they exist for finer playback control.
Sound objects can be retrieved from the pygame.mixer module with functions like pygame.mixer.Channel() and pygame.mixer.find_channel(). Also, each time you call Sound.play() a Channel object will be returned, representing the channel that sound is playing on.

fadeout | - fade out the channel
get_busy | - query state of the channel
get_endevent | - get the endevent for a channel
get_queue | - get the currently queued sound object
get_sound | - get the currently playing sound object
get_volume | - query the volume for the
pause | - temporarily stop the channel
play | - play a sound on this channel
queue | - queue a sound on this channel
set_endevent | - set an endevent for a channel
set_volume | - set volume for channel
stop | - stop playing on the channel
unpause | - restart a paused channel

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

Fade out the playing sound and stops it over the given milliseconds.

get_busy
`Channel.get_busy() -> bool`

Returns true when there is a sound actively playing on this channel.

get_endevent
`Channel.get_endevent() -> event_type`

Returns the end event type for this Channel. If the return value is NOEVENT, then no events will be sent when playback ends.

get_queue
`Channel.get_queue() -> Sound`

Return the currently queued Sound object on this channel. This will return None if there is nothing queued.

get_sound
`Channel.get_sound() -> Sound`

Return the currently playing Sound object on this channel. This will return None if there is nothing playing.

get_volume
`Channel.get_volume() -> val`

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

pause
`Channel.pause() -> None`

Stops the sound that is playing on this channel, but it can be resumed with a call to unpause()

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

Starts playing a given sound on this channel. If the channels is currently playing a different sound, it will be replaced/restarted with the given sound. 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 totalmilliseconds that the sound will play. It defaults to forever (-1).

queue
`Channel.queue(Sound) -> None`

When you queue a sound on a channel, it will begin playing immediately when the current playing sound finishes. Each channel can only have a single Sound object queued. The queued sound will only play when the current Sound finishes naturally, not from another call to stop() or play().
If there is no currently playing sound on this Channel it will begin playback immediately.
This will only work with SDL_mixer greater than version 1.2.3

set_endevent
`Channel.set_endevent([event_type]) -> None`

When you set an endevent for a channel, that event type will be put on the pygame event queue everytime a sound stops playing on that channel. This is slightly different than the music object end event, because this will trigger an event anytime the music stops. If you call stop() or play() on the channel, it will fire an event. An event will also be fired when playback switches to a queued Sound.
Pass no argument to stop this channel from firing events

set_volume
`Channel.set_volume(val, [stereoval]) -> None`

Sets the volume for the channel. The channel's volume level is mixed with the volume for the active sound object. The value is between 0.0 and 1.0.
If mixer is using stereo, you can set the panning for audio by supplying a volume for the left and right channels. If SDL_mixer cannot set the panning, it will average the two volumes. Panning requires SDL_mixer-1.2.1.

stop
`Channel.stop() -> None`

Stops the sound that is playing on this channel.

unpause
`Channel.unpause() -> None`

Restarts a paused channel where it was paused.