X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Mixer.html-inc;h=68bd8f0ebb2854fc5c631a87ce9d277739f3bc8f;hb=505f308d8b092747da8b2f5e9781475a1f06dfe8;hp=70e4cd40d34d726d7f90a55f9d52d411e19818cd;hpb=162a0989f2a1d33d50c8950709319df21973e7b7;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Mixer.html-inc b/pages/SDL-Mixer.html-inc index 70e4cd4..68bd8f0 100644 --- a/pages/SDL-Mixer.html-inc +++ b/pages/SDL-Mixer.html-inc @@ -3,280 +3,225 @@
SDL::Mixer - a SDL perl extension
+SDL::Mixer - Sound and music functions
$mixer = new SDL::Mixer -frequency => MIX_DEFAULT_FREQUENCY, - -format => MIX_DEFAULT_FORMAT, - -channels => MIX_DEFAULT_CHANNELS, - -size => 4096; - -- -
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.
- -Mixer
$mixer = SDL::Mixer->new( -frequency => MIX_DEFAULT_FREQUENCY, - -format => MIX_DEFAULT_FORMAT, - -channels => MIX_DEFAULT_CHANNELS, - -size => 4096); +CONSTANTS
++-The constants are exported by default. You can avoid this by doing:
+use SDL::Mixer ();-Creates a new SDL::Mixer object.
- -$size
is the buffer size in bytes.query_spec()
---my $specs = SDL::Mixer::query_spec(); +and access them directly:
+SDL::Mixer::MIX_DEFAULT_FREQUENCY;-Returns a hash reference, containing the following keys and their respective -values:
--status - -frequency - -channels - -format +or by choosing the export tags below:
+Export tag: ':init'
+MIX_INIT_FLAC + MIX_INIT_MOD + MIX_INIT_MP3 + MIX_INIT_OGG- -reserve_channels
---$mixer->reserve_channels(4); +Export tag: ':defaults'
+MIX_CHANNELS + MIX_DEFAULT_FORMAT + MIX_DEFAULT_FREQUENCY + MIX_DEFAULT_CHANNELS + MIX_MAX_VOLUME + MIX_CHANNEL_POST-Reserve so many channels.
- -allocate_channels()
---$mixer->reserve_channels(2); +Export tag: ':fading'
+MIX_NO_FADING + MIX_FADING_OUT + MIX_FADING_IN-Allocate so many channels.
+Export tag: ':type'
+MUS_NONE + MUS_CMD + MUS_WAV + MUS_MOD + MUS_MID + MUS_OGG + MUS_MP3 + MUS_MP3_MAD + MUS_MP3_FLAC -group_channel(channel,group)
---Group the channel number
- -$channel
into group$group
.group_channels(from,to,group)
---Groups a range of channels
+ +Export tag: ':format'
+AUDIO_U8 + AUDIO_S8 + AUDIO_U16LSB + AUDIO_S16LSB + AUDIO_U16MSB + AUDIO_S16MSB + AUDIO_U16 + AUDIO_S16 + AUDIO_U16SYS + AUDIO_S16SYS -group_available(group)
---Return true when the group is available.
+ +Export tag: ':status'
+SDL_AUDIO_STOPPED + SDL_AUDIO_PLAYING + SDL_AUDIO_PAUSED -group_count(group)
---Returns the number of channels in the group
+group_oldest()
-- - - - +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.
group_newer()
-- - - - +METHODS
+-play_channel()
-- - - +init
++-my $init_flags = SDL::Mixer::init( $flags ); ++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; -play_music()
---Play
+ my $init_flags = SDL::Mixer::init( MIX_INIT_MP3 | MIX_INIT_MOD | MIX_INIT_FLAC | MIX_INIT_OGG ); -$music
$loop
times.fade_in_channel(channel,chunk,loops,ms,ticks)
---Fades a channel in
+ 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; -fade_in_music(music,loops,ms)
---Fades the music in over a number of ms, looping as it does
+ +Flags:
++
-- MIX_INIT_MP3
+- MIX_INIT_MOD
+- MIX_INIT_FLAC
+- MIX_INIT_OGG
+channel_volume(channel,volume)
---Sets the volume for a single channel
+Note: Only available for SDL_mixer >= 1.2.10
mucis_volume(volume)
--Set the volume for the music.
+quit
++-SDL::Mixer::quit(); -halt_channel(channel)
---Stops a specific channel
+ +This function unloads the liraries previously loaded with init().
+Note: Only available for SDL_mixer >= 1.2.10
halt_group(group)
--Stops a group of channels
+linked_version
++-$version = SDL::Mixer::linked_version(); -halt_music()
---Stops the music
+ ++
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; -channel_expire(channel,ticks)
---Ignores the channel after
+ my $version = SDL::Mixer::linked_version(); -ticks
has expiredfade_out_channel(channel,ms)
---Fade the channel number
+ printf("%d.%d.%d\n", $version->major, $version->minor, $version->patch); # prints "1.2.8" for me -$channel
in$ms
ms out.fade_out_group(group,ms)
---Fade the channel group
- -$group
in$ms
ms out.fade_out_music(ms)
---Fade the music in
+$ms
ms out.fading_music()
--Return true when the music is currently fading in or out.
+open_audio
++-my $audio_opened = SDL::Mixer::open_audio( $frequency, $format, $channels, $chunksize ); -fading_channel()
---Return true when the channel number
+ +$channel
is currently fading in or out.+
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; -pause( channel )
---Pause the channel
+$channel
.resume(channel)
--Resume the channel
+$channel
.close_audio
++-SDL::Mixer::close_audio(); -paused()
---Return true when the channel is currently paused.
+ +Close the mixer and halting all playing audio. This function does not return anything.
pause_music()
--Pause the music play.
+query_spec
++-my @query_spec = @{ SDL::Mixer::query_spec() }; -resume_music()
---Resume the music play.
+ +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; -rewind_music()
---Resets the music file to the beginning
+ my ($status, $freq, $format, $channels) = @{ SDL::Mixer::query_spec() }; -music_paused()
---Return true when the music is currently paused.
+ printf("%s, %s, %s, %s\n", $status, $freq, $format, $channels); -playing()
---Return true when the channel is currently playing.
+playing_music ()
--Return true when the music is currently playing.
+AUTHORS
++-Tobias Leich [FROGGS]
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
+