Commit | Line | Data |
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. |
55 | This function returns the new number of allocated channels.</p> |
56 | <p>Example</p> |
57 | <pre> use SDL::Mixer::Channels; |
58 | |
59 | printf("We got %d channels!\n", 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> |
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 |
71 | current 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"> |
071b4b10 |
170 | <pre> SDL::Mixer::Channels::channel_finished( $callback ); |
171 | |
172 | </pre> |
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> |
176 | <p>Example 1:</p> |
177 | <pre> my $callback = sub{ printf("[channel_finished] callback called for channel %d\n", shift); }; |
178 | |
179 | SDL::Mixer::Channels::channel_finished( $callback ); |
180 | |
181 | </pre> |
182 | <p>Example 2:</p> |
183 | <pre> sub callback |
184 | { |
185 | ... |
186 | } |
187 | |
188 | SDL::Mixer::Channels::channel_finished( \&callback ); |
189 | |
190 | </pre> |
b5d537cc |
191 | |
192 | </div> |
193 | <h2 id="playing">playing</h2> |
194 | <div id="playing_CONTENT"> |
05971ac0 |
195 | <pre> my $playing = SDL::Mixer::Channels::playing( $channel ); |
196 | |
197 | </pre> |
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> |
b5d537cc |
200 | |
201 | </div> |
202 | <h2 id="paused">paused</h2> |
203 | <div id="paused_CONTENT"> |
05971ac0 |
204 | <pre> my $paused = SDL::Mixer::Channels::paused( $channel ); |
205 | |
206 | </pre> |
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> |
b5d537cc |
209 | |
210 | </div> |
211 | <h2 id="fading_channel">fading_channel</h2> |
212 | <div id="fading_channel_CONTENT"> |
05971ac0 |
213 | <pre> my $fading_channel = SDL::Mixer::Channels::fading_channel( $channel ); |
214 | |
215 | </pre> |
216 | <p>Returns one of the following for the given channel:</p> |
217 | <ul> |
218 | <li>MIX_NO_FADING </li> |
219 | <li>MIX_FADING_OUT </li> |
220 | <li>MIX_FADING_IN</li> |
221 | </ul> |
222 | |
223 | <p><strong>Note</strong>: Never pass <code>-1</code> to this function!</p> |
b5d537cc |
224 | |
225 | </div> |
226 | <h2 id="get_chunk">get_chunk</h2> |
227 | <div id="get_chunk_CONTENT"> |
05971ac0 |
228 | <pre> my $chunk = SDL::Mixer::Channels::get_chunk( $channel ); |
229 | |
230 | </pre> |
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> |
d49f81db |
233 | |
234 | </div> |
235 | </div> |