.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "pods::SDL::Mixer::Channels 3pm" .TH pods::SDL::Mixer::Channels 3pm 2024-03-28 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME SDL::Mixer::Channels \-\- SDL::Mixer channel functions and bindings .SH CATEGORY .IX Header "CATEGORY" Mixer .SH DESCRIPTION .IX Header "DESCRIPTION" .SH METHODS .IX Header "METHODS" .SS allocate_channels .IX Subsection "allocate_channels" .Vb 1 \& my $ret = SDL::Mixer::Channels::allocate_channels( $number_of_channels ); .Ve .PP Dynamically change the number of channels managed by the mixer. If decreasing the number of channels, the upper channels are stopped. This function returns the new number of allocated channels. .PP Example .PP .Vb 1 \& use SDL::Mixer::Channels; \& \& printf("We got %d channels!\en", SDL::Mixer::Channels::allocate_channels( 8 ) ); .Ve .SS volume .IX Subsection "volume" .Vb 1 \& my $prev_volume = SDL::Mixer::Channels::volume( $channel_number, $volume ); .Ve .PP \&\f(CW\*(C`volume\*(C'\fR changes the volume of the channel specified in channel by the amount set in volume. The range of volume is from 0 to \f(CW\*(C`MIX_MAX_VOLUME\*(C'\fR which is \f(CW128\fR. Passing \f(CW\-1\fR to channel will change the volume of all channels. If the specified volume is \f(CW\-1\fR, it will just return the current volume. .PP Returns the previously set volume of the channel. .SS play_channel .IX Subsection "play_channel" .Vb 1 \& my $channel_number = SDL::Mixer::Channels::play_channel( $channel, $chunk, $loops ); .Ve .PP \&\f(CW\*(C`play_channel\*(C'\fR will play the specified \f(CW\*(C`chunk\*(C'\fR over the specified \f(CW\*(C`channel\*(C'\fR. SDL_mixer will choose a channel for you if you pass \f(CW\-1\fR for \&\f(CW\*(C`channel\*(C'\fR. .PP The chunk will be looped \f(CW\*(C`loops\*(C'\fR times, the total number of times played will be \f(CW\*(C`loops+1\*(C'\fR. Passing \f(CW\-1\fR will loop the chunk infinitely. .PP Returns the channel the chunk will be played on, or \f(CW\-1\fR on error. .PP Example: .PP .Vb 3 \& use SDL::Mixer; \& use SDL::Mixer::Channels; \& use SDL::Mixer::Samples; \& \& SDL::init(SDL_INIT_AUDIO); \& SDL::Mixer::open_audio( 44100, SDL::Constants::AUDIO_S16, 2, 4096 ); \& \& my $chunk = SDL::Mixer::Samples::load_WAV(\*(Aqsample.wav\*(Aq); \& \& SDL::Mixer::Channels::play_channel( \-1, $chunk, \-1 ); \& \& SDL::delay(1000); \& SDL::Mixer::close_audio(); .Ve .SS play_channel_timed .IX Subsection "play_channel_timed" .Vb 1 \& my $channel = SDL::Mixer::Channels::play_channel_timed( $channel, $chunk, $loops, $ticks ); .Ve .PP Same as play_channel but you can specify the time it will play by \f(CW$ticks\fR. .SS fade_in_channel .IX Subsection "fade_in_channel" .Vb 1 \& my $channel = SDL::Mixer::Channels::fade_in_channel( $channel, $chunk, $loops, $ms ); .Ve .PP Same as play_channel but you can specify the fade-in time by \f(CW$ms\fR. .SS fade_in_channel_timed .IX Subsection "fade_in_channel_timed" .Vb 1 \& my $channel = SDL::Mixer::Channels::fade_in_channel_timed( $channel, $chunk, $loops, $ms, $ticks ); .Ve .PP Same as fade_in_channel but you can specify the time how long the chunk will be played by \f(CW$ticks\fR. .SS pause .IX Subsection "pause" .Vb 1 \& SDL::Mixer::Channels::pause( $channel ); .Ve .PP Pauses the given channel or all by passing \f(CW\-1\fR. .SS resume .IX Subsection "resume" .Vb 1 \& SDL::Mixer::Channels::resume( $channel ); .Ve .PP Resumes the given channel or all by passing \f(CW\-1\fR. .SS halt_channel .IX Subsection "halt_channel" .Vb 1 \& SDL::Mixer::Channels::halt_channel( $channel ); .Ve .PP Stops the given channel or all by passing \f(CW\-1\fR. .SS expire_channel .IX Subsection "expire_channel" .Vb 1 \& my $channels = SDL::Mixer::Channels::expire_channel( $channel, $ticks ); .Ve .PP Stops the given channel (or \f(CW\-1\fR for all) after the time specified by \f(CW$ticks\fR (in milliseconds). .PP Returns the number of affected channels. .SS fade_out_channel .IX Subsection "fade_out_channel" .Vb 1 \& my $fading_channels = SDL::Mixer::Channels::fade_out_channel( $which, $ms ); .Ve .PP \&\f(CW\*(C`fade_out_channel\*(C'\fR fades out a channel specified in \f(CW\*(C`which\*(C'\fR with a duration specified in \f(CW\*(C`ms\*(C'\fR in milliseconds. .PP Returns the the number of channels that will be faded out. .SS channel_finished .IX Subsection "channel_finished" .Vb 1 \& SDL::Mixer::Channels::channel_finished( $callback ); .Ve .PP Add your own callback when a channel has finished playing. \f(CW\*(C`NULL\*(C'\fR to disable callback. The callback may be called from the mixer's audio callback or it could be called as a result of halt_channel, etc. do not call \f(CW\*(C`lock_audio\*(C'\fR from this callback; you will either be inside the audio callback, or SDL_mixer will explicitly lock the audio before calling your callback. .PP Example 1: .PP .Vb 1 \& my $callback = sub{ printf("[channel_finished] callback called for channel %d\en", shift); }; \& \& SDL::Mixer::Channels::channel_finished( $callback ); .Ve .PP Example 2: .PP .Vb 4 \& sub callback \& { \& ... \& } \& \& SDL::Mixer::Channels::channel_finished( \e&callback ); .Ve .SS playing .IX Subsection "playing" .Vb 1 \& my $playing = SDL::Mixer::Channels::playing( $channel ); .Ve .PP Returns \f(CW1\fR if the given channel is playing sound, otherwise \f(CW0\fR. It doesn't check if the channel is paused. .PP \&\fBNote\fR: If you pass \f(CW\-1\fR you will get the number of playing channels. .SS paused .IX Subsection "paused" .Vb 1 \& my $paused = SDL::Mixer::Channels::paused( $channel ); .Ve .PP Returns \f(CW1\fR if the given channel is paused, otherwise \f(CW0\fR. .PP \&\fBNote\fR: If you pass \f(CW\-1\fR you will get the number of paused channels. .SS fading_channel .IX Subsection "fading_channel" .Vb 1 \& my $fading_channel = SDL::Mixer::Channels::fading_channel( $channel ); .Ve .PP Returns one of the following for the given channel: .IP \(bu 4 MIX_NO_FADING .IP \(bu 4 MIX_FADING_OUT .IP \(bu 4 MIX_FADING_IN .PP \&\fBNote\fR: Never pass \f(CW\-1\fR to this function! .SS get_chunk .IX Subsection "get_chunk" .Vb 1 \& my $chunk = SDL::Mixer::Channels::get_chunk( $channel ); .Ve .PP \&\f(CW\*(C`get_chunk\*(C'\fR gets the most recent sample chunk played on channel. This chunk may be currently playing, or just the last used. .PP \&\fBNote\fR: Never pass \f(CW\-1\fR to this function! .SH AUTHORS .IX Header "AUTHORS" See "AUTHORS" in SDL.