docs for SDL::Mixer::Channels
[sdlgit/SDL-Site.git] / pages / SDL-Mixer-Channels.html-inc
CommitLineData
d49f81db 1<div class="pod">
2<!-- INDEX START -->
3<h3 id="TOP">Index</h3>
4
5<ul><li><a href="#NAME">NAME</a></li>
b5d537cc 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>
25</li>
26</ul>
d49f81db 27</li>
28</ul><hr />
29<!-- INDEX END -->
30
31<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
32<div id="NAME_CONTENT">
b5d537cc 33<p>SDL::Mixer::Channels -- SDL::Mixer channel functions and bindings</p>
d49f81db 34
35</div>
36<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
37<div id="CATEGORY_CONTENT">
b5d537cc 38<p>Mixer</p>
39
40</div>
41<h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
42<div id="DESCRIPTION_CONTENT">
43
44</div>
45<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
46<div id="METHODS_CONTENT">
47
48</div>
49<h2 id="allocate_channels">allocate_channels</h2>
50<div id="allocate_channels_CONTENT">
05971ac0 51<pre> my $ret = SDL::Mixer::Channels::allocate_channels( $number_of_channels );
52
53</pre>
54<p>Dynamically change the number of channels managed by the mixer. If decreasing the number of channels, the upper channels arestopped.
55This function returns the new number of allocated channels.</p>
56<p>Example</p>
57<pre> use SDL::Mixer::Channels;
58
59 printf(&quot;We got %d channels!\n&quot;, SDL::Mixer::Channels::allocate_channels( 8 ) );
60
61</pre>
b5d537cc 62
63</div>
64<h2 id="volume">volume</h2>
65<div id="volume_CONTENT">
05971ac0 66<pre> my $prev_volume = SDL::Mixer::Channels::volume( $channel_number, $volume );
67
68</pre>
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>
70which 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
71current volume. </p>
72<p>Returns the previously set volume of the channel.</p>
b5d537cc 73
74</div>
75<h2 id="play_channel">play_channel</h2>
76<div id="play_channel_CONTENT">
05971ac0 77<pre> my $channel_number = SDL::Mixer::Channels::play_channel( $channel, $chunk, $loops );
78
79</pre>
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>
84<p>Example:</p>
85<pre> use SDL::Mixer;
86 use SDL::Mixer::Channels;
87 use SDL::Mixer::Samples;
88
89 SDL::init(SDL_INIT_AUDIO);
90 SDL::Mixer::open_audio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 );
91
92 my $chunk = SDL::Mixer::Samples::load_WAV('sample.wav');
93
94 SDL::Mixer::Channels::play_channel( -1, $chunk, -1 );
95
96 SDL::delay(1000);
97 SDL::Mixer::close_audio();
98
99</pre>
b5d537cc 100
101</div>
102<h2 id="play_channel_timed">play_channel_timed</h2>
103<div id="play_channel_timed_CONTENT">
05971ac0 104<pre> my $channel = SDL::Mixer::Channels::play_channel_timed( $channel, $chunk, $loops, $ticks );
105
106</pre>
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>
b5d537cc 108
109</div>
110<h2 id="fade_in_channel">fade_in_channel</h2>
111<div id="fade_in_channel_CONTENT">
05971ac0 112<pre> my $channel = SDL::Mixer::Channels::fade_in_channel( $channel, $chunk, $loops, $ms );
113
114</pre>
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>
b5d537cc 116
117</div>
118<h2 id="fade_in_channel_timed">fade_in_channel_timed</h2>
119<div id="fade_in_channel_timed_CONTENT">
05971ac0 120<pre> my $channel = SDL::Mixer::Channels::fade_in_channel_timed( $channel, $chunk, $loops, $ms, $ticks );
121
122</pre>
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>
b5d537cc 124
125</div>
126<h2 id="pause">pause</h2>
127<div id="pause_CONTENT">
05971ac0 128<pre> SDL::Mixer::Channels::pause( $channel );
129
130</pre>
131<p>Pauses the given channel or all by passing <code>-1</code>.</p>
b5d537cc 132
133</div>
134<h2 id="resume">resume</h2>
135<div id="resume_CONTENT">
05971ac0 136<pre> SDL::Mixer::Channels::resume( $channel );
137
138</pre>
139<p>Resumes the given channel or all by passing <code>-1</code>.</p>
b5d537cc 140
141</div>
142<h2 id="halt_channel">halt_channel</h2>
143<div id="halt_channel_CONTENT">
05971ac0 144<pre> SDL::Mixer::Channels::halt_channel( $channel );
145
146</pre>
147<p>Stops the given channel or all by passing <code>-1</code>.</p>
b5d537cc 148
149</div>
150<h2 id="expire_channel">expire_channel</h2>
151<div id="expire_channel_CONTENT">
05971ac0 152<pre> my $channels = SDL::Mixer::Channels::expire_channel( $channel, $ticks );
153
154</pre>
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>
b5d537cc 157
158</div>
159<h2 id="fade_out_channel">fade_out_channel</h2>
160<div id="fade_out_channel_CONTENT">
05971ac0 161<pre> my $fading_channels = SDL::Mixer::Channels::fade_out_channel( $which, $ms );
162
163</pre>
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>
b5d537cc 166
167</div>
168<h2 id="channel_finished">channel_finished</h2>
169<div id="channel_finished_CONTENT">
05971ac0 170<p>TODO</p>
b5d537cc 171
172</div>
173<h2 id="playing">playing</h2>
174<div id="playing_CONTENT">
05971ac0 175<pre> my $playing = SDL::Mixer::Channels::playing( $channel );
176
177</pre>
178<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>
179<p><strong>Note</strong>: If you pass <code>-1</code> you will get the number of playing channels.</p>
b5d537cc 180
181</div>
182<h2 id="paused">paused</h2>
183<div id="paused_CONTENT">
05971ac0 184<pre> my $paused = SDL::Mixer::Channels::paused( $channel );
185
186</pre>
187<p>Returns <code>1</code> if the given channel is paused, otherwise <code>0</code>.</p>
188<p><strong>Note</strong>: If you pass <code>-1</code> you will get the number of paused channels.</p>
b5d537cc 189
190</div>
191<h2 id="fading_channel">fading_channel</h2>
192<div id="fading_channel_CONTENT">
05971ac0 193<pre> my $fading_channel = SDL::Mixer::Channels::fading_channel( $channel );
194
195</pre>
196<p>Returns one of the following for the given channel:</p>
197<ul>
198 <li>MIX_NO_FADING </li>
199 <li>MIX_FADING_OUT </li>
200 <li>MIX_FADING_IN</li>
201</ul>
202
203<p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p>
b5d537cc 204
205</div>
206<h2 id="get_chunk">get_chunk</h2>
207<div id="get_chunk_CONTENT">
05971ac0 208<pre> my $chunk = SDL::Mixer::Channels::get_chunk( $channel );
209
210</pre>
211<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>
212<p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p>
d49f81db 213
214</div>
215</div>