3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
8 <li><a href="#METHODS">METHODS</a>
9 <ul><li><a href="#allocate_channels">allocate_channels</a></li>
10 <li><a href="#volume">volume</a></li>
11 <li><a href="#play_channel">play_channel</a></li>
12 <li><a href="#play_channel_timed">play_channel_timed</a></li>
13 <li><a href="#fade_in_channel">fade_in_channel</a></li>
14 <li><a href="#fade_in_channel_timed">fade_in_channel_timed</a></li>
15 <li><a href="#pause">pause</a></li>
16 <li><a href="#resume">resume</a></li>
17 <li><a href="#halt_channel">halt_channel</a></li>
18 <li><a href="#expire_channel">expire_channel</a></li>
19 <li><a href="#fade_out_channel">fade_out_channel</a></li>
20 <li><a href="#channel_finished">channel_finished</a></li>
21 <li><a href="#playing">playing</a></li>
22 <li><a href="#paused">paused</a></li>
23 <li><a href="#fading_channel">fading_channel</a></li>
24 <li><a href="#get_chunk">get_chunk</a></li>
27 <li><a href="#AUTHORS">AUTHORS</a>
32 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
33 <div id="NAME_CONTENT">
34 <p>SDL::Mixer::Channels -- SDL::Mixer channel functions and bindings</p>
37 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
38 <div id="CATEGORY_CONTENT">
42 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
43 <div id="DESCRIPTION_CONTENT">
46 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
47 <div id="METHODS_CONTENT">
50 <h2 id="allocate_channels">allocate_channels</h2>
51 <div id="allocate_channels_CONTENT">
52 <pre> my $ret = SDL::Mixer::Channels::allocate_channels( $number_of_channels );
55 <p>Dynamically change the number of channels managed by the mixer. If decreasing the number of channels, the upper channels arestopped.
56 This function returns the new number of allocated channels.</p>
58 <pre> use SDL::Mixer::Channels;
60 printf("We got %d channels!\n", SDL::Mixer::Channels::allocate_channels( 8 ) );
65 <h2 id="volume">volume</h2>
66 <div id="volume_CONTENT">
67 <pre> my $prev_volume = SDL::Mixer::Channels::volume( $channel_number, $volume );
70 <p><code>volume</code> changes the volume of the channel specified in channel by the amount set in volume. The range of volume is from 0 to <code>MIX_MAX_VOLUME</code>
71 which is <code>128</code>. Passing <code>-1</code> to channel will change the volume of all channels. If the specified volume is <code>-1</code>, it will just return the
73 <p>Returns the previously set volume of the channel.</p>
76 <h2 id="play_channel">play_channel</h2>
77 <div id="play_channel_CONTENT">
78 <pre> my $channel_number = SDL::Mixer::Channels::play_channel( $channel, $chunk, $loops );
81 <p><code>play_channel</code> will play the specified <code>chunk</code> over the specified <code>channel</code>. SDL_mixer will choose a channel for you if you pass <code>-1</code> for
82 <code>channel</code>.</p>
83 <p>The chunk will be looped <code>loops</code> times, the total number of times played will be <code>loops+1</code>. Passing <code>-1</code> will loop the chunk infinitely. </p>
84 <p>Returns the channel the chunk will be played on, or <code>-1</code> on error.</p>
87 use SDL::Mixer::Channels;
88 use SDL::Mixer::Samples;
90 SDL::init(SDL_INIT_AUDIO);
91 SDL::Mixer::open_audio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 );
93 my $chunk = SDL::Mixer::Samples::load_WAV('sample.wav');
95 SDL::Mixer::Channels::play_channel( -1, $chunk, -1 );
98 SDL::Mixer::close_audio();
103 <h2 id="play_channel_timed">play_channel_timed</h2>
104 <div id="play_channel_timed_CONTENT">
105 <pre> my $channel = SDL::Mixer::Channels::play_channel_timed( $channel, $chunk, $loops, $ticks );
108 <p>Same as <a href="http://search.cpan.org/perldoc?play_channel">play_channel</a> but you can specify the time it will play by <code>$ticks</code>.</p>
111 <h2 id="fade_in_channel">fade_in_channel</h2>
112 <div id="fade_in_channel_CONTENT">
113 <pre> my $channel = SDL::Mixer::Channels::fade_in_channel( $channel, $chunk, $loops, $ms );
116 <p>Same as <a href="http://search.cpan.org/perldoc?play_channel">play_channel</a> but you can specify the fade-in time by <code>$ms</code>.</p>
119 <h2 id="fade_in_channel_timed">fade_in_channel_timed</h2>
120 <div id="fade_in_channel_timed_CONTENT">
121 <pre> my $channel = SDL::Mixer::Channels::fade_in_channel_timed( $channel, $chunk, $loops, $ms, $ticks );
124 <p>Same as <a href="http://search.cpan.org/perldoc?fade_in_channel">fade_in_channel</a> but you can specify the time how long the chunk will be played by <code>$ticks</code>.</p>
127 <h2 id="pause">pause</h2>
128 <div id="pause_CONTENT">
129 <pre> SDL::Mixer::Channels::pause( $channel );
132 <p>Pauses the given channel or all by passing <code>-1</code>.</p>
135 <h2 id="resume">resume</h2>
136 <div id="resume_CONTENT">
137 <pre> SDL::Mixer::Channels::resume( $channel );
140 <p>Resumes the given channel or all by passing <code>-1</code>.</p>
143 <h2 id="halt_channel">halt_channel</h2>
144 <div id="halt_channel_CONTENT">
145 <pre> SDL::Mixer::Channels::halt_channel( $channel );
148 <p>Stops the given channel or all by passing <code>-1</code>.</p>
151 <h2 id="expire_channel">expire_channel</h2>
152 <div id="expire_channel_CONTENT">
153 <pre> my $channels = SDL::Mixer::Channels::expire_channel( $channel, $ticks );
156 <p>Stops the given channel (or <code>-1</code> for all) after the time specified by <code>$ticks</code> (in milliseconds).</p>
157 <p>Returns the number of affected channels.</p>
160 <h2 id="fade_out_channel">fade_out_channel</h2>
161 <div id="fade_out_channel_CONTENT">
162 <pre> my $fading_channels = SDL::Mixer::Channels::fade_out_channel( $which, $ms );
165 <p><code>fade_out_channel</code> fades out a channel specified in <code>which</code> with a duration specified in <code>ms</code> in milliseconds.</p>
166 <p>Returns the the number of channels that will be faded out.</p>
169 <h2 id="channel_finished">channel_finished</h2>
170 <div id="channel_finished_CONTENT">
171 <pre> SDL::Mixer::Channels::channel_finished( $callback );
174 <p>Add your own callback when a channel has finished playing. <code>NULL</code> to disable callback. The callback may be called from the mixer's audio
175 callback or it could be called as a result of <a href="http://search.cpan.org/perldoc?halt_channel">halt_channel</a>, etc. do not call <code>lock_audio</code> from this callback; you will either be inside
176 the audio callback, or SDL_mixer will explicitly lock the audio before calling your callback.</p>
178 <pre> my $callback = sub{ printf("[channel_finished] callback called for channel %d\n", shift); };
180 SDL::Mixer::Channels::channel_finished( $callback );
189 SDL::Mixer::Channels::channel_finished( \&callback );
194 <h2 id="playing">playing</h2>
195 <div id="playing_CONTENT">
196 <pre> my $playing = SDL::Mixer::Channels::playing( $channel );
199 <p>Returns <code>1</code> if the given channel is playing sound, otherwise <code>0</code>. It does'nt check if the channel is paused.</p>
200 <p><strong>Note</strong>: If you pass <code>-1</code> you will get the number of playing channels.</p>
203 <h2 id="paused">paused</h2>
204 <div id="paused_CONTENT">
205 <pre> my $paused = SDL::Mixer::Channels::paused( $channel );
208 <p>Returns <code>1</code> if the given channel is paused, otherwise <code>0</code>.</p>
209 <p><strong>Note</strong>: If you pass <code>-1</code> you will get the number of paused channels.</p>
212 <h2 id="fading_channel">fading_channel</h2>
213 <div id="fading_channel_CONTENT">
214 <pre> my $fading_channel = SDL::Mixer::Channels::fading_channel( $channel );
217 <p>Returns one of the following for the given channel:</p>
219 <li>MIX_NO_FADING </li>
220 <li>MIX_FADING_OUT </li>
221 <li>MIX_FADING_IN</li>
224 <p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p>
227 <h2 id="get_chunk">get_chunk</h2>
228 <div id="get_chunk_CONTENT">
229 <pre> my $chunk = SDL::Mixer::Channels::get_chunk( $channel );
232 <p><code>get_chunk</code> gets the most recent sample chunk played on channel. This chunk may be currently playing, or just the last used. </p>
233 <p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p>
236 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
237 <div id="AUTHORS_CONTENT">
238 <p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>