<html> <title>Channel</title> <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111> <table cellspacing=3 width=100%><tr><td bgcolor=#00000> <table width=100%><tr><td bgcolor=c2fc20 align=center> <a href=http://www.pygame.org> <img src=../pygame_tiny.gif border=0 width=200 height=60></a><br> <b>pygame documentation</b> </td><td bgcolor=6aee28 align=center valign=top width=100%> || <a href=http://www.pygame.org>Home</a> || <a href=../index.html>Help Contents</a> || <br> <br> || <a href=pygame.html>pygame</a> || <a href=pygame_cdrom.html>cdrom</a> || <a href=pygame_constants.html>constants</a> || <a href=pygame_display.html>display</a> || <a href=pygame_draw.html>draw</a> || <a href=pygame_event.html>event</a> ||<br> || <a href=pygame_font.html>font</a> || <a href=pygame_image.html>image</a> || <a href=pygame_joystick.html>joystick</a> || <a href=pygame_key.html>key</a> || <a href=pygame_mixer.html>mixer</a> || <a href=pygame_mixer_music.html>mixer_music</a> ||<br> || <a href=pygame_mouse.html>mouse</a> || <a href=pygame_movie.html>movie</a> || <a href=pygame_sndarray.html>sndarray</a> || <a href=pygame_surfarray.html>surfarray</a> || <a href=pygame_time.html>time</a> || <a href=pygame_transform.html>transform</a> ||<br> <br>|| <a href=CD.html>CD</a> || <a href=Channel.html>Channel</a> || <a href=Clock.html>Clock</a> || <a href=Font.html>Font</a> || <a href=Joystick.html>Joystick</a> || <a href=Movie.html>Movie</a> ||<br> || <a href=Rect.html>Rect</a> || <a href=Sound.html>Sound</a> || <a href=Surface.html>Surface</a> ||<br> <br>|| <a href=pygame_cursors.html>cursors</a> || <a href=pygame_sprite.html>sprite</a> ||<br> </td></tr></table></td></tr></table> <br> <h2 align=center>Channel</h2> 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. <br> <br> Sound objects can be retrieved from the pygame.mixer module with functions like <a href=pygame_mixer.html#Channel>pygame.mixer.Channel()</a> and <a href=pygame_mixer.html#find_channel>pygame.mixer.find_channel()</a>. Also, each time you call <a href=Sound.html#play>Sound.play()</a> a Channel object will be returned, representing the channel that sound is playing on. <hr> <table> <tr><td><a href=#fadeout>fadeout</a></td><td> - fade out the channel</td></tr> <tr><td><a href=#get_busy>get_busy</a></td><td> - query state of the channel</td></tr> <tr><td><a href=#get_endevent>get_endevent</a></td><td> - get the endevent for a channel</td></tr> <tr><td><a href=#get_queue>get_queue</a></td><td> - get the currently queued sound object</td></tr> <tr><td><a href=#get_sound>get_sound</a></td><td> - get the currently playing sound object</td></tr> <tr><td><a href=#get_volume>get_volume</a></td><td> - query the volume for the</td></tr> <tr><td><a href=#pause>pause</a></td><td> - temporarily stop the channel</td></tr> <tr><td><a href=#play>play</a></td><td> - play a sound on this channel</td></tr> <tr><td><a href=#queue>queue</a></td><td> - queue a sound on this channel</td></tr> <tr><td><a href=#set_endevent>set_endevent</a></td><td> - set an endevent for a channel</td></tr> <tr><td><a href=#set_volume>set_volume</a></td><td> - set volume for channel</td></tr> <tr><td><a href=#stop>stop</a></td><td> - stop playing on the channel</td></tr> <tr><td><a href=#unpause>unpause</a></td><td> - restart a paused channel</td></tr> </table> <hr> <a name=fadeout><font size=+2><b>fadeout </b></font><br><font size=+1><tt> Channel.fadeout(millisec) -> None </tt></font><ul> Fade out the playing sound and stops it over the given milliseconds. </ul><br> <br> <a name=get_busy><font size=+2><b>get_busy </b></font><br><font size=+1><tt> Channel.get_busy() -> bool </tt></font><ul> Returns true when there is a sound actively playing on this channel. </ul><br> <br> <a name=get_endevent><font size=+2><b>get_endevent </b></font><br><font size=+1><tt> Channel.get_endevent() -> event_type </tt></font><ul> Returns the end event type for this Channel. If the return value is NOEVENT, then no events will be sent when playback ends. </ul><br> <br> <a name=get_queue><font size=+2><b>get_queue </b></font><br><font size=+1><tt> Channel.get_queue() -> Sound </tt></font><ul> Return the currently queued Sound object on this channel. This will return None if there is nothing queued. </ul><br> <br> <a name=get_sound><font size=+2><b>get_sound </b></font><br><font size=+1><tt> Channel.get_sound() -> Sound </tt></font><ul> Return the currently playing Sound object on this channel. This will return None if there is nothing playing. </ul><br> <br> <a name=get_volume><font size=+2><b>get_volume </b></font><br><font size=+1><tt> Channel.get_volume() -> val </tt></font><ul> Returns the current volume for this sound object. The value is between 0.0 and 1.0. </ul><br> <br> <a name=pause><font size=+2><b>pause </b></font><br><font size=+1><tt> Channel.pause() -> None </tt></font><ul> Stops the sound that is playing on this channel, but it can be resumed with a call to <a href=#unpause>unpause()</a> </ul><br> <br> <a name=play><font size=+2><b>play </b></font><br><font size=+1><tt> Channel.play(Sound, [loops, [maxtime]]) -> None </tt></font><ul> 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). </ul><br> <br> <a name=queue><font size=+2><b>queue </b></font><br><font size=+1><tt> Channel.queue(Sound) -> None </tt></font><ul> 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 <a href=Sound.html#stop>stop()</a> or <a href=Sound.html#play>play()</a>. <br> <br> If there is no currently playing sound on this Channel it will begin playback immediately. <br> <br> This will only work with SDL_mixer greater than version 1.2.3 </ul><br> <br> <a name=set_endevent><font size=+2><b>set_endevent </b></font><br><font size=+1><tt> Channel.set_endevent([event_type]) -> None </tt></font><ul> 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 <a href=Sound.html#stop>stop()</a> or <a href=Sound.html#play>play()</a> on the channel, it will fire an event. An event will also be fired when playback switches to a queued Sound. <br> <br> Pass no argument to stop this channel from firing events </ul><br> <br> <a name=set_volume><font size=+2><b>set_volume </b></font><br><font size=+1><tt> Channel.set_volume(val, [stereoval]) -> None </tt></font><ul> 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. <br> <br> 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. </ul><br> <br> <a name=stop><font size=+2><b>stop </b></font><br><font size=+1><tt> Channel.stop() -> None </tt></font><ul> Stops the sound that is playing on this channel. </ul><br> <br> <a name=unpause><font size=+2><b>unpause </b></font><br><font size=+1><tt> Channel.unpause() -> None </tt></font><ul> Restarts a paused channel where it was paused. </ul><br> <br> <hr> </body></html>