spencoid has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Win32::Sound; my $data = ""; my $counter = 0; my $increment = 440/44100; my $repeats; my $input = 1; while ($input){ print "\nenter number of reps \"enter\" to quit.\n"; $input=<STDIN>; chomp $input; $repeats = $input; make_wav(); } sub make_wav{ my $WAV = new Win32::Sound::WaveOut(44100, 8, 2); $data = ""; $counter = 0; for ( my $i = 1 ; $i < $repeats + 1 ; $i++ ) { print "\ndoing repeat number $i"; for my $j (1..4410) { my $v = sin($counter/2*3.14) * 128 + 128; $data .= pack("cc", $v, $v); $counter += $increment; } for my $k (1..440) { #silence between pulses my $v = 128; $data .= pack("cc", $v, $v); } } $WAV->Unload(); # drop it $WAV->Load($data); # get it $WAV->Write(); # hear it 1 until $WAV->Status(); # wait for completion $WAV->Save("temp.wav",$data); # write to disk $WAV->Close(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: win32 sound problem
by toolic (Bishop) on Feb 27, 2011 at 19:43 UTC | |
by spencoid (Acolyte) on Feb 27, 2011 at 20:20 UTC | |
by toolic (Bishop) on Feb 27, 2011 at 21:44 UTC | |
by spencoid (Acolyte) on Feb 27, 2011 at 22:53 UTC | |
by roboticus (Chancellor) on Feb 28, 2011 at 01:01 UTC | |
| |
|
Re: win32 sound problem
by kejohm (Hermit) on Feb 28, 2011 at 06:10 UTC |