Skip Menu |

This queue is for tickets about the Win32-Sound CPAN distribution.

Report information
The Basics
Id: 4213
Status: resolved
Priority: 0/
Queue: Win32-Sound

People
Owner: Nobody in particular
Requestors: igor [...] plisco.ru
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: 0.51



Subject: Mistake in formula
Author address dada@divinf.it is wrong, so I copy my message here. Hi, I tried your module Win32::Sound today. Thanks. You have little mistake in your example script. In the line: Show quoted text
> $v = sin($counter/2*3.14) * 128 + 128;
you shoul have: $v = sin($counter * 2*3.14) * 128 + 128; If you like, you can use more transparent version of your example script which I made while testing. It's attached to this letter (it plays 1 kHz). Another problem was that script creates file sound.wav, but it is created with error and has size of 43 bytes. I had following error message (of course, only middle line). C:\WINDOWS\COMMAND.COM /c perl rrr.pl XS(WaveOut::Save): loaded bufferlen=0 Hit any key to close this window... Best wishes, Igor Plisco
use Win32::Sound; # Create the object $WAV = new Win32::Sound::WaveOut(44100, 8, 2); $freq = 1000; $vol = 10; $len = 0.1; # seconds $data = ""; $counter = 0; $increment = $freq/44100; # Generate 44100 samples ( = 1 second) for $i (1..44100* $len) { # Calculate the pitch # (range 0..255 for 8 bits) $v = (sin($counter*2*3.14) + 1) * $vol; # "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