#!/usr/bin/perl -w

# $Id: decode,v 1.1.1.1 2004/06/30 21:49:37 daniel Exp $

use strict;
use lib qw(blib/lib blib/arch);
use Audio::Wav;
use Audio::FLAC::Decoder;

my $details = {
	'bits_sample'       => 16,
	'sample_rate'       => 44100,
	'channels'          => 2,
};

sub main {

	my $wav = Audio::Wav->new();
	my $write = $wav->write('out.wav', $details);

	my $decoder = Audio::FLAC::Decoder->open('test.flac');

	my $buffer;
	while (my $len = $decoder->sysread($buffer)) {

		last if $len <= 0;

        	$write->write_raw($buffer);
	}

	$write->finish();
}

main();
