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>
31 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
32 <div id="NAME_CONTENT">
33 <p>SDL::Mixer::Channels -- SDL::Mixer channel functions and bindings</p>
36 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="CATEGORY_CONTENT">
41 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="DESCRIPTION_CONTENT">
45 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
46 <div id="METHODS_CONTENT">
49 <h2 id="allocate_channels">allocate_channels</h2>
50 <div id="allocate_channels_CONTENT">
51 <pre> my $ret = SDL::Mixer::Channels::allocate_channels( $number_of_channels );
54 <p>Dynamically change the number of channels managed by the mixer. If decreasing the number of channels, the upper channels arestopped.
55 This function returns the new number of allocated channels.</p>
57 <pre> use SDL::Mixer::Channels;
59 printf("We got %d channels!\n", SDL::Mixer::Channels::allocate_channels( 8 ) );
64 <h2 id="volume">volume</h2>
65 <div id="volume_CONTENT">
66 <pre> my $prev_volume = SDL::Mixer::Channels::volume( $channel_number, $volume );
69 <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>
70 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
72 <p>Returns the previously set volume of the channel.</p>
75 <h2 id="play_channel">play_channel</h2>
76 <div id="play_channel_CONTENT">
77 <pre> my $channel_number = SDL::Mixer::Channels::play_channel( $channel, $chunk, $loops );
80 <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
81 <code>channel</code>.</p>
82 <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>
83 <p>Returns the channel the chunk will be played on, or <code>-1</code> on error.</p>
86 use SDL::Mixer::Channels;
87 use SDL::Mixer::Samples;
89 SDL::init(SDL_INIT_AUDIO);
90 SDL::Mixer::open_audio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 );
92 my $chunk = SDL::Mixer::Samples::load_WAV('sample.wav');
94 SDL::Mixer::Channels::play_channel( -1, $chunk, -1 );
97 SDL::Mixer::close_audio();
102 <h2 id="play_channel_timed">play_channel_timed</h2>
103 <div id="play_channel_timed_CONTENT">
104 <pre> my $channel = SDL::Mixer::Channels::play_channel_timed( $channel, $chunk, $loops, $ticks );
107 <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>
110 <h2 id="fade_in_channel">fade_in_channel</h2>
111 <div id="fade_in_channel_CONTENT">
112 <pre> my $channel = SDL::Mixer::Channels::fade_in_channel( $channel, $chunk, $loops, $ms );
115 <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>
118 <h2 id="fade_in_channel_timed">fade_in_channel_timed</h2>
119 <div id="fade_in_channel_timed_CONTENT">
120 <pre> my $channel = SDL::Mixer::Channels::fade_in_channel_timed( $channel, $chunk, $loops, $ms, $ticks );
123 <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>
126 <h2 id="pause">pause</h2>
127 <div id="pause_CONTENT">
128 <pre> SDL::Mixer::Channels::pause( $channel );
131 <p>Pauses the given channel or all by passing <code>-1</code>.</p>
134 <h2 id="resume">resume</h2>
135 <div id="resume_CONTENT">
136 <pre> SDL::Mixer::Channels::resume( $channel );
139 <p>Resumes the given channel or all by passing <code>-1</code>.</p>
142 <h2 id="halt_channel">halt_channel</h2>
143 <div id="halt_channel_CONTENT">
144 <pre> SDL::Mixer::Channels::halt_channel( $channel );
147 <p>Stops the given channel or all by passing <code>-1</code>.</p>
150 <h2 id="expire_channel">expire_channel</h2>
151 <div id="expire_channel_CONTENT">
152 <pre> my $channels = SDL::Mixer::Channels::expire_channel( $channel, $ticks );
155 <p>Stops the given channel (or <code>-1</code> for all) after the time specified by <code>$ticks</code> (in milliseconds).</p>
156 <p>Returns the number of affected channels.</p>
159 <h2 id="fade_out_channel">fade_out_channel</h2>
160 <div id="fade_out_channel_CONTENT">
161 <pre> my $fading_channels = SDL::Mixer::Channels::fade_out_channel( $which, $ms );
164 <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>
165 <p>Returns the the number of channels that will be faded out.</p>
168 <h2 id="channel_finished">channel_finished</h2>
169 <div id="channel_finished_CONTENT">
170 <pre> SDL::Mixer::Channels::channel_finished( $callback );
173 <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
174 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
175 the audio callback, or SDL_mixer will explicitly lock the audio before calling your callback.</p>
177 <pre> my $callback = sub{ printf("[channel_finished] callback called for channel %d\n", shift); };
179 SDL::Mixer::Channels::channel_finished( $callback );
188 SDL::Mixer::Channels::channel_finished( \&callback );
193 <h2 id="playing">playing</h2>
194 <div id="playing_CONTENT">
195 <pre> my $playing = SDL::Mixer::Channels::playing( $channel );
198 <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>
199 <p><strong>Note</strong>: If you pass <code>-1</code> you will get the number of playing channels.</p>
202 <h2 id="paused">paused</h2>
203 <div id="paused_CONTENT">
204 <pre> my $paused = SDL::Mixer::Channels::paused( $channel );
207 <p>Returns <code>1</code> if the given channel is paused, otherwise <code>0</code>.</p>
208 <p><strong>Note</strong>: If you pass <code>-1</code> you will get the number of paused channels.</p>
211 <h2 id="fading_channel">fading_channel</h2>
212 <div id="fading_channel_CONTENT">
213 <pre> my $fading_channel = SDL::Mixer::Channels::fading_channel( $channel );
216 <p>Returns one of the following for the given channel:</p>
218 <li>MIX_NO_FADING </li>
219 <li>MIX_FADING_OUT </li>
220 <li>MIX_FADING_IN</li>
223 <p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p>
226 <h2 id="get_chunk">get_chunk</h2>
227 <div id="get_chunk_CONTENT">
228 <pre> my $chunk = SDL::Mixer::Channels::get_chunk( $channel );
231 <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>
232 <p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p>