Homework 4 - radio play

Test soundfile playback

The clip being played is a humpback whale vocalization recorded Oct, 2022 with a 220a hydrophone. Chuck loads the file "whale.wav". The filename will be available to Chuck after preloading, see the JavaScript call to "serverFilesToPreload" in this file for the format. It associates the sound file at the URL "https://ccrma.stanford.edu/courses/220a/examples/webchuck/radio-play/wav/whale.wav" and makes it available to Chuck as "whale.wav".

Improvement: There are two start buttons, the regular one and a new one that starts like the regular one but with ADC input. Use the latter if browser audio input is needed in the Chuck script. (In this example, the regular one suffices since this is strictly a script generating output.)

Optional code to add to live code below:
// after mySnd is declared, perhaps add this to play it a bit louder mySnd.gain(3.0); // 3x amplitude
////////////////////////////////////////////////////
live code
fun void clip(string name) // define "clip" as a function { SndBuf2 mySnd => dac; // declare a sound file reader "mySnd" and connect to the DAC mySnd.read(name); // specify the file name mySnd.length() => dur myDur; // get the duration <<< name, "is playing at", now/second, "for", myDur/second,"seconds">>>; myDur => now; // quit this shred after sound file's duration has passed } spork ~clip("whale.wav"); // spork with the filename that's available to Chuck while (true) 1::samp => now; // chuck forever, "stop" button finishes the recording and exits