D
DG
Hello and thanks for the help,
I would like to play a *portion* of a wav file (say from sample 400 to
sample 9000) on a Windows machine.
Unfortunately, I'm unable to get my code to work. Below are my tests.
I tried the following code:
use Win32::Sound;
$WAV = new Win32::Sound::WaveOut("klaxton.wav"); #open "klaxton.wav"
located in the current directory
$WAV->Play(400,9000); #play from sample 400 to
sample 9000
When I run it, I get the following error messages:
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Argument "klaxton.wav" isn't numeric in entersub at
C:/Perl/site/lib/Win32/Sound.pm line 109.
So I tried the modified code below:
use Win32::Sound;
$WAV = new Win32::Sound::WaveOut(); #use defaults
$WAV->Open("klaxton.wav"); #open "klaxton.wav" located in the
current directory
$WAV->Play(400,9000); #play from sample 400 to sample 9000
When I run it, I get the following error messages:
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Use of uninitialized value at x.bat line 28.
Argument "klaxton.wav" isn't numeric in entersub at x.bat line 28.
To test the Sound package, I ran the following code (it worked fine):
use Win32::Sound;
Win32::Sound:lay("klaxton.wav");
To test the WaveOut package, I ran the example code given in the
documentation (shown below). It worked fine.
use Win32::Sound;
# Create the object
$WAV = new Win32::Sound::WaveOut(44100, 8, 2);
$data = "";
$counter = 0;
$increment = 440/44100;
# Generate 44100 samples ( = 1 second)
for $i (1..44100) {
# Calculate the pitch
# (range 0..255 for 8 bits)
$v = sin($counter/2*3.14) * 128 + 128;
# "pack" it twice for left and right
$data .= pack("cc", $v, $v);
$counter += $increment;
}
$WAV->Load($data); # get it
$WAV->Write(); # hear it
1 until $WAV->Status(); # wait for completion
$WAV->Save("sinus.wav"); # write to disk
$WAV->Unload(); # drop it
So the packages are working. The wav file is present. Yet I can't get my
original code to work. What am I doing wrong?
thanks for the help,
DG
I would like to play a *portion* of a wav file (say from sample 400 to
sample 9000) on a Windows machine.
Unfortunately, I'm unable to get my code to work. Below are my tests.
I tried the following code:
use Win32::Sound;
$WAV = new Win32::Sound::WaveOut("klaxton.wav"); #open "klaxton.wav"
located in the current directory
$WAV->Play(400,9000); #play from sample 400 to
sample 9000
When I run it, I get the following error messages:
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Argument "klaxton.wav" isn't numeric in entersub at
C:/Perl/site/lib/Win32/Sound.pm line 109.
So I tried the modified code below:
use Win32::Sound;
$WAV = new Win32::Sound::WaveOut(); #use defaults
$WAV->Open("klaxton.wav"); #open "klaxton.wav" located in the
current directory
$WAV->Play(400,9000); #play from sample 400 to sample 9000
When I run it, I get the following error messages:
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
Use of uninitialized value at x.bat line 28.
Argument "klaxton.wav" isn't numeric in entersub at x.bat line 28.
To test the Sound package, I ran the following code (it worked fine):
use Win32::Sound;
Win32::Sound:lay("klaxton.wav");
To test the WaveOut package, I ran the example code given in the
documentation (shown below). It worked fine.
use Win32::Sound;
# Create the object
$WAV = new Win32::Sound::WaveOut(44100, 8, 2);
$data = "";
$counter = 0;
$increment = 440/44100;
# Generate 44100 samples ( = 1 second)
for $i (1..44100) {
# Calculate the pitch
# (range 0..255 for 8 bits)
$v = sin($counter/2*3.14) * 128 + 128;
# "pack" it twice for left and right
$data .= pack("cc", $v, $v);
$counter += $increment;
}
$WAV->Load($data); # get it
$WAV->Write(); # hear it
1 until $WAV->Status(); # wait for completion
$WAV->Save("sinus.wav"); # write to disk
$WAV->Unload(); # drop it
So the packages are working. The wav file is present. Yet I can't get my
original code to work. What am I doing wrong?
thanks for the help,
DG