.\" -*- 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 3pm" .TH pods::SDL::Mixer 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 \- Sound and music functions .SH CATEGORY .IX Header "CATEGORY" Mixer .SH CONSTANTS .IX Header "CONSTANTS" The constants are exported by default. You can avoid this by doing: .PP .Vb 1 \& use SDL::Mixer (); .Ve .PP and access them directly: .PP .Vb 1 \& SDL::Mixer::MIX_DEFAULT_FREQUENCY; .Ve .PP or by choosing the export tags below: .PP Export tag: ':init' .PP .Vb 4 \& MIX_INIT_FLAC \& MIX_INIT_MOD \& MIX_INIT_MP3 \& MIX_INIT_OGG .Ve .PP Export tag: ':defaults' .PP .Vb 6 \& MIX_CHANNELS \& MIX_DEFAULT_FORMAT \& MIX_DEFAULT_FREQUENCY \& MIX_DEFAULT_CHANNELS \& MIX_MAX_VOLUME \& MIX_CHANNEL_POST .Ve .PP Export tag: ':fading' .PP .Vb 3 \& MIX_NO_FADING \& MIX_FADING_OUT \& MIX_FADING_IN .Ve .PP Export tag: ':type' .PP .Vb 9 \& MUS_NONE \& MUS_CMD \& MUS_WAV \& MUS_MOD \& MUS_MID \& MUS_OGG \& MUS_MP3 \& MUS_MP3_MAD \& MUS_MP3_FLAC .Ve .PP Export tag: ':format' .PP .Vb 10 \& AUDIO_U8 \& AUDIO_S8 \& AUDIO_U16LSB \& AUDIO_S16LSB \& AUDIO_U16MSB \& AUDIO_S16MSB \& AUDIO_U16 \& AUDIO_S16 \& AUDIO_U16SYS \& AUDIO_S16SYS .Ve .PP Export tag: ':status' .PP .Vb 3 \& SDL_AUDIO_STOPPED \& SDL_AUDIO_PLAYING \& SDL_AUDIO_PAUSED .Ve .SH DESCRIPTION .IX Header "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. .SS "Supported Formats" .IX Subsection "Supported Formats" The SDL Mixer library is a multi-channel audio mixer. It supports \fI8 channels\fR of \fB16 bit\fR stereo audio, and a \fIsingle channel for music\fR. .PP You can use the channels to load samples (i.e. sound effects) in the following formats: .IP \(bu 4 Microsoft WAVE files (WAV) .IP \(bu 4 Creative Labs VOC files (VOC) .IP \(bu 4 MIDI files (if compiled with Timidity) .PP If you use MIDI, you should note that the process of mixing MIDI files to wave output is very CPU-intensive, so if playing regular WAVE files sound great, but playing MIDI files sound choppy, try using 8\-bit audio, mono audio, or lower frequencies. .PP The music channel can play the following formats: .IP \(bu 4 AIFF .IP \(bu 4 MOD (.mod .xm .s3m .669 .it .med and more \- if compiled with libmikmod) .IP \(bu 4 OggVorbis (.ogg \- if compiled with ogg/vorbis libraries) .IP \(bu 4 MP3 (if compiled with SMPEG or MAD libraries) .IP \(bu 4 FLAC (if compiled with FLAC library) .SH METHODS .IX Header "METHODS" .SS init .IX Subsection "init" .Vb 1 \& my $init_flags = SDL::Mixer::init( $flags ); .Ve .PP 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. .PP Example: .PP .Vb 1 \& use SDL::Mixer; \& \& my $init_flags = SDL::Mixer::init( MIX_INIT_MP3 | MIX_INIT_MOD | MIX_INIT_FLAC | MIX_INIT_OGG ); \& \& print("We have MP3 support!\en") if $init_flags & MIX_INIT_MP3; \& print("We have MOD support!\en") if $init_flags & MIX_INIT_MOD; \& print("We have FLAC support!\en") if $init_flags & MIX_INIT_FLAC; \& print("We have OGG support!\en") if $init_flags & MIX_INIT_OGG; .Ve .PP Flags: .IP \(bu 4 MIX_INIT_MP3 .IP \(bu 4 MIX_INIT_MOD .IP \(bu 4 MIX_INIT_FLAC .IP \(bu 4 MIX_INIT_OGG .PP \&\fBNote\fR: Only available for SDL_mixer >= 1.2.10 .SS quit .IX Subsection "quit" .Vb 1 \& SDL::Mixer::quit(); .Ve .PP This function unloads the libraries previously loaded with \fBinit()\fR. .PP \&\fBNote\fR: Only available for SDL_mixer >= 1.2.10 .SS linked_version .IX Subsection "linked_version" .Vb 1 \& $version = SDL::Mixer::linked_version(); .Ve .PP \&\f(CW\*(C`linked_version\*(C'\fR gives you the major\-, minor\-, and patchlevel for SDL_mixer. This way you can check if e.g. \fBinit()\fR and \fBquit()\fR are available. .PP Example: .PP .Vb 2 \& use SDL::Mixer; \& use SDL::Version; \& \& my $version = SDL::Mixer::linked_version(); \& \& printf("%d.%d.%d\en", $version\->major, $version\->minor, $version\->patch); # prints "1.2.8" for me .Ve .SS open_audio .IX Subsection "open_audio" .Vb 1 \& my $audio_opened = SDL::Mixer::open_audio( $frequency, $format, $channels, $chunksize ); .Ve .PP \&\f(CW\*(C`open_audio\*(C'\fR 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. .PP Returns 0 on success, \-1 on error. .PP \&\fBNote\fR: You must not use \f(CW\*(C`AUDIO_S16\*(C'\fR, \f(CW\*(C`AUDIO_U16\*(C'\fR, \f(CW\*(C`AUDIO_S16LSB\*(C'\fR, or \f(CW\*(C`AUDIO_U16LSB.\*(C'\fR 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 use \f(CW\*(C`AUDIO_S16SYS\*(C'\fR, 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. .PP \&\fBNote\fR: 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. .PP Example: .PP .Vb 2 \& use SDL; \& use SDL::Mixer; \& \& printf("Error initializing SDL_mixer: %s\en", SDL::get_error()) unless SDL::Mixer::open_audio(44100, AUDIO_S16, 2, 1024) == 0; .Ve .SS close_audio .IX Subsection "close_audio" .Vb 1 \& SDL::Mixer::close_audio(); .Ve .PP Close the mixer and halting all playing audio. This function does not return anything. .SS query_spec .IX Subsection "query_spec" .Vb 1 \& my @query_spec = @{ SDL::Mixer::query_spec() }; .Ve .PP 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. .PP Example: .PP .Vb 1 \& use SDL::Mixer; \& \& my ($status, $freq, $format, $channels) = @{ SDL::Mixer::query_spec() }; \& \& printf("%s, %s, %s, %s\en", $status, $freq, $format, $channels); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" perl, SDL::Mixer::Channels, SDL::Mixer::Effects, SDL::Mixer::Groups, SDL::Mixer::Music. .SH AUTHORS .IX Header "AUTHORS" See "AUTHORS" in SDL.