UNH1995 has asked for the wisdom of the Perl Monks concerning the following question:

I have been given a problem (extra credit for class) to generate an escalating tone which starts low, gets loud and then goes back down. I was told that PERL would be a good language for this (there are no constraints of which language to use). I have never done audio programs with PERL (only text processing) and I really don't know where to start. Can anybody give me something to start with?

Replies are listed 'Best First'.
Re: Generating a wave file
by HyperZonk (Friar) on Oct 06, 2003 at 21:06 UTC
    UNH1995:

    Audio::Data on CPAN is probably a good place to start.


    -HZ
Re: Generating a wave file
by graff (Chancellor) on Oct 07, 2003 at 02:40 UTC
    To supplement HyperZonk's suggestion: in case you need to write some particular audio file format other than ".au" (which is what Audio::Data handles), you'll also want to look at Audio::Wav, Audio::SoundFile, maybe some others (just enter "audio" for the cpan module search).

    But don't feel bad if these things aren't exactly what you need. There are also some nice tools written in C... (sox has probably been around the longest and can do the most, and the portions of its code that I've seen are reasonably well documented, so you can work out what's going on).

    Frankly, I tend to prefer C for audio-related stuff: declare a buffer for short ints, fill it using a loop that implements some function, or by reading from a A/D converter, and write it to a disk file -- no muss, no fuss, and nothing very obscure. (Though I did recently use perl to validate/repair some mangled ms-wav file headers -- I'm getting better with the "pack" and "unpack" functions, and I was able to code it quicker than I could have in C; it's just that you need "pack" and "unpack" to do audio properly in Perl, and these calls tend to be hard to grok -- their descriptions in perlfunc are not an easy read.)

Re: Generating a wave file
by PodMaster (Abbot) on Oct 07, 2003 at 08:12 UTC
    What class? Check out my answer to Re: Win32 sound to file to audio CD and try out morsify ;)

    BTW it's Perl , not PERL (not many people program in PERL).

    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.