Audio Codec Loader

al_load_sample

ALLEGRO_SAMPLE *al_load_sample(const char *filename)

Loads a few different audio file formats based on their extension. Some formats require external libraries to be installed prior to compiling the library.

Note that this stores the entire file in memory at once, which may be time consuming. To read the file as it is needed, use al_stream_from_file.

File types supported:

  • wav
  • ogg (requires libvorbis)
  • flac (requires flac or libsndfile)
  • aiff (requires libsndfile)

al_stream_from_file

ALLEGRO_STREAM *al_stream_from_file(size_t buffer_count, unsigned long samples,
                                    const char *filename)

Loads an audio file from disk as it is needed. Supports the same file types as al_load_sample.

Unlike regular streams, the one returned by this function need not be fed by the user; the library will automatically read more of the file as it is needed. The stream will contain buffer_count buffers with samples samples.

FLAC streaming is currently unimplemented.

A stream must be attached to a voice to be used. See ALLEGRO_STREAM for more details.

al_save_sample

bool al_save_sample(ALLEGRO_SAMPLE *spl, const char *filename)

Writes a sample into a file. Currently, wav is the only supported format, and the extension must be 'wav'.

Returns true on success, false on error.

Last updated: 2009-07-05 05:34:12 UTC