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

NAME

POE::Component::Enc::Flac - POE component to wrap FLAC encoder flac

SYNOPSIS

  use POE qw(Component::Enc::Flac);

  $encoder1 = POE::Component::Enc::Flac->new();
  $encoder1->enc(input => "/tmp/track03.wav");

  $encoder2 = POE::Component::Enc::Flac->new(
    parent      => 'mainSession',
    priority    => 10,
    compression => 'best',
    status      => 'flacStatus',
    error       => 'flacEerror',
    warning     => 'flacWarning',
    done        => 'flacDone',
    );
  $encoder2->enc(
    input       => "/tmp/track02.wav",
    output      => "/tmp/02.flac",
    tracknumber => 'Track 2',
    comment     => [
                    'title=Birdhouse in your Soul',
                    'artist=They Might be Giants',
                    'date=1990',
                    'origin=CD',
                   ]
    );

  POE::Kernel->run();

ABSTRACT

POE is a multitasking framework for Perl. FLAC stands for Free Lossless Audio Codec and 'flac' is an encoder for this standard. This module wraps 'flac' into the POE framework, simplifying its use in, for example, a CD music ripper and encoder application. It provides an object oriented interface.

To use this module, you will need the POE framework (See http://poe.perl.org/) and you will need to install the flac tool (See http://flac.sourceforge.net/).

DESCRIPTION

This POE component encodes wav audio files into FLAC format. It's merely a wrapper for the flac program.

METHODS

The module provides an object oriented interface as follows.

new

Used to create an encoder instance. The following parameters are available. All of these are optional.

priority

This is the delta priority for the encoder relative to the caller, default is 0. A positive value lowers the encoder's priority. See POE::Wheel:Run(3pm) and nice(1).

parent

Names the session to which events are posted. By default this is main.

compression

Sets the encoding compression level to the given value, between 0 (least) and 8 (most). You can also specify 'fast' and 'best' which are synonymous to 0 and 8 respectively. If unspecified, the default compression level is 5.

status
error
warning
done

These parameters specify the events that are posted to the main session. By default the events are status, error, warning and done respectively.

enc

Encodes the given file, naming the result with a .flac extension. The only mandatory parameter is the name of the file to encode.

input

The input file to be encoded. This must be a .wav file.

output

The output file to encode to. This will be a .flac file. This parameter is optional, and if unspecied the output file name will be formed by replacing the extension of the input file name with .flac.

delete

A true value for this parameter indicates that the original input file should be deleted after encoding.

comment

Use this parameter to pass Vorbis comments to the encoder.

For the comment parameter, the encoder expects tag-value pairs separated with an equals sign ('tag=value'). Multiple pairs can be specified because this parameter is a list. Note that this parameter must always be passed as a list even if it has only one element. This parameter is optional.

EVENTS

Events are passed to the session specified to the new() method to indicate progress, completion, warnings and errors. These events are described below, with their default names; alternative names may be specified when calling new().

The first argument (ARG0) passed with these events is always the instance of the encoder as returned by new(). ARG1 and ARG2 are always the input and output file names respectively.

status

Sent during encoding to indicate progress. ARG3 is the percentage of completion so far (integer number 0 to 100), and ARG4 is the current compression ratio (real number, three decimal places).

warning

Sent when the encoder emits a warning. ARG3 is the warning message.

error

Sent in the event of an error from the encoder. ARG3 is the error code from the encoder and ARG4 is the error message if provided, otherwise ''.

done

This event is sent upon completion of encoding.

SEE ALSO

Vorbis Tools oggenc(1), POE::Component::Enc::Ogg, POE::Component::Enc::Mp3, POE::Component::CD::Detect, POE::Component::CD::Rip.

http://www.ambrosia.plus.com/perl/modules/POE-Component-Enc-Flac/

AUTHOR

Steve James <steATcpanDOTorg>

DATE

$Date: 2004/04/25 22:01:19 $

VERSION

$Revision: 1.1 $

COPYRIGHT AND LICENSE

Copyright (c) 2004 Steve James

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