2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
5 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6 <link rel="stylesheet" href="alut.css" type="text/css"/>
7 <title>The OpenAL Utility Toolkit</title>
11 <h1>The OpenAL Utility Toolkit (ALUT)</h1>
17 <a href="#ReleaseHistory">Release History</a>
20 <a href="#Introduction">Introduction</a>
22 <li><a href="#Licensing">Licensing</a></li>
23 <li><a href="#History">Some History</a></li>
24 <li><a href="#BackwardsCompatibility">Backwards Compatibility with Version 0.x.x</a></li>
25 <li><a href="#OpenGLGLUT">OpenGL, GLUT and using what you already know</a></li>
29 <a href="#CompilingLinking">Compiling and Linking</a>
32 <a href="#API">The ALUT API</a>
35 <a href="#ErrorHandling">Error Handling</a>
37 <li><a href="#alutGetError">alutGetError</a></li>
38 <li><a href="#alutGetErrorString">alutGetErrorString</a></li>
42 <a href="#InitializationExit">Initialization / Exit</a>
44 <li><a href="#alutInit">alutInit</a></li>
45 <li><a href="#alutInitWithoutContext">alutInitWithoutContext</a></li>
46 <li><a href="#alutExit">alutExit</a></li>
50 <a href="#Loading">Sound Sample File Loading</a>
52 <li><a href="#alutCreateBufferFromFile">alutCreateBufferFromFile</a></li>
53 <li><a href="#alutCreateBufferFromFileImage"> alutCreateBufferFromFileImage</a></li>
54 <li><a href="#alutCreateBufferHelloWorld">alutCreateBufferHelloWorld</a></li>
55 <li><a href="#alutCreateBufferWaveform">alutCreateBufferWaveform</a></li>
56 <li><a href="#alutLoadMemoryFromFile">alutLoadMemoryFromFile</a></li>
57 <li><a href="#alutLoadMemoryFromFileImage">alutLoadMemoryFromFileImage</a></li>
58 <li><a href="#alutLoadMemoryHelloWorld">alutLoadMemoryHelloWorld</a></li>
59 <li><a href="#alutLoadMemoryWaveform">alutLoadMemoryWaveform</a></li>
60 <li><a href="#alutGetMIMETypes">alutGetMIMETypes</a></li>
61 <li><a href="#DeprecatedWAVLoaders">Deprecated WAV loaders</a></li>
65 <a href="#VersionChecking">Version Checking</a>
67 <li><a href="#alutGetMajorVersion">alutGetMajorVersion</a></li>
68 <li><a href="#alutGetMinorVersion">alutGetMinorVersion</a></li>
69 <li><a href="#VersioningMacros">Compile Time Version Checking</a></li>
73 <a href="#Sleeping">Sleeping</a>
75 <li><a href="#alutSleep">alutSleep</a></li>
82 <h1><a name="ReleaseHistory"></a>Release History</h1>
84 <p>Discussion of the API is done via the <a
85 href="mailto:openal-devel@opensource.creative.com">openal-devel</a> mailing
89 <li>2005-08-14: Version 1.0.0 by Steve Baker</li>
90 <li>2005-09-02: Version 1.0.1 by Sven Panne</li>
91 <li>2005-09-10: Version 1.0.2 by Sven Panne</li>
92 <li>2005-09-26: Version 1.0.3 by Sven Panne</li>
93 <li>2005-09-28: Version 1.0.4 by Sven Panne</li>
94 <li>2005-10-29: Version 1.0.5 by Sven Panne</li>
95 <li>2005-11-19: Version 1.0.6 by Sven Panne</li>
96 <li>2006-04-10: Version 1.0.7 by Sven Panne</li>
97 <li>2006-04-11: Version 1.1.0 by Sven Panne</li>
100 <h1><a name="Introduction"></a>Introduction</h1>
102 <p>This is the <a href="http://www.openal.org/">OpenAL</a> Utility Toolkit
103 (ALUT) Reference Manual.</p>
105 <h2><a name="Licensing"></a>Licensing</h2>
107 <p>Some previous versions of ALUT were released under the BSD license -
108 others under LGPL. This version will be released exclusively under LGPL.</p>
110 <h2><a name="History"></a>Some History</h2>
112 <p>At the time of the first writing of this document (August 2005), ALUT was
113 a set of undocumented semi-portable functions that were mixed up in the
114 OpenAL library distribution. The intent had always been that ALUT would be a
115 cleanly separated library that would be portable between systems. It was
116 hoped that it would be well suited to producing succinct demo programs and
117 to help new developers to get started with OpenAL. It was to do this by
118 removing the annoying details of getting an audio application started -
119 allowing developers to learn OpenAL without distractions such as loading
120 sound samples from disk.</p>
122 <p>In order to move from this initial implementation to a clean API that
123 would meet the original goals of ALUT, it was necessary to break from the
124 past and make a clean start. The original version(s) were unnumbered - so we
125 will arbitarily label all previous versions as 0.x.x and start this cleaned
126 up version at release 1.0.0 to reflect changed API and implementations.</p>
128 <h2><a name="BackwardsCompatibility"></a>Backwards Compatibility with Version 0.x.x</h2>
130 <p>There are no formal guarantees of reverse compatibility with the various
131 versions of ALUT prior to 1.0.0. Having said that, some effort has been made
132 to at least allow these programs to continue to run if they are recompiled
133 against ALUT 1.0.0 or later.</p>
135 <p>The old Linux implementation of OpenAL poses a special compatibility
136 problem: ALUT 0.x.x was not a physically separate library on this platform,
137 it was actually part of libopenal itself. This is bad for at least two
138 reasons: It was handled differently on other platforms and much more
139 seriously it locked together OpenAL and ALUT releases. So a deliberate
140 decision was made to break binary compatibility in this respect and cleanly
141 split the libraries into an OpenAL (i.e. AL and ALC) part and an ALUT
144 <p>If you have a program which needs such an old, deprecated "combined
145 OpenAL/ALUT" and you are not able to recompile it for some reason
146 (e.g. it is available in binary format only), then temporarily setting the
147 environment variable <tt>LD_PRELOAD</tt> to the full path of your installed
148 ALUT dynamic library can help. If this really works depends on the platform,
149 but e.g. Linux, FreeBSD, NetBSD, Solaris etc. support this mechanism. On Mac
150 OS X there is a similar environment variable called
151 <tt>DYLD_INSERT_LIBRARIES</tt>, but this has not been tested yet.</p>
153 <div class="example">
154 <h4>Example: Using a legacy program with the new ALUT</h4>
156 <p>Let's assume that your ALUT dynamic library is at the usual location
157 <tt>/usr/lib/libalut.so</tt> and you have an old program called
158 <tt>myOldProg</tt>, then the following commandline in Bash syntax does the
161 <pre class="programlisting">
162 LD_PRELOAD="/usr/lib/libalut.so" myOldProg
165 <p>Note that setting <tt>LD_PRELOAD</tt> globally might not be a good idea,
166 because in that case the new ALUT would be loaded before <em>every</em>
167 dynamically linked executable.</p>
171 <h2><a name="OpenGLGLUT"></a>OpenGL, GLUT and using what you already know</h2>
173 <p>If you are already familiar with OpenGL and its utility toolkit GLUT,
174 then you should feel very familiar with ALUT. Wherever GLUT has 'GL', ALUT
175 has 'AL' and wherever GLUT has 'glut', ALUT has 'alut'. 'Window' is replaced
176 with 'Context' throughout the API.</p>
178 <div class="example">
179 <h4>Example: 'Hello, world' in ALUT</h4>
181 <p>Here is the traditional first program for any language or library, but
182 this time it is actually <em>saying</em> 'Hello, world!' instead of
185 <pre class="programlisting">
186 #include <stdlib.h>
187 #include <AL/alut.h>
190 main (int argc, char **argv)
192 ALuint helloBuffer, helloSource;
193 alutInit (&argc, argv);
194 helloBuffer = alutCreateBufferHelloWorld ();
195 alGenSources (1, &helloSource);
196 alSourcei (helloSource, AL_BUFFER, helloBuffer);
197 alSourcePlay (helloSource);
204 <p>Note that there error checks are missing in the program above to keep
209 <h3><a name="CompilingLinking"></a>Compiling and Linking</h3>
211 <p>All ALUT programs should contain:</p>
213 <pre class="programlisting">
214 #include <AL/alut.h>
217 <p>The ALUT header includes <tt><AL/al.h></tt> and
218 <tt><AL/alc.h></tt> for you so you don't need to include them again -
219 although it does not hurt to do so. ALUT reserves the
220 "<tt>ALUT_</tt>" prefix for preprocessor macros, so you should
221 never define such a macro in your own program. Furthermore, you should not
222 rely on any macro starting with "<tt>ALUT_</tt>" not mentioned in
223 this specification.</p>
225 <p>If you are using the freealut implementation of ALUT, which is available
226 via the <a href="http://www.openal.org/">OpenAL homepage</a>, you can find
227 out the necessary compilation flags by using one of the following
231 pkg-config --cflags freealut
232 freealut-config --cflags
235 <p>To find out the necessary flags for linking, use one of the following
239 pkg-config --libs freealut
240 freealut-config --libs
243 <p>On Windows, link with <tt>alut.dll</tt> and <tt>openal32.dll</tt>.</p>
245 <p>ALUT reserves the "<tt>alut</tt>" prefix for globally visible
246 functions and variables, so you should never define such a function or
247 variable in your own program. Furthermore, you should not rely on any such
248 function or variable not mentioned in this specification.</p>
250 <h1><a name="API"></a>The ALUT API</h1>
252 <h2><a name="ErrorHandling"></a>Error Handling</h2>
254 <p>ALUT's error handling and reporting is a little bit different from the
255 one used in OpenAL and OpenGL: All functions which can fail report
256 success/failure via a return value, where <tt>AL_FALSE</tt> /
257 <tt>AL_NONE</tt> / <tt>NULL</tt> mean failure. <tt>alutGetError</tt> can be
258 used to find out what exactly went wrong.</p>
260 <p>It is guaranteed that if a function fails, no data pointed to by pointer
261 arguments has been changed.</p>
263 <h3 class="manpage"><a name="alutGetError"></a>alutGetError</h3>
267 <p><tt>alutGetError</tt> - return and clear the current error state</p>
271 <pre class="programlisting">
272 ALenum alutGetError (void);
277 <p>Any ALUT routine that fails will return <tt>AL_FALSE</tt> /
278 <tt>AL_NONE</tt> / <tt>NULL</tt> and set the global error state. If a
279 subsequent error occurs while there is still an error recorded internally,
280 the second error will simply be ignored. Calling <tt>alutGetError</tt> will
281 reset the error code to <tt>ALUT_ERROR_NO_ERROR</tt>. Note that the error
282 state is <em>not</em> cleared by other successful ALUT calls.</p>
284 <h4>Return Value</h4>
286 <p><tt>alutGetError</tt> returns the contents of the global error state,
287 which can be one of the following values:</p>
290 <dt><tt>ALUT_ERROR_NO_ERROR</tt></dt>
291 <dd>No ALUT error found.</dd>
293 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
294 <dd>ALUT ran out of memory.</dd>
296 <dt><tt>ALUT_ERROR_INVALID_ENUM</tt></dt>
297 <dd>ALUT was given an invalid enumeration token.</dd>
299 <dt><tt>ALUT_ERROR_INVALID_VALUE</tt></dt>
300 <dd>ALUT was given an invalid value.</dd>
302 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
303 <dd>The operation is invalid in the current ALUT state.</dd>
305 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
306 <dd>There is no current AL context.</dd>
308 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
309 <dd>There was already an AL error on entry to an ALUT function.</dd>
311 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
312 <dd>There was already an ALC error on entry to an ALUT function.</dd>
314 <dt><tt>ALUT_ERROR_OPEN_DEVICE</tt></dt>
315 <dd>There was an error opening the ALC device.</dd>
317 <dt><tt>ALUT_ERROR_CLOSE_DEVICE</tt></dt>
318 <dd>There was an error closing the ALC device.</dd>
320 <dt><tt>ALUT_ERROR_CREATE_CONTEXT</tt></dt>
321 <dd>There was an error creating an ALC context.</dd>
323 <dt><tt>ALUT_ERROR_MAKE_CONTEXT_CURRENT</tt></dt>
324 <dd>Could not change the current ALC context.</dd>
326 <dt><tt>ALUT_ERROR_DESTROY_CONTEXT</tt></dt>
327 <dd>There was an error destroying the ALC context.</dd>
329 <dt><tt>ALUT_ERROR_GEN_BUFFERS</tt></dt>
330 <dd>There was an error generating an AL buffer.</dd>
332 <dt><tt>ALUT_ERROR_BUFFER_DATA</tt></dt>
333 <dd>There was an error passing buffer data to AL.</dd>
335 <dt><tt>ALUT_ERROR_IO_ERROR</tt></dt>
336 <dd>I/O error, consult <tt>errno</tt> for more details.</dd>
338 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_TYPE</tt></dt>
339 <dd>Unsupported file type.</dd>
341 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE</tt></dt>
342 <dd>Unsupported mode within an otherwise usable file type.</dd>
344 <dt><tt>ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA</tt></dt>
345 <dd>The sound data was corrupt or truncated.</dd>
350 <p><tt>alutGetError</tt> can be called in any ALUT state and will never
353 <h3 class="manpage"><a name="alutGetErrorString"></a>alutGetErrorString</h3>
357 <p><tt>alutGetErrorString</tt> - return an error message string
358 given an error code</p>
362 <pre class="programlisting">
363 const char *alutGetErrorString (ALenum error);
368 <p><tt>alutGetErrorString</tt> can be used to convert an error code into a
369 human-readable description. The precise text of these descriptions may vary
370 from implementation to implementation and should not be relied upon by the
373 <h4>Return Value</h4>
375 <p><tt>alutGetErrorString</tt> returns a pointer to an immutable
376 zero-terminated string corresponding to the given error code.</p>
380 <p><tt>alutGetErrorString</tt> can be called in any ALUT state and
381 will never fail. An unknown error code is not considered an error
382 and a generic description will be returned in that case.</p>
384 <div class="example">
385 <h4>Example: Context Handling and Error Reporting</h4>
387 <p>A typical ALUT program might look like this:</p>
389 <pre class="programlisting">
393 fprintf (stderr, "ALUT error: %s\n",
394 alutGetErrorString (alutGetError ()));
399 main (int argc, char **argv)
401 if (!alutInit (&argc, argv))
406 /* ...play audio for a while... */
418 <h2><a name="InitializationExit"></a>Initialization / Exit</h2>
420 <p>ALUT starts in an <em>uninitialized</em> state. <tt>alutInit</tt> and
421 <tt>alutInitWithoutContext</tt> put ALUT into the <em>initialized</em>
422 state. Those functions must only be called when the state is
423 <em>uninitialized</em>. <tt>alutExit</tt> puts ALUT back from an
424 <em>initialized</em> state to an <em>uninitialized</em> one.</p>
426 <p>The following functions must only be called in an <em>initialized</em>
427 state and with a current context: <tt>alutExit</tt>,
428 <tt>alutCreateBufferFromFile</tt>, <tt>alutCreateBufferFromFileImage</tt>,
429 <tt>alutLoadMemoryFromFile</tt>, <tt>alutLoadMemoryFromFileImage</tt>,
430 <tt>alutGetMIMETypes</tt>, <tt>alutCreateBufferHelloWorld</tt>,
431 <tt>alutCreateBufferWaveform</tt>. All these functions check for AL/ALC
432 errors on entry and immediately return <tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt>
433 or <tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt> if there was one. Note that as a
434 consequence of these checks the AL/ALC error states for the current
435 context/device are cleared after calling any of these functions.</p>
437 <p><tt>alutSleep</tt> can be called in every state.</p>
439 <p>The following functions never fail and can be called in any state:
440 <tt>alutGetError</tt>, <tt>alutGetErrorString</tt>,
441 <tt>alutGetMajorVersion</tt>, <tt>alutGetMinorVersion</tt>.</p>
443 <h3 class="manpage"><a name="alutInit"></a>alutInit</h3>
447 <p><tt>alutInit</tt> - initialize the ALUT library and create a default
452 <pre class="programlisting">
453 ALboolean alutInit (int *argcp, char **argv);
458 <p><tt>alutInit</tt> initializes the ALUT internals and creates an OpenAL
459 context on the default device and makes it the current OpenAL context. If
460 you want something more complex than that (e.g. running on a non-default
461 device or opening multiple contexts on multiple devices), you can use <a
462 href="#alutInitWithoutContext"><tt>alutInitWithoutContext</tt></a>
463 instead. <tt>alutInit</tt> examines the commandline arguments passed to it
464 and remove those it recognizes. It is acceptable to pass two <tt>NULL</tt>
465 pointers in settings where no useful information can be obtained from argc
468 <h4>Return Value</h4>
470 <p><tt>alutInit</tt> returns <tt>AL_TRUE</tt> on success or
471 <tt>AL_FALSE</tt> on failure.</p>
476 <dt><tt>ALUT_ERROR_INVALID_VALUE</tt></dt>
477 <dd>One of the arguments was <tt>NULL</tt>, but not the other one.</dd>
479 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
480 <dd>ALUT has already been initialized.</dd>
482 <dt><tt>ALUT_ERROR_OPEN_DEVICE</tt></dt>
483 <dd>There was an error opening the default ALC device.</dd>
485 <dt><tt>ALUT_ERROR_CREATE_CONTEXT</tt></dt>
486 <dd>There was an error creating an ALC context.</dd>
488 <dt><tt>ALUT_ERROR_MAKE_CONTEXT_CURRENT</tt></dt>
489 <dd>Could not change the current ALC context.</dd>
492 <div class="example">
493 <h4>Example: Handling command-line options</h4>
495 <p>If you pass <tt>alutInit</tt> the argc and argv from your main program,
496 it will examine your command-line options and use (and remove) those
497 options that it recognises:</p>
499 <pre class="programlisting">
501 main (int argc, char **argv)
503 alutInit (&argc, argv);
508 <p>Precisely which (if any) command-line options are accepted and what
509 they control is implementation and operating system dependent. Note that
510 some implementations will use argv[0] in debug and error messages - but
511 this is not guaranteed by the API because it is operating-system
512 dependent. On some OS's, <tt>alutInit</tt> may use initial settings from
513 other sources such as 'registry' data, '<tt>.alutrc</tt>' files or shell
514 variables. Please consult the README.xxx file for your OS if you need
518 <h3 class="manpage"><a name="alutInitWithoutContext"></a>alutInitWithoutContext</h3>
522 <p><tt>alutInitWithoutContext</tt> - initialize the ALUT library</p>
526 <pre class="programlisting">
527 ALboolean alutInitWithoutContext (int *argcp, char **argv);
532 <p><tt>alutInitWithoutContext</tt> initializes the ALUT internals. It does
533 not create any OpenAL context or device, so this has to be done via the
534 usual ALC calls. <tt>alutInitWithoutContext</tt> examines the commandline
535 arguments passed to it and remove those it recognizes. It is acceptable to
536 pass two <tt>NULL</tt> pointers in settings where no useful information can
537 be obtained from argc and argv.</p>
539 <h4>Return Value</h4>
541 <p><tt>alutInitWithoutContext</tt> returns <tt>AL_TRUE</tt> on success or
542 <tt>AL_FALSE</tt> on failure.</p>
547 <dt><tt>ALUT_ERROR_INVALID_VALUE</tt></dt>
548 <dd>One of the arguments was <tt>NULL</tt>, but not the other one.</dd>
550 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
551 <dd>ALUT has already been initialized.</dd>
554 <h3 class="manpage"><a name="alutExit"></a>alutExit</h3>
558 <p><tt>alutExit</tt> - shutdown the ALUT library</p>
562 <pre class="programlisting">
563 ALboolean alutExit (void);
568 <p>When the application has finished playing audio, it should shut down ALUT
569 using <tt>aluExit</tt>. This closes any OpenAL device/context that ALUT may
570 have created in <tt>alutInit</tt> (but not any that the application created
571 using ALC). After calling <tt>alutExit</tt>, you may subsequently call
572 <tt>alutInit</tt> or <tt>alutInitWithoutContext</tt> again. Note that under
573 well-behaved operating systems, it should be acceptable to simply exit from
574 your program without bothering to call <tt>alutExit</tt>, relying on the OS
575 to clean up after you. However, it is dangerous to rely on this behavior if
576 portable operation is expected.</p>
578 <h4>Return Value</h4>
580 <p><tt>alutExit</tt> returns <tt>AL_TRUE</tt> on success or
581 <tt>AL_FALSE</tt> on failure.</p>
586 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
587 <dd>ALUT has not been initialised.</dd>
589 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
590 <dd>There is no current AL context.</dd>
592 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
593 <dd>There was already an AL error on entry to <tt>alutExit</tt>.</dd>
595 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
596 <dd>There was already an ALC error on entry to <tt>alutExit</tt>.</dd>
598 <dt><tt>ALUT_ERROR_CLOSE_DEVICE</tt></dt>
599 <dd>There was an error closing the ALC device created by
600 <tt>alutInit</tt>.</dd>
602 <dt><tt>ALUT_ERROR_MAKE_CONTEXT_CURRENT</tt></dt>
603 <dd>Could not release the current ALC context.</dd>
605 <dt><tt>ALUT_ERROR_DESTROY_CONTEXT</tt></dt>
606 <dd>There was an error destroying the ALC context created by
607 <tt>alutInit</tt>.</dd>
610 <h2><a name="Loading"></a>Sound Sample File Loading</h2>
612 <p>ALUT attempts to simplify the business of getting a simple application
613 running by providing loaders for a range of file formats. Rather than
614 enumerate a list of formats that will likely grow with time, the loaders are
615 generic and try to do their best either by using OpenAL extensions if
616 possible or by converting the sound data into standard OpenAL formats.</p>
618 <p>In order to simplify initial startup and to keep test program
619 distributions clean, ALUT provides built-in sounds, too, that do not require
620 disk I/O because they are built into the ALUT library. These functions may
621 be used to write compact ALUT test/example applications with no external
622 file dependancies whatsoever. When sending short application programs to
623 either the ALUT or OpenAL developers as a part of bug reporting, one should
624 endeavor to use these functions instead of loading ones own sound files.</p>
626 <p>There are eight (= 4 * 2) different loaders, corresponding to the sources
627 and destinations of the sound data. The possible sources are:</p>
630 <li>The loaders with a <tt>FromFile</tt> suffix get their sound data from
633 <li>The loaders with a <tt>FromFileImage</tt> suffix get their data from a
634 continuous memory region. This region can be re-used or destroyed
637 <li>The loaders with a <tt>HelloWorld</tt> suffix get their fixed data
640 <li>The loaders with a <tt>Waveform</tt> suffix get their data via
641 internal waveform calculation.</li>
644 <p>The possible destinations are:</p>
647 <li>The loaders with a <tt>alutCreateBuffer</tt> prefix create a new
648 OpenAL buffer and put the sound data into it. If possible, OpenAL
649 extensions are used to avoid conversions at the ALUT level and enable the
650 use of possible hardware/driveer features for some sound
651 formats. Therefore, these are the preferred loaders.</li>
653 <li>The loaders with a <tt>alutLoadMemory</tt> prefix allocate a new
654 memory region with <tt>malloc</tt> and put the sound data into it,
655 optionally passing back more information about the sound. The sound data
656 is guaranteed to be in one of the four standard OpenAL formats (8/16bit
657 monon/stereo) aftwerwards. Because no OpenAL extensions can be used here,
658 these loaders might handle fewer sound formats than the
659 <tt>alutCreateBuffer</tt> ones.</li>
662 <h3 class="manpage"><a name="alutCreateBufferFromFile"></a>alutCreateBufferFromFile</h3>
666 <p><tt>alutCreateBufferFromFile</tt> - load a sound file into an OpenAL
671 <pre class="programlisting">
672 ALuint alutCreateBufferFromFile (const char *filename);
675 <p><tt>alutCreateBufferFromFile</tt> tries to guess the sound data format by
676 looking at the filename and/or the file contents and loads the sound data
677 into an OpenAL buffer.</p>
679 <h4>Return Value</h4>
681 <p>On success, <tt>alutCreateBufferFromFile</tt> returns a handle to an
682 OpenAL buffer containing the loaded sound. It returns <tt>AL_NONE</tt> on
688 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
689 <dd>ALUT ran out of memory.</dd>
691 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
692 <dd>ALUT has not been initialised.</dd>
694 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
695 <dd>There is no current AL context.</dd>
697 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
698 <dd>There was already an AL error on entry to
699 <tt>alutCreateBufferFromFile</tt>.</dd>
701 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
702 <dd>There was already an ALC error on entry to
703 <tt>alutCreateBufferFromFile</tt>.</dd>
705 <dt><tt>ALUT_ERROR_GEN_BUFFERS</tt></dt>
706 <dd>There was an error generating an AL buffer.</dd>
708 <dt><tt>ALUT_ERROR_BUFFER_DATA</tt></dt>
709 <dd>There was an error passing buffer data to AL.</dd>
711 <dt><tt>ALUT_ERROR_IO_ERROR</tt></dt>
712 <dd>I/O error, consult <tt>errno</tt> for more details.</dd>
714 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_TYPE</tt></dt>
715 <dd>Unsupported file type.</dd>
717 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE</tt></dt>
718 <dd>Unsupported mode within an otherwise usable file type.</dd>
720 <dt><tt>ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA</tt></dt>
721 <dd>The sound data was corrupt or truncated.</dd>
724 <h3 class="manpage"><a name="alutCreateBufferFromFileImage"></a>alutCreateBufferFromFileImage</h3>
728 <p><tt>alutCreateBufferFromFileImage</tt> - load in-memory sound data into
733 <pre class="programlisting">
734 ALuint alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
737 <p><tt>alutCreateBufferFromFileImage</tt> tries to guess the sound data
738 format by looking at the contents of the memory region given as parameters
739 and loads the sound data into an OpenAL buffer.</p>
741 <h4>Return Value</h4>
743 <p>On success, <tt>alutCreateBufferFromFileImage</tt> returns a handle to an
744 OpenAL buffer containing the loaded sound. It returns <tt>AL_NONE</tt> on
750 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
751 <dd>ALUT ran out of memory.</dd>
753 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
754 <dd>ALUT has not been initialised.</dd>
756 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
757 <dd>There is no current AL context.</dd>
759 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
760 <dd>There was already an AL error on entry to
761 <tt>alutCreateBufferFromFileImage</tt>.</dd>
763 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
764 <dd>There was already an ALC error on entry to
765 <tt>alutCreateBufferFromFileImage</tt>.</dd>
767 <dt><tt>ALUT_ERROR_GEN_BUFFERS</tt></dt>
768 <dd>There was an error generating an AL buffer.</dd>
770 <dt><tt>ALUT_ERROR_BUFFER_DATA</tt></dt>
771 <dd>There was an error passing buffer data to AL.</dd>
773 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_TYPE</tt></dt>
774 <dd>Unsupported file type.</dd>
776 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE</tt></dt>
777 <dd>Unsupported mode within an otherwise usable file type.</dd>
779 <dt><tt>ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA</tt></dt>
780 <dd>The sound data was corrupt or truncated.</dd>
783 <h3 class="manpage"><a name="alutCreateBufferHelloWorld"></a>alutCreateBufferHelloWorld</h3>
787 <p><tt>alutCreateBufferHelloWorld</tt> - create a buffer with a 'Hello, world!' sound</p>
791 <pre class="programlisting">
792 ALuint alutCreateBufferHelloWorld (void);
797 <p><tt>alutCreateBufferHelloWorld</tt> returns a handle to an OpenAL buffer
798 containing the sound of someone saying 'Hello, world!'.</p>
800 <h4>Return Value</h4>
802 <p>On success, <tt>alutCreateBufferHelloWorld</tt> returns a handle to an
803 OpenAL buffer containing a 'Hello, world!' sound. It returns
804 <tt>AL_NONE</tt> on failure.</p>
809 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
810 <dd>ALUT ran out of memory.</dd>
812 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
813 <dd>ALUT has not been initialised.</dd>
815 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
816 <dd>There is no current AL context.</dd>
818 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
819 <dd>There was already an AL error on entry to
820 <tt>alutCreateBufferHelloWorld</tt>.</dd>
822 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
823 <dd>There was already an ALC error on entry to
824 <tt>alutCreateBufferHelloWorld</tt>.</dd>
826 <dt><tt>ALUT_ERROR_GEN_BUFFERS</tt></dt>
827 <dd>There was an error generating an AL buffer.</dd>
829 <dt><tt>ALUT_ERROR_BUFFER_DATA</tt></dt>
830 <dd>There was an error passing buffer data to AL.</dd>
833 <h3 class="manpage"><a name="alutCreateBufferWaveform"></a>alutCreateBufferWaveform</h3>
837 <p><tt>alutCreateBufferWaveform</tt> - create a buffer with a synthesized waveform sound</p>
841 <pre class="programlisting">
842 ALuint alutCreateBufferWaveform (ALenum waveshape,
850 <p><tt>alutCreateBufferWaveform</tt> returns a handle to an OpenAL buffer
851 containing a snippet of audio with the specified waveshape at the specified
852 frequency (in Hertz), phase (in degrees: -180 to +180) and duration (in
853 seconds). Allowed waveforms are:</p>
856 <li><tt>ALUT_WAVEFORM_SINE</tt></li>
857 <li><tt>ALUT_WAVEFORM_SQUARE</tt></li>
858 <li><tt>ALUT_WAVEFORM_SAWTOOTH</tt></li>
859 <li><tt>ALUT_WAVEFORM_WHITENOISE</tt></li>
860 <li><tt>ALUT_WAVEFORM_IMPULSE</tt></li>
863 <p>The duration will always be rounded up to an exact number of cycles of
864 the sound to avoid a click if you loop the sample. The frequency and phase
865 arguments are ignored for <tt>ALUT_WHITENOISE</tt>.</p>
867 <h4>Return Value</h4>
869 <p>On success, <tt>alutCreateBufferWaveform</tt> returns a handle to an
870 OpenAL buffer containing the synthesized waveform. It returns
871 <tt>AL_NONE</tt> on failure.</p>
876 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
877 <dd>ALUT ran out of memory.</dd>
879 <dt><tt>ALUT_ERROR_INVALID_ENUM</tt></dt>
880 <dd>An invalid waveform token was given to
881 <tt>alutCreateBufferWaveform</tt>.</dd>
883 <dt><tt>ALUT_ERROR_INVALID_VALUE</tt></dt>
884 <dd>The frequency was not positive or the duration was negative.</dd>
886 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
887 <dd>ALUT has not been initialised.</dd>
889 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
890 <dd>There is no current AL context.</dd>
892 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
893 <dd>There was already an AL error on entry to
894 <tt>alutCreateBufferWaveform</tt>.</dd>
896 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
897 <dd>There was already an ALC error on entry to
898 <tt>alutCreateBufferWaveform</tt>.</dd>
900 <dt><tt>ALUT_ERROR_GEN_BUFFERS</tt></dt>
901 <dd>There was an error generating an AL buffer.</dd>
903 <dt><tt>ALUT_ERROR_BUFFER_DATA</tt></dt>
904 <dd>There was an error passing buffer data to AL.</dd>
907 <h3 class="manpage"><a name="alutLoadMemoryFromFile"></a>alutLoadMemoryFromFile</h3>
911 <p><tt>alutLoadMemoryFromFile</tt> - load a sound file into OpenAL-like
916 <pre class="programlisting">
917 ALvoid *alutLoadMemoryFromFile (const char *filename,
923 <p><tt>alutLoadMemoryFromFile</tt> tries to guess the sound data format by
924 looking at the filename and/or the file contents and loads the sound data
925 into a newly <tt>malloc</tt>ed buffer, possibly converting it in the
926 process. The format is guaranteed to be a standard OpenAL format
929 <h4>Return Value</h4>
931 <p>On success, <tt>alutLoadMemoryFromFile</tt> returns a pointer to a newly
932 allocated memory area containing the sound data, which can be <tt>free</tt>d
933 if not needed anymore. It returns <tt>NULL</tt> on failure. If any of the
934 format, size or frequency parameters are non-<tt>NULL</tt>, the respective
935 information about the sound will be passed back.</p>
940 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
941 <dd>ALUT ran out of memory.</dd>
943 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
944 <dd>ALUT has not been initialised.</dd>
946 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
947 <dd>There is no current AL context.</dd>
949 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
950 <dd>There was already an AL error on entry to
951 <tt>alutLoadMemoryFromFile</tt>.</dd>
953 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
954 <dd>There was already an ALC error on entry to
955 <tt>alutLoadMemoryFromFile</tt>.</dd>
957 <dt><tt>ALUT_ERROR_IO_ERROR</tt></dt>
958 <dd>I/O error, consult <tt>errno</tt> for more details.</dd>
960 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_TYPE</tt></dt>
961 <dd>Unsupported file type.</dd>
963 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE</tt></dt>
964 <dd>Unsupported mode within an otherwise usable file type.</dd>
966 <dt><tt>ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA</tt></dt>
967 <dd>The sound data was corrupt or truncated.</dd>
970 <h3 class="manpage"><a name="alutLoadMemoryFromFileImage"></a>alutLoadMemoryFromFileImage</h3>
974 <p><tt>alutLoadMemoryFromFileImage</tt> - convert in-memory sound data into
979 <pre class="programlisting">
980 ALvoid *alutLoadMemoryFromFileImage (const ALvoid *data,
987 <p><tt>alutLoadMemoryFromFileImage</tt> tries to guess the sound data format
988 by looking at the contents of the memory region given as the first two
989 arguments and loads the sound data into a newly <tt>malloc</tt>ed buffer,
990 possibly converting it in the process. The format is guaranteed to be a
991 standard OpenAL format afterwards.</p>
993 <h4>Return Value</h4>
995 <p>On success, <tt>alutLoadMemoryFromFileImage</tt> returns a pointer to a
996 newly allocated memory area containing the sound data, which can be
997 <tt>free</tt>d if not needed anymore. It returns <tt>NULL</tt> on
998 failure. If any of the format, size or frequency parameters are
999 non-<tt>NULL</tt>, the respective information about the sound will be passed
1005 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
1006 <dd>ALUT ran out of memory.</dd>
1008 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
1009 <dd>ALUT has not been initialised.</dd>
1011 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
1012 <dd>There is no current AL context.</dd>
1014 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
1015 <dd>There was already an AL error on entry to
1016 <tt>alutLoadMemoryFromFileImage</tt>.</dd>
1018 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
1019 <dd>There was already an ALC error on entry to
1020 <tt>alutLoadMemoryFromFileImage</tt>.</dd>
1022 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_TYPE</tt></dt>
1023 <dd>Unsupported file type.</dd>
1025 <dt><tt>ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE</tt></dt>
1026 <dd>Unsupported mode within an otherwise usable file type.</dd>
1028 <dt><tt>ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA</tt></dt>
1029 <dd>The sound data was corrupt or truncated.</dd>
1032 <h3 class="manpage"><a name="alutLoadMemoryHelloWorld"></a>alutLoadMemoryHelloWorld</h3>
1036 <p><tt>alutLoadMemoryHelloWorld</tt> - load a 'Hello, world!' sound into
1037 OpenAL-like data</p>
1041 <pre class="programlisting">
1042 ALvoid *alutLoadMemoryHelloWorld (ALenum *format,
1044 ALfloat *frequency);
1048 <h4>Description</h4>
1050 <p><tt>alutLoadMemoryHelloWorld</tt> loads the sound of someone saying
1051 'Hello, world!' into a newly <tt>malloc</tt>ed buffer. The sound data is
1052 guaranteed to be in a standard OpenAL format, with a sample frequency chosen
1053 by the ALUT implementation.</p>
1055 <h4>Return Value</h4>
1057 <p>On success, <tt>alutLoadMemoryHelloWorld</tt> returns a pointer to a
1058 newly allocated memory area containing the sound data, which can be
1059 <tt>free</tt>d if not needed anymore. It returns <tt>NULL</tt> on
1060 failure. If any of the format, size or frequency parameters are
1061 non-<tt>NULL</tt>, the respective information about the sound will be passed
1067 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
1068 <dd>ALUT ran out of memory.</dd>
1070 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
1071 <dd>ALUT has not been initialised.</dd>
1073 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
1074 <dd>There is no current AL context.</dd>
1076 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
1077 <dd>There was already an AL error on entry to
1078 <tt>alutLoadMemoryHelloWorld</tt>.</dd>
1080 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
1081 <dd>There was already an ALC error on entry to
1082 <tt>alutLoadMemoryHelloWorld</tt>.</dd>
1085 <h3 class="manpage"><a name="alutLoadMemoryWaveform"></a>alutLoadMemoryWaveform</h3>
1089 <p><tt>alutLoadMemoryWaveform</tt> - load a synthesized waveform sound into
1090 OpenAL-like data</p>
1094 <pre class="programlisting">
1095 ALvoid *alutLoadMemoryWaveform (ALenum waveshape,
1101 ALfloat *sampleFrequency);
1104 <h4>Description</h4>
1106 <p><tt>alutLoadMemoryWaveform</tt> loads a snippet of audio with the
1107 specified waveshape at the specified frequency (in Hertz), phase (in
1108 degrees: -180 to +180) and duration (in seconds) into a newly
1109 <tt>malloc</tt>ed buffer. The sound data is guaranteed to be in a standard
1110 OpenAL format, with a sample frequency chosen by the ALUT
1111 implementation. Allowed waveforms are:</p>
1114 <li><tt>ALUT_WAVEFORM_SINE</tt></li>
1115 <li><tt>ALUT_WAVEFORM_SQUARE</tt></li>
1116 <li><tt>ALUT_WAVEFORM_SAWTOOTH</tt></li>
1117 <li><tt>ALUT_WAVEFORM_WHITENOISE</tt></li>
1118 <li><tt>ALUT_WAVEFORM_IMPULSE</tt></li>
1121 <p>The duration will always be rounded up to an exact number of cycles of
1122 the sound to avoid a click if you loop the sample. The frequency and phase
1123 arguments are ignored for <tt>ALUT_WHITENOISE</tt>.</p>
1125 <h4>Return Value</h4>
1127 <p>On success, <tt>alutLoadMemoryWaveform</tt> returns a pointer to a newly
1128 allocated memory area containing the sound data, which can be <tt>free</tt>d
1129 if not needed anymore. It returns <tt>NULL</tt> on failure. If any of the
1130 format, size or sample frequency parameters are non-<tt>NULL</tt>, the
1131 respective information about the sound will be passed back.</p>
1136 <dt><tt>ALUT_ERROR_OUT_OF_MEMORY</tt></dt>
1137 <dd>ALUT ran out of memory.</dd>
1139 <dt><tt>ALUT_ERROR_INVALID_ENUM</tt></dt>
1140 <dd>An invalid waveform token was given to
1141 <tt>alutLoadMemoryWaveform</tt>.</dd>
1143 <dt><tt>ALUT_ERROR_INVALID_VALUE</tt></dt>
1144 <dd>The frequency was not positive or the duration was negative.</dd>
1146 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
1147 <dd>ALUT has not been initialised.</dd>
1149 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
1150 <dd>There is no current AL context.</dd>
1152 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
1153 <dd>There was already an AL error on entry to
1154 <tt>alutLoadMemoryWaveform</tt>.</dd>
1156 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
1157 <dd>There was already an ALC error on entry to
1158 <tt>alutLoadMemoryWaveform</tt>.</dd>
1161 <h3 class="manpage"><a name="alutGetMIMETypes"></a>alutGetMIMETypes</h3>
1165 <p><tt>alutGetMIMETypes</tt> - get list support supported audio MIME types</p>
1169 <pre class="programlisting">
1170 const char *alutGetMIMETypes (ALenum loader);
1173 <h4>Description</h4>
1175 <p><tt>alutGetMIMETypes</tt> returns a comma-separated list of
1176 supported MIME types for the given loader type, e.g. something like
1177 "<tt>audio/basic,audio/mpeg,audio/x-wav</tt>". Allowed loader
1181 <dt><tt>ALUT_LOADER_BUFFER</tt></dt>
1183 <dd>For the loaders returning sound data in an OpenAL buffer,
1184 e.g. <tt>alutCreateBufferFromFile</tt> and
1185 <tt>alutCreateBufferFromFileImage</tt></dd>
1187 <dt><tt>ALUT_LOADER_MEMORY</tt></dt>
1189 <dd>For the loaders returning sound data in a newly allocated memory
1190 region, e.g. <tt>alutLoadMemoryFromFile</tt> and
1191 <tt>alutLoadMemoryFromFileImage</tt></dd>
1194 <p>It is possible that <tt>ALUT_LOADER_MEMORY</tt> loaders will be unable to
1195 support some file types that <tt>ALUT_LOADER_BUFFER</tt> loaders can support
1196 (although the reverse is never the case). Furthermore, it is possible that
1197 for some file types (notably audio/x-wav) the support may be only for a few
1198 sub-formats. For example, an implementation may advertise that audio/x-wav
1199 is supported when in fact it only supports uncompressed (i.e. PCM) WAV files
1200 and not any of the compressed subformats. In this event, the various ALUT
1201 loaders may return an error and set
1202 <tt>ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE</tt> rather than
1203 <tt>ALUT_ERROR_UNSUPPORTED_FILE_TYPE</tt> which would indicate that no files
1204 of this type are allowed.</p>
1206 <h4>Return Value</h4>
1208 <p>On success, <tt>alutGetMIMETypes</tt> returns a zero-terminated string
1209 which contains a comma-separated list of supported MIME types. It returns
1210 <tt>NULL</tt> on failure.</p>
1215 <dt><tt>ALUT_ERROR_INVALID_ENUM</tt></dt>
1216 <dd><tt>alutGetMIMETypes</tt> was given an invalid loader token.</dd>
1218 <dt><tt>ALUT_ERROR_INVALID_OPERATION</tt></dt>
1219 <dd>ALUT has not been initialised.</dd>
1221 <dt><tt>ALUT_ERROR_NO_CURRENT_CONTEXT</tt></dt>
1222 <dd>There is no current AL context.</dd>
1224 <dt><tt>ALUT_ERROR_AL_ERROR_ON_ENTRY</tt></dt>
1225 <dd>There was already an AL error on entry to
1226 <tt>alutGetMIMETypes</tt>.</dd>
1228 <dt><tt>ALUT_ERROR_ALC_ERROR_ON_ENTRY</tt></dt>
1229 <dd>There was already an ALC error on entry to
1230 <tt>alutGetMIMETypes</tt>.</dd>
1233 <h3><a name="DeprecatedWAVLoaders"></a>Deprecated WAV loaders</h3>
1235 <p>For backwards-compatibility with ALUT 0.x.x, ALUT still offers the three
1236 deprecated functions below. Note that on MacOS 0.x.x version, the
1237 '<tt>loop</tt>' parameter is omitted from both loader functions.</p>
1239 <pre class="programlisting">
1240 void alutLoadWAVFile (ALbyte *filename,
1247 void alutLoadWAVMemory (ALbyte *buffer,
1254 void alutUnloadWAV (ALenum format ALvoid *data, ALsizei size, ALsizei frequency);
1257 <h2><a name="VersionChecking"></a>Version Checking</h2>
1259 <p>ALUT version numbers consist of a major version number, a minor version
1260 number, and a patchlevel. The former two numbers will match the major/minor
1261 version number of the corresponding ALUT specification document and can be
1262 accessed at compile time as well as runtime. The patchlevel is not
1263 programmatically available and it is incremented only when fixing bugs
1264 without any API changes.</p>
1266 <h3 class="manpage"><a name="alutGetMajorVersion"></a>alutGetMajorVersion</h3>
1270 <p><tt>alutGetMajorVersion</tt> - return the major ALUT version number</p>
1274 <pre class="programlisting">
1275 ALint alutGetMajorVersion (void);
1278 <h4>Description</h4>
1280 <p><tt>alutGetMajorVersion</tt> returns the major version number of the ALUT
1281 in use, which will match the major version number of the corresponding ALUT
1282 specification document.</p>
1284 <h4>Return Value</h4>
1286 <p><tt>alutGetMajorVersion</tt> returns the major version number of the ALUT
1291 <p><tt>alutGetMajorVersion</tt> can be called in any ALUT state and will
1294 <h3 class="manpage"><a name="alutGetMinorVersion"></a>alutGetMinorVersion</h3>
1298 <p><tt>alutGetMinorVersion</tt> - return the minor ALUT version number</p>
1302 <pre class="programlisting">
1303 ALint alutGetMinorVersion (void);
1306 <h4>Description</h4>
1308 <p><tt>alutGetMinorVersion</tt> returns the minor version number of the ALUT
1309 in use, which will match the minor version number of the corresponding ALUT
1310 specification document.</p>
1312 <h4>Return Value</h4>
1314 <p><tt>alutGetMinorVersion</tt> returns the minor version number of the ALUT
1319 <p><tt>alutGetMinorVersion</tt> can be called in any ALUT state and will
1322 <h3><a name="VersioningMacros"></a>Compile Time Version Checking</h3>
1324 <pre class="programlisting">
1325 #define ALUT_API_MAJOR_VERSION 1
1327 #define ALUT_API_MINOR_VERSION 1
1330 <p>Version 1.0.0 introduced the above preprocessor symbols, whose values
1331 will be incremented appropriately in future revisions of ALUT. In version
1332 1.1.0, <tt>alutLoadMemoryHelloWorld</tt> and <tt>alutLoadMemoryWaveform</tt>
1333 have been added to the ALUT API.</p>
1335 <div class="example">
1336 <h4>Example: Version consistency check</h4>
1338 <p>Applications can verify at runtime that they have been compiled and
1339 linked with the matching header file and library file as follows:</p>
1341 <pre class="programlisting">
1342 #ifdef ALUT_API_MAJOR_VERSION
1343 if (alutGetMajorVersion () != ALUT_API_MAJOR_VERSION ||
1344 alutGetMinorVersion () != ALUT_API_MINOR_VERSION)
1345 /* Oh-oh! The ALUT header and the ALUT library are different revisions... */
1347 /* Oh-oh! We're linking against an ALUT 0.x.x header file... */
1352 <h2><a name="Sleeping"></a>Sleeping</h2>
1354 <p>Having a general utility function like the following in an audio-related
1355 toolkit might seem strange at first, but sleeping is a common task in a lot
1356 of audio demos and it can't be done portably without cluttering the source
1357 code with <tt>#ifdefs</tt>.</p>
1359 <h3 class="manpage"><a name="alutSleep"></a>alutSleep</h3>
1363 <p><tt>alutSleep</tt> - sleep for a given number of seconds</p>
1367 <pre class="programlisting">
1368 ALboolean alutSleep (ALfloat duration);
1371 <h4>Description</h4>
1373 <p><tt>alutSleep</tt> will delay the execution of the current thread for at
1374 least the given amount of seconds. It will only return earlier if a signal
1375 has been delivered to the thread, but this does not count as an error. Note
1376 that sleeping for zero seconds will give other runnable threads a chance to
1379 <h4>Return Value</h4>
1381 <p><tt>alutSleep</tt> returns <tt>AL_TRUE</tt> on success or
1382 <tt>AL_FALSE</tt> on failure. Note that current implementations will always
1383 succeed if the duration is non-negative, but this might change in the
1389 <dt><tt>ALUT_ERROR_INVALID_VALUE</tt></dt>
1390 <dd><tt>alutSleep</tt> was given a negative duration.</dd>
1396 ;;; Local Variables: ***