Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Win32 sound to file to audio CD

by rkg (Hermit)
on Oct 05, 2003 at 19:15 UTC ( #296761=perlquestion: print w/ replies, xml ) Need Help??
rkg has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I am trying to make a CD with a gentle beep every 30s . The sound is used by a live coder for timing events with pencil and paper in field research. I don't know much about Perl audio, or about CD file formats. I wrote this little beeping program:
use Win32::Sound; use Time::Hires qw(sleep); use strict; $|++; Win32::Sound::Volume('100%'); while (1) { print "."; Win32::Sound::Play("SystemQuestion"); Win32::Sound::Stop(); sleep(30); }
Is there a way I create a file that I could burn to CD with 60 minutes of this beeping that will play back on an audio CD player?

Thanks!

rkg

Comment on Win32 sound to file to audio CD
Download Code
Re: Win32 sound to file to audio CD
by benn (Priest) on Oct 05, 2003 at 19:27 UTC
    This is what audio editors (Sound Forge, Cool Edit etc) are for - cutting'n'pasting of sounds. You could do this in Windows Sound Recorder even, if you have the disk space and the patience to splice together 120 samples.

    Alternatively, you could simply press "record" in your Audio Application Of Choice (Windows Sound Recorder upwards), run your program, and leave it going for 60 minutes. Save As a .wav, burn with your CD Burner App. of choice and voila. Even without the diskspace, as all you have is a single beep, you could probably knock down the sample quality without missing too much.

    A less tedious way would be to record / construct a (say) 5 minute chunk, then burn it as 12 duplicate tracks with no inter-track gap.

    HTH, Ben.

Re: Win32 sound to file to audio CD
by PodMaster (Abbot) on Oct 06, 2003 at 05:38 UTC
    See Audio::Beep, then bust out your favorite sound recording program, grab a microphone, and record your computer as it beeps :) or checkout morsify, and generate a wav file with the tone of the desired pitch/duration (there are other examples of this type thing around here, but there is also Acme::Morse::Audible)...

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Win32 sound to file to audio CD
by rkg (Hermit) on Oct 07, 2003 at 18:21 UTC
    I thought I'd post the code I came up with in case it helps someone else down the road. This creates a .wav file; I then used audacity to rip it to a MP3 cd.
    use Win32::Sound; use strict; my $rate = 14100; my $WAV = new Win32::Sound::WaveOut($rate, 8, 2); Win32::Sound::Volume('100%'); my $data = ""; my $counter = 0; # an hour of beeping -- what fun for my $c (1 ..2*60) { print "$c beep\n"; # .25 sec tone for my $i (1 .. .25 * $rate) { my $v = 128 + 50 * sin($i); $data .= pack("cc", $v); } # 29.75 sec sec silence for my $i (1 .. 29.75 * $rate) { my $v = 0; $data .= pack("cc", $v); } } $WAV->Load($data); # get it $WAV->Save("beep.wav"); # write to disk $WAV->Unload(); # drop it

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://296761]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2014-10-20 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (77 votes), past polls