in reply to Re: win32 sound problem
in thread win32 sound problem
use strict; #use warnings; use Win32::Sound; my $input = 1; while ($input){ print "\nenter number of repetitions of pulse \"enter\" to quit.\ +n"; $input=<STDIN>; chomp $input; make_wav($input); } sub make_wav{ my $repeats = shift; my $data = ""; my $counter = 0; my $increment = 440/44100; 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^3: win32 sound problem
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 | |
by spencoid (Acolyte) on Feb 28, 2011 at 03:00 UTC | |
by roboticus (Chancellor) on Feb 28, 2011 at 03:07 UTC | |
by toolic (Bishop) on Feb 28, 2011 at 13:49 UTC |