3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#CONSTANTS">CONSTANTS</a></li>
8 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9 <li><a href="#METHODS">METHODS</a>
10 <ul><li><a href="#init">init</a></li>
11 <li><a href="#quit">quit</a></li>
12 <li><a href="#linked_version">linked_version</a></li>
13 <li><a href="#open_audio">open_audio</a></li>
14 <li><a href="#close_audio">close_audio</a></li>
15 <li><a href="#query_spec">query_spec</a></li>
18 <li><a href="#AUTHORS">AUTHORS </a></li>
19 <li><a href="#SEE_ALSO">SEE ALSO</a>
24 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
25 <div id="NAME_CONTENT">
26 <p>SDL::Mixer - Sound and music functions</p>
29 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
30 <div id="CATEGORY_CONTENT">
34 <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
35 <div id="CONSTANTS_CONTENT">
36 <p>The constants are not exported by default. You can export them into your namespace by doing:</p>
37 <pre> use SDL::Mixer ':all';
40 <p>or access them directly:</p>
41 <pre> SDL::Mixer::MIX_DEFAULT_FREQUENCY;
44 <p>or by choosing the export tags below:</p>
45 <p>Export tag: ':init'</p>
52 <p>Export tag: ':default'</p>
61 <p>Export tag: ':fading'</p>
67 <p>Export tag: ':type'</p>
81 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
82 <div id="DESCRIPTION_CONTENT">
83 <p>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
87 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
88 <div id="METHODS_CONTENT">
91 <h2 id="init">init</h2>
92 <div id="init_CONTENT">
93 <pre> my $init_flags = SDL::Mixer::init( $flags );
96 <p>Loads dynamic libraries and prepares them for use. Flags should be one or more flags from init flags OR'd together.
97 It returns the flags successfully initialized, or 0 on failure.</p>
101 my $init_flags = SDL::Mixer::init( MIX_INIT_MP3 | MIX_INIT_MOD | MIX_INIT_FLAC | MIX_INIT_OGG );
103 print("We have MP3 support!\n") if $init_flags & MIX_INIT_MP3;
104 print("We have MOD support!\n") if $init_flags & MIX_INIT_MOD;
105 print("We have FLAC support!\n") if $init_flags & MIX_INIT_FLAC;
106 print("We have OGG support!\n") if $init_flags & MIX_INIT_OGG;
111 <li>MIX_INIT_MP3 </li>
112 <li>MIX_INIT_MOD </li>
113 <li>MIX_INIT_FLAC </li>
114 <li>MIX_INIT_OGG</li>
117 <p><strong>Note</strong>: Only available for SDL_mixer >= 1.2.10</p>
120 <h2 id="quit">quit</h2>
121 <div id="quit_CONTENT">
122 <pre> SDL::Mixer::quit();
125 <p>This function unloads the liraries previously loaded with <a href="#init">init()</a>.</p>
126 <p><strong>Note</strong>: Only available for SDL_mixer >= 1.2.10</p>
129 <h2 id="linked_version">linked_version</h2>
130 <div id="linked_version_CONTENT">
131 <pre> $version = SDL::Mixer::linked_version();
134 <p><code>linked_version</code> gives you the major-, minor-, and patchlevel for SDL_mixer. This way you can check if e.g. <a href="#init">init()</a> and <a href="#quit">quit()</a>
137 <pre> use SDL::Mixer;
140 my $version = SDL::Mixer::linked_version();
142 printf("%d.%d.%d\n", $version->major, $version->minor, $version->patch); # prints "1.2.8" for me
147 <h2 id="open_audio">open_audio</h2>
148 <div id="open_audio_CONTENT">
149 <pre> my $audio_opened = SDL::Mixer::open_audio( $frequency, $format, $channels, $chunksize );
152 <p><code>open_audio</code> will initialize SDL_mixer if it is not yet initialized, see note. SDL_mixer may not be able to provide the exact specifications
153 your provided, however it will automatically translate between the expected format and the real one. You can retrieve the real format using
154 <a href="http://search.cpan.org/perldoc?query_spec">query_spec</a>. </p>
155 <p>Returns 0 on success, -1 on error.</p>
156 <p><strong>Note</strong>: You must not use <code>AUDIO_S16</code>, <code>AUDIO_U16</code>, <code>AUDIO_S16LSB</code>, or <code>AUDIO_U16LSB.</code> They are not portable, and SDL will not return an
157 error code when they fail. The result will be a horrible staticy noise. You can usually use <code>AUDIO_S16SYS</code>, though not always. Future versions
158 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
159 desired audio type is not supported. </p>
160 <p><strong>Note</strong>: When already initialized, this function will not re-initialize SDL_mixer, nor fail. It will merely increment the number of times
161 <a href="/SDL-Mixer.html#close_audio">SDL::Mixer::close_audio</a> must be called to actually get it to uninitialize. This serves as a very simplistic method for multiple application
162 components to use SDL_mixer without necessitating a great deal of inter-component awareness. Be warned however that in such a situation, the
163 latest components to initialize SDL_mixer will probably not get the SDL_mixer settings they're expecting. </p>
168 printf("Error initializing SDL_mixer: %s\n", SDL::get_error()) unless SDL::Mixer::open_audio(44100, AUDIO_S16, 2, 1024) == 0;
173 <h2 id="close_audio">close_audio</h2>
174 <div id="close_audio_CONTENT">
175 <pre> SDL::Mixer::close_audio();
178 <p>Close the mixer and halting all playing audio. This function does not return anything.</p>
181 <h2 id="query_spec">query_spec</h2>
182 <div id="query_spec_CONTENT">
183 <pre> my @query_spec = @{ SDL::Mixer::query_spec() };
186 <p>Find out what the actual audio device parameters are.
187 This function returns 1 as first array element (status) if the audio has been opened, 0 otherwise.</p>
189 <pre> use SDL::Mixer;
191 my ($status, $freq, $format, $channels) = @{ SDL::Mixer::query_spec() };
193 printf("%s, %s, %s, %s\n", $status, $freq, $format, $channels);
198 <h1 id="AUTHORS">AUTHORS </h1><p><a href="#TOP" class="toplink">Top</a></p>
199 <div id="AUTHORS_CONTENT">
200 <p>Tobias Leich [FROGGS]</p>
203 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
204 <div id="SEE_ALSO_CONTENT">
205 <p><a href="http://search.cpan.org/perldoc?perl">perl</a>, <a href="SDL-Mixer-Channels.html">SDL::Mixer::Channels</a>, <a href="SDL-Mixer-Effects.html">SDL::Mixer::Effects</a>, <a href="SDL-Mixer-Groups.html">SDL::Mixer::Groups</a>, <a href="SDL-Mixer-Music.html">SDL::Mixer::Music</a>.</p>