Audio::Wav - Modules for reading & writing Microsoft WAV files.
use Audio::Wav; my $wav = new Audio::Wav; my $read = $wav -> read( 'input.wav' ); my $write = $wav -> write( 'output.wav', $read -> details() ); print "input is ", $read -> length_seconds(), " seconds long\n"; $write -> set_info( 'software' => 'Audio::Wav' ); my $data; while ( defined( $data = $read -> read_raw( $buffer ) ) ) { $write -> write_raw( $data ); } my $length = $read -> length_samples(); my( $third, $half, $twothirds ) = map int( $length / $_ ), ( 3, 2, 1.5 ); my %samp_loop = ( 'start' => $third, 'end' => $twothirds, ); $write -> add_sampler_loop( %samp_loop ); $write -> add_cue( $half, "cue label 1", "cue note 1" ); $write -> finish();
All sample positions are now in sample offsets (unless option '.01compatible' is true).
These modules provide a method of reading & writing uncompressed Microsoft WAV files.
L<Audio::Wav::Read> L<Audio::Wav::Write>
Returns a blessed Audio::Wav object. All the parameters are optional and default to 0
my %options = ( '.01compatible' => 0, 'oldcooledithack' => 0, 'debug' => 0, ); my $wav = Audio::Wav -> new( %options );
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.
Returns a blessed Audio::Wav::Read object.
my $read = $wav -> read( 'testout.wav' );
See Audio::Wav::Read for methods.
Specifies a subroutine for catching errors. The subroutine should take a hash as input. The keys in the hash are 'filename', 'message' (error message), and 'warning'. If no error handler is set, die and warn will be used.
sub myErrorHandler { my( %parameters ) = @_; if ( $parameters{'warning'} ) { # This is a non-critical warning warn "Warning: $parameters{'filename'}: $parameters{'message'}\n"; } else { # Critical error! die "ERROR: $parameters{'filename'}: $parameters{'message'}\n"; } } $wav -> set_error_handler( \&myErrorHandler );
Nick Peskett <cpan@peskett.com>. Kurt George Gjerde <kurt.gjerde@media.uib.no>. (0.02)
To install Audio::Wav, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audio::Wav
CPAN shell
perl -MCPAN -e shell install Audio::Wav
For more information on module installation, please visit the detailed CPAN module installation guide.