X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Mixer.html-inc;h=43e150ab8c4a2edd8d3771900fe904bd58aef7e5;hb=d5943b684b1240307fbf0a103abbf18dd93998f4;hp=62a0915d435ec8ac4e8b1d62735701192b6de0d9;hpb=cf23a5dab86667dca8475ee830e684c9944f115f;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Mixer.html-inc b/pages/SDL-Mixer.html-inc index 62a0915..43e150a 100644 --- a/pages/SDL-Mixer.html-inc +++ b/pages/SDL-Mixer.html-inc @@ -4,53 +4,26 @@
SDL::Mixer - a SDL perl extension
+SDL::Mixer - Sound and music functions
Mixer
-SDL::Mixer allows you access to the SDL mixer library, enablig sound and -music volume setting, playing, pausing and resuming, as well as fading -the sound and music in and out.
- -my $specs = SDL::Mixer::query_spec(); +CONSTANTS
++-The constants are exported by default. You can avoid this by doing:
+use SDL::Mixer ();-Returns a hash reference, containing the following keys and their respective -values:
--status - -frequency - -channels - -format +and access them directly:
+SDL::Mixer::MIX_DEFAULT_FREQUENCY;- -reserve_channels
---$mixer->reserve_channels(4); +or by choosing the export tags below:
+Export tag: ':init'
+MIX_INIT_FLAC + MIX_INIT_MOD + MIX_INIT_MP3 + MIX_INIT_OGG-Reserve so many channels.
- -allocate_channels()
---$mixer->reserve_channels(2); +Export tag: ':defaults'
+MIX_CHANNELS + MIX_DEFAULT_FORMAT + MIX_DEFAULT_FREQUENCY + MIX_DEFAULT_CHANNELS + MIX_MAX_VOLUME + MIX_CHANNEL_POST-Allocate so many channels.
- -group_channel(channel,group)
---Group the channel number
- -$channel
into group$group
.group_channels(from,to,group)
---Groups a range of channels
- -group_available(group)
---Return true when the group is available.
- -group_count(group)
---Returns the number of channels in the group
- -group_oldest()
-+-Export tag: ':fading'
+MIX_NO_FADING + MIX_FADING_OUT + MIX_FADING_IN ++Export tag: ':type'
+MUS_NONE + MUS_CMD + MUS_WAV + MUS_MOD + MUS_MID + MUS_OGG + MUS_MP3 + MUS_MP3_MAD + MUS_MP3_FLAC ++Export tag: ':format'
+AUDIO_U8 + AUDIO_S8 + AUDIO_U16LSB + AUDIO_S16LSB + AUDIO_U16MSB + AUDIO_S16MSB + AUDIO_U16 + AUDIO_S16 + AUDIO_U16SYS + AUDIO_S16SYS ++Export tag: ':status'
+SDL_AUDIO_STOPPED + SDL_AUDIO_PLAYING + SDL_AUDIO_PAUSED +group_newer()
-- - - - +DESCRIPTION
++-SDL::Mixer allows you to enable sound, alter music volume settings, and lets you play, pause and resume, as well as fading the sound and music +in and out.
play_channel()
-- - - - +METHODS
+-play_music()
--Play
+$music
$loop
times.init
++-my $init_flags = SDL::Mixer::init( $flags ); -fade_in_channel(channel,chunk,loops,ms,ticks)
---Fades a channel in
+ +Loads dynamic libraries and prepares them for use. Flags should be one or more flags from init flags OR'd together. +It returns the flags successfully initialized, or 0 on failure.
+Example:
+use SDL::Mixer; -fade_in_music(music,loops,ms)
---Fades the music in over a number of ms, looping as it does
+ my $init_flags = SDL::Mixer::init( MIX_INIT_MP3 | MIX_INIT_MOD | MIX_INIT_FLAC | MIX_INIT_OGG ); -channel_volume(channel,volume)
---Sets the volume for a single channel
+ print("We have MP3 support!\n") if $init_flags & MIX_INIT_MP3; + print("We have MOD support!\n") if $init_flags & MIX_INIT_MOD; + print("We have FLAC support!\n") if $init_flags & MIX_INIT_FLAC; + print("We have OGG support!\n") if $init_flags & MIX_INIT_OGG; -mucis_volume(volume)
---Set the volume for the music.
+ +Flags:
++
-- MIX_INIT_MP3
+- MIX_INIT_MOD
+- MIX_INIT_FLAC
+- MIX_INIT_OGG
+halt_channel(channel)
---Stops a specific channel
+Note: Only available for SDL_mixer >= 1.2.10
halt_group(group)
--Stops a group of channels
+quit
++-SDL::Mixer::quit(); -halt_music()
---Stops the music
+ +This function unloads the liraries previously loaded with init().
+Note: Only available for SDL_mixer >= 1.2.10
expire_channel(channel,ticks)
--Ignores the channel after
+ticks
has expiredlinked_version
++-$version = SDL::Mixer::linked_version(); -fade_out_channel(channel,ms)
---Fade the channel number
+ +$channel
in$ms
ms out.+
linked_version
gives you the major-, minor-, and patchlevel for SDL_mixer. This way you can check if e.g. init() and quit() +are available.Example:
+use SDL::Mixer; + use SDL::Version; -fade_out_group(group,ms)
---Fade the channel group
+ my $version = SDL::Mixer::linked_version(); -$group
in$ms
ms out.fade_out_music(ms)
---Fade the music in
+ printf("%d.%d.%d\n", $version->major, $version->minor, $version->patch); # prints "1.2.8" for me -$ms
ms out.fading_music()
---Return true when the music is currently fading in or out.
+fading_channel()
--Return true when the channel number
+$channel
is currently fading in or out.open_audio
++-my $audio_opened = SDL::Mixer::open_audio( $frequency, $format, $channels, $chunksize ); -pause(channel)
---Pause the channel
+ +$channel
.+
open_audio
will initialize SDL_mixer if it is not yet initialized, see note. SDL_mixer may not be able to provide the exact specifications +your provided, however it will automatically translate between the expected format and the real one. You can retrieve the real format using +query_spec.Returns 0 on success, -1 on error.
+Note: You must not use
+AUDIO_S16
,AUDIO_U16
,AUDIO_S16LSB
, orAUDIO_U16LSB.
They are not portable, and SDL will not return an +error code when they fail. The result will be a horrible staticy noise. You can usually useAUDIO_S16SYS
, though not always. Future versions +of SDL should take this parameter only as a hint, then read back the value that the OS (for example, OSS or ALSA) has chosen to use in case the +desired audio type is not supported.Note: When already initialized, this function will not re-initialize SDL_mixer, nor fail. It will merely increment the number of times +SDL::Mixer::close_audio must be called to actually get it to uninitialize. This serves as a very simplistic method for multiple application +components to use SDL_mixer without necessitating a great deal of inter-component awareness. Be warned however that in such a situation, the +latest components to initialize SDL_mixer will probably not get the SDL_mixer settings they're expecting.
+Example:
+use SDL; + use SDL::Mixer; + + printf("Error initializing SDL_mixer: %s\n", SDL::get_error()) unless SDL::Mixer::open_audio(44100, AUDIO_S16, 2, 1024) == 0; -resume(channel)
---Resume the channel
+$channel
.paused()
--Return true when the channel is currently paused.
+close_audio
++-SDL::Mixer::close_audio(); -pause_music()
---Pause the music play.
+ +Close the mixer and halting all playing audio. This function does not return anything.
resume_music()
--Resume the music play.
+query_spec
++-my @query_spec = @{ SDL::Mixer::query_spec() }; -rewind_music()
---Resets the music file to the beginning
+ +Find out what the actual audio device parameters are. +This function returns 1 as first array element (status) if the audio has been opened, 0 otherwise.
+Example:
+use SDL::Mixer; -music_paused()
---Return true when the music is currently paused.
+ my ($status, $freq, $format, $channels) = @{ SDL::Mixer::query_spec() }; -playing()
---Return true when the channel is currently playing.
+ printf("%s, %s, %s, %s\n", $status, $freq, $format, $channels); -playing_music ()
---Return true when the music is currently playing.
+set_panning($channel, $left, $right)
--\ No newline at end of fileSets the volume for the left or right channels. To do true panning:
+SEE ALSO
+ -AUTHORS
+AUTHORS
--David J. Goehrig, basic doc added by Tels <http://bloodgate.com>.
- -SEE ALSO
--perl, SDL::Music and SDL::Sound.
+See AUTHORS in SDL.