The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Audio::aKodePlayer - A simple Perl interface to the aKode audio library.

VERSION

Version 0.01

DESCRIPTION

This module provides a simple interface to the aKode::Player class from the C++ aKode library. aKode is a simple audio-decoding frame-work that provides a uniform interface to decode the most common audio-formats such as WAV, MP3, Ogg/Vorbis, Ogg/FLAC, etc. It also has a direct playback option for a number of audio-outputs, such as OSS, Alsa, SunOS/Solaris audio, Jack, and Polyp (recommended for network transparent audio).

SYNOPSIS

  use Audio::aKodePlayer;

  my $player = Audio::aKodePlayer->new();
  $player->open('auto'); # automatically selected output sink
  $player->load( 'my_audio.ogg' ); # any format supported by aKode
  $player->play();
  $player->seek(10*1000) if $player->seekable; # seek 10 seconds from the beginning
  while (!$player->eof) {
    print "Playback position: ".($player->position()/1000)." seconds of ".($player->length()/1000)."\n";
    sleep 1;
  }
    ...
  $player->pause();
  $player->resume();
  $player->setVolume(0.75);
  print "Current volume is at ".($player->volume()*100)."%\n";
    ...
  $player->wait;   # idle until the playback stops
  $player->stop;   # stop playback
  $player->unload; # release resources related to the media
  $player->close;  # release resources related to the the output sink

EXPORT

None.

FUNCTIONS

new()

Create a new Audio::aKodePlayer object.

open(sinkname)

Opens a player that outputs to the sink sinkname (the sink 'auto' is recommended, other options are 'alsa', 'jack', 'oss', 'polyp', 'sun', and maybe other, depending on the aKode installation).

Returns false if the device cannot be opened.

close()

Closes the player and releases the output sink.

load(filename)

Loads the file from a given filename and prepares it for playing. Returns false if the file cannot be loaded or decoded.

setDecoderPlugin(plugin_name)

Sets the decoder plugin to use. Default is auto-detect.

setResamplerPlugin(plugin_name)

Sets the resampler plugin to use. Default is "fast".

Audio::aKodePlayer::listPlugins()

Returns the names of available plugins (as an array).

Audio::aKodePlayer::listSinks()

Returns the names of available sinks (as an array).

Audio::aKodePlayer::listDecoders()

Returns the names of available decoders (as an array).

unload()

Unload the file and release any resources allocated while loaded.

play()

Start playing.

stop()

Stop playing and release any resources allocated while playing.

wait()

Waits for the file to finish playing (eof or error) and calls stop. This blocks the calling thread.

detach()

Detach the player from the current thread (once detached, you won't be able to apply any methods on the player object).

pause()

Pause the player.

resume()

Resume the player from paused.

setVolume(volume)

Set the software-volume. Use a number between 0.0 and 1.0.

volume()

Returns the current value of the software-volume.

state ()

Returns the current state of the Player, as a number. The constants Audio::aKodePlayer::CLOSED, Audio::aKodePlayer::OPEN, Audio::aKodePlayer::LOADED, Audio::aKodePlayer::PLAYING, and Audio::aKodePlayer::PAUSED can be used, but it is recommended to use directly the methods isClosed, isOpen, isLoaded, isPlaying, and isPaused instead.

seek(milliseconds)

Attempts a seek to pos milliseconds into the file/stream. Returns true if succesfull.

length()

Returns the length of the file/stream in milliseconds. Returns -1 if the length is unknown.

WARNING: current version of aKode (2.0.1) returns lenghts in seconds for WAV files.

position()

Returns the current position in file/stream in milliseconds. Returns -1 if the position is unknown.

WARNING: current version of aKode (2.0.1) returns position in seconds for WAV files.

seekable()

Returns true if the decoder is seekable.

eof()

Returns true if the decoder has reached the end-of-file/stream.

decoderError()

Returns true if the decoder has encountered a non-recoverable error.

setSampleRate(rate)

Sets the output sample-rate on the resampler to a given value. (May not work with all sinks.)

setSpeed(value)

Sets the resample speed to a given value. (May not work with all sinks.)

isClosed ()

Return true if the player is in the closed state.

isOpen ()

Return true if the player is in the open state.

isLoaded ()

Return true if the player is in the Loaded state.

isPlaying ()

Return true if the player is in the playing state.

isPaused ()

Return true if the player is in the paused state.

CAVEATS

The C++ class provides a method aKode::Player::open(FILE), where FILE is an overloaded class derived from the aKode::File interface. This allows for streaming. The current bindings do not have interface for this feature. Feel free to submit a patch.

KNOWN BUGS

Current version of aKode (2.0.1) probably contains a bug, so position() and length() are reported in seconds rather than in milliseconds for WAV files.

AUTHOR

Petr Pajas, <pajas at matfyz.cz>

BUGS

Please report any bugs or feature requests to bug-audio-akodeplayer at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Audio-aKodePlayer. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Audio::aKodePlayer

You can also look for information at:

ACKNOWLEDGEMENTS

aKode library was written Allan Sandfeld.

The Perl bindings were written by Petr Pajas http://pajas.matfyz.cz and their development was supported by the grant no. 1ET101120503 of the Grant Agency of Academy of Sciences of the Czech Republic.

COPYRIGHT & LICENSE

Copyright 2007 Petr Pajas, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.