| Store | Cart

Audio::WAV on win 32

From: Spencer Chase <spen...@spencerserolls.com>
Thu, 18 Apr 2013 11:16:05 -0700
I am trying to read the raw data from a WAV file that I am using for 
storing data logger information. Using a test WAV file with nothing but 
silence, I do not get the expected all 0 results. I have tried different 
unpack formats but nothing seems to work any better. My test files are 
made in "Audacity" using the "generate silence" function. I am testing 
with mono files so there should just be a series of 16 bit signed 
integers. The dumped data shows that Audio::WAV sees the file as mono 
with the correct sample rate and bit depth. All suggestions welcomed.

use strict;
use Audio::Wav;
use Cwd;
use Data::Dumper;

my $path = getcwd;
my $wav = new Audio::Wav;
my $test = 'test.wav';
my $read = $wav -> read($test);

my $details = $read -> details();
print Data::Dumper->Dump([ $details ]);

my $total = 0;
my $buffer = 2;
my $length = $read -> length();
while ( $total < $length ) {
    $total += $buffer;
    my $data = $read -> read_raw( $buffer );
    my $value = unpack('s',$data);
    my $sample = $total/2;
    print "\nsample $sample value $value ";
}

-- 
Best regards, Spencer Chase
67550-Bell Springs Rd.
Garberville, CA 95542 Postal service only.
Laytonville, CA 95454 UPS only.
Spen...@spencerserolls.com
http://www.spencerserolls.com
(707) 984-8356
(425) 791-0309

_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Recent Messages in this Thread
Spencer Chase Apr 18, 2013 06:16 pm