NAME

Peta::Synth::Output::FLAC - a FLAC encoder in Perl

VERSION

version 0.2610180

SYNOPSIS

my $out = Peta::Synth::Output::FLAC->new('song.flac', rate => 48000, bits => 24);
$out->write(\@left, \@right);       # floats in -1 .. 1, as often as needed
$out->close;

DESCRIPTION

Writes FLAC files with no program or library outside Perl: blocks of 4096 samples, the better of fixed predictors (orders 0 to 4) and linear predictors (up to order 12), the best of four stereo codings, partitioned Rice coding, and the MD5 of the samples in STREAMINFO. Usually opened through Peta::Synth::Output.

METHODS

new

new($file, rate => ..., bits => 16 or 24, quality => 5). quality is the compression level, 0 to 8, as flac's: 0-2 fixed predictors only, 3-5 also a linear predictor through one window, 6-7 through three, 8 through six, with the stereo coding chosen by coding all four channels (as flac -8; about four and a half times the time of 5, files 1-3% smaller). Level 5 makes files as large as flac -5, level 8 within half a per cent of flac -8.

write

write(\@left, \@right): takes samples (-1 .. 1) of both channels; writes each block of 4096 as it is complete.

close

Writes the last, shorter block and the final STREAMINFO (its sizes, samples and MD5); returns the file name.

FUNCTIONS

crc8, crc16

The checksums of FLAC frame headers and frames.

AUTHOR

PetaMem s.r.o. <info@petamem.com>

COPYRIGHT

Copyright (c) 2026 PetaMem s.r.o.

LICENSE

This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.