NAME
Audio::Audiere - use the Audiere sound library in Perl
SYNOPSIS
use Audio::Audiere qw/AUDIO_STREAM AUDIO_BUFFER/;
use strict;
use warnings;
my $audiere = Audio::Audiere->new();
if ($audiere->error() ne '')
{
die ("Cannot get audio device: ". print $audiere->error());
}
# now we have the driver, add some sound streams
# stream the sound from the disk
my $stream = $audiere->addStream( 'media/sample.ogg', AUDIO_STREAM);
# load sound into memory (if possible), this is also the default
my $sound = $audiere->addStream( 'media/effect.wav', AUDIO_BUFFER);
$stream->setVolume(0.5); # 50%
$stream->setRepeat(1); # loooop
$stream->play(); # start playing
$sound->play(); # start playing
# free sound device (not neccessary, will be done automatically)
# $driver = undef;
EXPORTS
Exports nothing on default. Can export AUDIO_BUFFER
and AUDIO_STREAM
on request.
DESCRIPTION
This package provides you with an interface to the audio library Audiere.
METHODS
- new()
-
my $audiere = Audio::Audiere->new( $device );
Creates a new object that holds the Audiere driver to the optional
$device
.There is only one of them and it will croak if you try to create a second one. When
$audiere
goes out of scope or is set to undef, the Audiere driver will be automatically released.In case you wonder how you can play multiple sounds at once: these are handled as separate streams, and once you have the Audiere driver, you can add (almost infinitely) many of them via addStream.
- getVersion
-
Returns the version of Audiere you are using as string.
- addStream
-
$stream = $audiere->addStream( $file, $stream_flag )
- dropStream
-
$audiere->dropStream($stream);
This will stop the sound playing from this stream and release it's memory. You can also do it like this or just have
$stream
go out of scope:$stream = undef;
- dupeStream
-
$second_stream = $audiere->dupeStream($stream); $second_stream = $stream->copy();
METHODS ON STREAMS
Methods on streamds must be called on stream objects that are returned by addStream.
- play
-
Start playing the stream.
- stop
-
Stop playing the stream.
- isSeekable
- getLength
- isPlaying
-
while ($stream->isPlaying()) { ... }
Returns true if the stream still plays.
- getPosition
- getFormat
- getSamples
- getVolume
-
Returns the volume of the stream as a value between 0 and 1.
- setVolume
-
Set the volume of the stream as a value between 0 and 1.
- getRepeat
-
Returns true if the stream is repeating (aka looping).
- setRepeat
-
$stream->setRepeat(1); # loop $stream->setRepeat(0); # don't loop
If true, the stream will repeat (aka loop).
- setPan
-
$stream->setPan ( -1.0 ); # -1.0 = left, 0 = center, 1.0 = right
Set the panning of the sound from -1.0 to +1.0.
- getPan
-
Returns the current panning of the sound from -1.0 to +1.0. See setPan.
- setPitch
- getPitch
- setPitchShift
- getPitchShift
Internal Methods
You should not use these methods:
- _alloc_device()
-
Increments the ref count on the driver to ensure only one is active at a time.
- _free_device()
-
Decrements the ref count on the driver to ensure only one is active at a time.
- _device_in_use()
-
Return true if the Audiere device is already in use.
AUTHORS
(c) 2004 Tels <http://bloodgate.com/>