X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Mixer.html-inc;h=bb0e1e734428373d5669544fafa6fc8452f4f344;hb=55bbf7a209993f4172fd7e6555dda0947b844089;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..bb0e1e7 100644 --- a/pages/SDL-Mixer.html-inc +++ b/pages/SDL-Mixer.html-inc @@ -3,280 +3,158 @@
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; - -+
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.
+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.
$mixer = SDL::Mixer->new( -frequency => MIX_DEFAULT_FREQUENCY, - -format => MIX_DEFAULT_FORMAT, - -channels => MIX_DEFAULT_CHANNELS, - -size => 4096); +init
++-my $init_flags = SDL::Mixer::init( $flags );-Creates a new SDL::Mixer object.
+$size
is the buffer size in bytes.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; -query_spec()
---my $specs = SDL::Mixer::query_spec(); + my $init_flags = SDL::Mixer::init( MIX_INIT_MP3 | MIX_INIT_MOD | MIX_INIT_FLAC | MIX_INIT_OGG ); --Returns a hash reference, containing the following keys and their respective -values:
--status - -frequency - -channels - -format + 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;+Flags:
++
-- MIX_INIT_MP3
+- MIX_INIT_MOD
+- MIX_INIT_FLAC
+- MIX_INIT_OGG
+reserve_channels
---$mixer->reserve_channels(4); - --Reserve so many channels.
+Note: Only available for SDL_mixer >= 1.2.10
allocate_channels()
--$mixer->reserve_channels(2); +quit
++-SDL::Mixer::quit();-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()
-- - - - - --group_newer()
-- - - - - --play_channel()
-- - - - - --play_music()
---Play
- -$music
$loop
times.fade_in_channel(channel,chunk,loops,ms,ticks)
---Fades a channel in
- -fade_in_music(music,loops,ms)
---Fades the music in over a number of ms, looping as it does
- -channel_volume(channel,volume)
---Sets the volume for a single channel
+This function unloads the liraries previously loaded with init().
+Note: Only available for SDL_mixer >= 1.2.10
mucis_volume(volume)
--Set the volume for the music.
+linked_version
++-$version = SDL::Mixer::linked_version(); -halt_channel(channel)
---Stops a specific channel
- -halt_group(group)
---Stops a group of channels
- -halt_music()
---Stops the music
- -channel_expire(channel,ticks)
---Ignores the channel after
+ +ticks
has expired+
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_channel(channel,ms)
---Fade the channel number
+ my $version = SDL::Mixer::linked_version(); -$channel
in$ms
ms out.fade_out_group(group,ms)
---Fade the channel group
+ printf("%d.%d.%d\n", $version->major, $version->minor, $version->patch); # prints "1.2.8" for me -$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
+