pods::...annels(3pm)
π
pods::...annels(3pm) β SDL::Mixer::Channels π
okay bestie, welcome to the pods::...annels(3pm) page from the User Contributed Perl Documentation manual. Itβs giving SDL::Mixer channel functions and bindings, and weβre gonna go through every single one. no cap. π
β¨ NAME β¨
SDL::Mixer::Channels β SDL::Mixer channel functions and bindings.
π·οΈ CATEGORY π·οΈ
Mixer
π DESCRIPTION π
This page is basically the channel-method lineup, bestie. Every method is down below β no skips, fr fr. π
π§ METHODS π§
π allocate_channels π
my $ret = SDL::Mixer::Channels::allocate_channels( $number_of_channels );
Dynamically changes the number of channels managed by the mixer. If you decrease the number of channels, the upper channels are stopped. This function returns the new number of allocated channels. Slay. π
Example
use SDL::Mixer::Channels;
printf("We got %d channels!\n", SDL::Mixer::Channels::allocate_channels( 8 ) );
π volume π
my $prev_volume = SDL::Mixer::Channels::volume( $channel_number, $volume );
volume changes the volume of the channel specified in channel by the amount set in volume. The range of volume is from 0 to MIX_MAX_VOLUME, which is 128. Passing -1 to channel changes the volume of all channels. If the specified volume is -1, it will just return the current volume.
Returns the previously set volume of the channel. π«Ά
πΆ play_channel πΆ
my $channel_number = SDL::Mixer::Channels::play_channel( $channel, $chunk, $loops );
play_channel plays the specified chunk over the specified channel. SDL_mixer will choose a channel for you if you pass -1 for channel.
The chunk will be looped loops times, and the total number of times played will be loops+1. Passing -1 will loop the chunk infinitely.
Returns the channel the chunk will be played on, or -1 on error. π₯
Example:
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('sample.wav');
SDL::Mixer::Channels::play_channel( -1, $chunk, -1 );
SDL::delay(1000);
SDL::Mixer::close_audio();
β±οΈ play_channel_timed β±οΈ
my $channel = SDL::Mixer::Channels::play_channel_timed( $channel, $chunk, $loops, $ticks );
Same as play_channel, but you can specify the time it will play by $ticks. β¨
π fade_in_channel π
my $channel = SDL::Mixer::Channels::fade_in_channel( $channel, $chunk, $loops, $ms );
Same as play_channel, but you can specify the fade-in time by $ms. π
π fade_in_channel_timed π
my $channel = SDL::Mixer::Channels::fade_in_channel_timed( $channel, $chunk, $loops, $ms, $ticks );
Same as fade_in_channel, but you can specify the time how long the chunk will be played by $ticks. π¦
βΈοΈ pause βΈοΈ
SDL::Mixer::Channels::pause( $channel );
Pauses the given channel, or all of them by passing -1. π€
βΆοΈ resume βΆοΈ
SDL::Mixer::Channels::resume( $channel );
Resumes the given channel, or all of them by passing -1. π₯
π halt_channel π
SDL::Mixer::Channels::halt_channel( $channel );
Stops the given channel, or all of them by passing -1. π
β³ expire_channel β³
my $channels = SDL::Mixer::Channels::expire_channel( $channel, $ticks );
Stops the given channel (or -1 for all) after the time specified by $ticks (in milliseconds).
Returns the number of affected channels. π°οΈ
π fade_out_channel π
my $fading_channels = SDL::Mixer::Channels::fade_out_channel( $which, $ms );
fade_out_channel fades out a channel specified in which with a duration specified in ms in milliseconds.
Returns the number of channels that will be faded out. π
π channel_finished π
SDL::Mixer::Channels::channel_finished( $callback );
Add your own callback for when a channel has finished playing. NULL disables the 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 lock_audio from this callback; you will either be inside the audio callback, or SDL_mixer will explicitly lock the audio before calling your callback.
bestie, seriously: no lock_audio in here. thatβs the rule. π
Example 1:
my $callback = sub{ printf("[channel_finished] callback called for channel %d\n", shift); };
SDL::Mixer::Channels::channel_finished( $callback );
Example 2:
sub callback
{
...
}
SDL::Mixer::Channels::channel_finished( \&callback );
π΅ playing π΅
my $playing = SDL::Mixer::Channels::playing( $channel );
Returns 1 if the given channel is playing sound, otherwise 0. It doesnβt check if the channel is paused.
Note: If you pass -1 you will get the number of playing channels. π§
π΄ paused π΄
my $paused = SDL::Mixer::Channels::paused( $channel );
Returns 1 if the given channel is paused, otherwise 0.
Note: If you pass -1 you will get the number of paused channels. π€
π fading_channel π
my $fading_channel = SDL::Mixer::Channels::fading_channel( $channel );
Returns one of the following for the given channel:
MIX_NO_FADINGMIX_FADING_OUTMIX_FADING_IN
Note: Never pass -1 to this function! π¨
π get_chunk π
my $chunk = SDL::Mixer::Channels::get_chunk( $channel );
get_chunk gets the most recent sample chunk played on channel. This chunk may be currently playing, or just the last used.
Note: Never pass -1 to this function! π¨
π AUTHORS π
See "AUTHORS" in SDL. π
okay thatβs the whole page, bestie π«Ά β this was pods::...annels(3pm) from the User Contributed Perl Documentation manual, with the footer/source line saying perl v5.42.0, dated 2024-05-01. Go make some iconic mixer channels. periodt. π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms