the script i sent in last message has a couple of errors that make the 
sound it produces inaudible for testing.

the corrected script follows:

use strict;
use Win32::Sound;
my $input = 1;
my $repeats;
my $data;
while ($input){
     print "\nenter number of repetitions of pulse \"enter\" to quit.\n";
     $input=<STDIN>;
     chomp $input;
     $repeats = $input;
     do_it();
}
sub do_it{
        my $WAV = new Win32::Sound::WaveOut(44100, 8, 2);
     my $data;
        my $counter;
        my $increment =  1000/44100;
     my $repeat_width = int((44100 / 1000) * (20));
     my $pulse_width = int((44100 / 1000000) * (10000/ 2));     
     my $space = $repeat_width - $pulse_width;
      print "\nrepeats $repeats width $pulse_width space $space\n";
     for ( my $i = 0 ; $i<  $repeats ; $i++ ) { # for number of repeats, make 
pulse and space
                for ( my $j = 0 ; $j<  $pulse_width ; $j++ ){ # do the pulse
                        my $v;
             $v = sin($counter/2*3.14) * 128 + 128;  # for sine wave
             #$v = 255;
                        $data .= pack("cc", $v, $v);    # "pack" it twice for 
left and right
         $counter += $increment;
     }          
     for ( my $k = 0 ; $k<  $space ; $k++ ){ # do the space between pulses
             my $v = 127;
             $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("test.wav"); # write to disk
     $WAV->Unload();          # drop it
}



-- 
Best regards, Spencer Chase
67550-Bell Springs Rd.
Garberville, CA 95542 Postal service only.
Laytonville, CA 95454 UPS only.
[email protected]
http://www.spencerserolls.com
(707) 984-8356
(425) 791-0309

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to