Re: Newbie: Win32:Sound:WaveOut problem

From: DG (invalid_at_invalid.invalid)
Date: 09/02/04


Date: Wed, 01 Sep 2004 23:24:40 GMT

I found a solution to this problem at:
http://aspn.activestate.com/ASPN/Mail/Message/activeperl/1520559

It seems that the Win32::Sound:WaveOut module has a bug. It won't open
files. The above link tells how to fix this module.

Also, I discovered that the documentation for "Play([FROM, TO])" is also
incorrect. It should be "Play([FROM, LENGTH])". For example: if you want
to play starting from sample #1200 to sample #1800 (LENGTH = 1800 - 1200 =
600), the documentation leads you to believe that you should use
"$WAV->Play(1200,1800)". My tests show that statement to be incorrect. The
correct statement should be "$WAV->Play(1200,600)". In other words
"$WAV->Play([FROM, LENGTH])".

I hope this info helps someone else.
DG

"DG" <invalid@invalid.invalid> wrote in message
news:z1iZc.96511$Fg5.43900@attbi_s53...
> 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::Play("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
>
>



Relevant Pages

  • Visual Studio Common IDE Package error
    ... so of these error messages ... Package Load Failure ... Package 'Visual Studio Common IDE Package' has failed to load properly ( ... like to disable loading this ...
    (microsoft.public.vsnet.ide)
  • Re: Error messages after reinstall following AOL induced crash
    ... I'm not sure what you mean by 'package' but have you tried ... uninstalling and reinstalling Office? ... > instructions to the letter - and no error messages ... > you want to reinstall' appears. ...
    (microsoft.public.word.application.errors)
  • Re: firefox .9 rpms
    ... it doesnt runs (no error messages are shown). ... > Someone has a recommendation for solving this problem or knows another ... Please also clearly indicate what version/release of the package you have ...
    (Fedora)
  • Re: XML - one more try...
    ... unless we have some idea as to what error messages you are getting. ... I've definitely used the ExPat package successfully. ... I need to find a simple way of loading xml documents into a VS2005 mfc app. ... Any of the files I've downloaded won;t compile. ...
    (microsoft.public.vc.mfc)
  • Re: Dissatisfaction with VS2005
    ... I have uninstalled using that uninstall tool and reinstalled the VS2005. ... No change in the error messages. ... Package Load Failure ...
    (borland.public.delphi.non-technical)