The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Audio::Wav - Modules for reading & writing Microsoft Wav files.

SYNOPSIS

        use Audio;

        my $buffer = 512;

        my $wav = new Audio::Wav;

        my $read = $wav -> read( 'testout.wav' );

        my $write = $wav -> write( 'testcopy.wav', $read -> details() );

        my $total = 0;

        my $length = $read -> length();
        while ( $total < $length ) {
                my $left = $length - $total;
                $buffer = $left unless $left > $buffer;
                my $data = $read -> read_raw( $buffer );
                last unless defined( $data );
                $write -> write_raw( $data, $buffer );
                $total += $buffer;
        }

        $write -> finish();

NOTES

All sample positions used are in byte offsets (Audio::Tools::Time for conversion utilities)

DESCRIPTION

These modules provide a method of reading & writing uncompressed Microsoft Wav files. It was developed on mswin32 so I'm not sure if this version has the correct byte order for big endian machines.

AUTHOR

Nick Peskett - nick@soup.demon.co.uk

SEE ALSO

        L<Audio::Tools>

        L<Audio::Wav::Read>

        L<Audio::Wav::Write>

METHODS

new

Returns a blessed Audio::Wav object.

        my $wav = new Audio::Wav;

write

Returns a blessed Audio::Wav::Write object.

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

        my $write = $wav -> write( 'testout.wav', $details );

See Audio::Wav::Write for methods.

read

Returns a blessed Audio::Wav::Read object.

        my $read = $wav -> read( 'testout.wav' );

See Audio::Wav::Read for methods.