POE::Component::Enc::Flac - POE component to wrap FLAC encoder flac
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();
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.
This POE component encodes wav audio files into FLAC format. It's merely a wrapper for the flac program.
The module provides an object oriented interface as follows.
Used to create an encoder instance. The following parameters are available. All of these are optional.
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).
Names the session to which events are posted. By default this is
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
These parameters specify the events that are posted to the main session. By default the events are
Encodes the given file, naming the result with a
.flac extension. The only mandatory parameter is the name of the file to encode.
The input file to be encoded. This must be a .wav file.
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.
A true value for this parameter indicates that the original input file should be deleted after encoding.
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 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
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.
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).
Sent when the encoder emits a warning. ARG3 is the warning message.
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 ''.
This event is sent upon completion of encoding.
Steve James <steATcpanDOTorg>
$Date: 2004/04/25 22:01:19 $
$Revision: 1.1 $
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.