.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "pods::SDL::Mixer 3pm" .TH pods::SDL::Mixer 3pm "2020-11-09" "perl v5.32.0" "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 \s-1SDL\s0 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 \s-1WAVE\s0 files (\s-1WAV\s0) .IP "\(bu" 4 Creative Labs \s-1VOC\s0 files (\s-1VOC\s0) .IP "\(bu" 4 \&\s-1MIDI\s0 files (if compiled with Timidity) .PP If you use \s-1MIDI,\s0 you should note that the process of mixing \s-1MIDI\s0 files to wave output is very CPU-intensive, so if playing regular \s-1WAVE\s0 files sound great, but playing \s-1MIDI\s0 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 \&\s-1AIFF\s0 .IP "\(bu" 4 \&\s-1MOD\s0 (.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 \&\s-1MP3\s0 (if compiled with \s-1SMPEG\s0 or \s-1MAD\s0 libraries) .IP "\(bu" 4 \&\s-1FLAC\s0 (if compiled with \s-1FLAC\s0 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 \s-1OR\s0'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 \&\s-1MIX_INIT_MP3\s0 .IP "\(bu" 4 \&\s-1MIX_INIT_MOD\s0 .IP "\(bu" 4 \&\s-1MIX_INIT_FLAC\s0 .IP "\(bu" 4 \&\s-1MIX_INIT_OGG\s0 .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 \s-1SDL\s0 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 \s-1SDL\s0 should take this parameter only as a hint, then read back the value that the \s-1OS\s0 (for example, \s-1OSS\s0 or \s-1ALSA\s0) 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 \*(L"\s-1AUTHORS\*(R"\s0 in \s-1SDL\s0.