Audio::Ao - A Perl wrapper for the Ao audio library.
use Audio::Ao qw(:all); initialize_ao; my $device = open_live(default_driver_id(), 16, $rate, $channels, is_big_endian(), {}); while (#have data) { play($device, $data_buffer, $len_of_buffer); } close_ao($device($device)); shutdown_ao;
Provides access to Libao, "a cross-platform library that allows programs to output PCM audio data to the native audio devices on a wide variety of platforms." Libao currently supports OSS, ESD, ALSA, Sun audio, and aRts.
initialize_ao ()
Initializes the underlying library. This must be called before any other Ao operations are performed.
shutdown_ao ()
Closes down the underlying libraries. Call this when you're done.
open_live ($driver_id, $bits, $rate, $channels, $byte_format, %options)
Opens a live playback audio device for output. Takes driver id number, bits per sample, sample rate, number of channels, and byte format (big or little endian). The options hash is optional, although you must pass at least and empty hash to the function. Options differ based on driver, see http://docs.meg.nu/local-docs/libao/drivers.html for more information. Returns undef on failure and a device (passed to play) on success.
undef
play
open_file ($driver_id, $filename, $overwrite, $bits, $rate, $channles, $byte_format, %options)
This function is equivalent to open_live except that it writes to a file given by $filename. Set $overwrite to true to automatically overwrite existing files.
open_live
$filename
$overwrite
play ($device, $buffer, $length)
Plays the specified number of bytes from $buffer to the device. Returns nonzero on success, 0 on failure.
$buffer
close_ao ($device)
Closes the given device. Returns 0 on failure.
driver_id ($short_name)
Returns the id number of the driver with the given $short_name. Returns -1 on failure. Non-negative numbers are driver ids.
$short_name
default_driver_id ()
Returns the id number of the default driver on this system. Returns -1 on failure.
driver_info ($driver_id)
Returns a hash containing various information about the driver with the specified id. An empty hash represents failure. See http://docs.meg.nu/local-docs/libao/ao_info.html for a list of key values (same as in the struct). Note that char **options is held as a nested array within the hash and the int option_count is ignored.
char **options
int option_count
driver_info_list ()
Returns an array containing the driver_info hashes for every driver supported by the system.
is_big_endian ()
Returns true if the system is big endian, false otherwrise.
Inline::C, libao
Dan Pemstein <dan@lcws.org>
Copyright (c) 2003, Dan Pemstein. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. A copy of this license is included with this module (LICENSE.GPL).
Inline::C. libao-perl
To install Audio::Ao, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audio::Ao
CPAN shell
perl -MCPAN -e shell install Audio::Ao
For more information on module installation, please visit the detailed CPAN module installation guide.