Create an audio test CD of sine waves from 1 to 99 Hz

(echo CD_DA; for f in {01..99}; do echo "$f Hz">&2; sox -nt cdda -r44100 -c2 $f.cdda synth 30 sine $f; echo TRACK AUDIO; echo FILE \"$f.cdda\" 0; done) > cdrdao.toc && cdrdao write cdrdao.toc && rm ??.cdda cdrdao.toc
This command creates and burns a gapless audio CD with 99 tracks. Each track is a 30 second sine wave, the first is 1 Hz, the second 2 Hz, and so on, up to 99 Hz. This is useful for testing audio systems (how low can your bass go?) and for creating the constant vibrations needed to make non-Newtonian fluids (like cornstarch and water) crawl around. Note, this temporarily creates 500MB of .cdda files in the current directory. If you don't use the "rm" at the end of the command, you can burn more disks using cdrdao write cdrdao.toc Prerequisites: a blank CD-R in /dev/cdrw, sox (http://sox.sourceforge.net/), and cdrdao (http://cdrdao.sourceforge.net/). I'm also assuming a recent version of bash for the brace expansion (which just looks nicer than using seq(1), but isn't necessary).
Sample Output
01 Hz
02 Hz
03 Hz
...
Cdrdao version 1.2.2 - (C) Andreas Mueller <andreas@daneb.de>
Starting write at speed 48...
Pausing 10 seconds - hit CTRL-C to abort.
Executing power calibration...
Writing lead-in and gap...
Writing track 01 (mode AUDIO/AUDIO )...
Writing track 02 (mode AUDIO/AUDIO )...
Writing track 03 (mode AUDIO/AUDIO )...

What Others Think

Very nice. Just a small note: You don't have to have bash. The very same command line works fine with zsh (even quite old versions), too, including the brace expansion.
inof · 460 weeks and 5 days ago
dose not seem to work i get this error sox soxio: Failed reading `-n': unknown file type `null' (one for each htz) then ERROR: Cannot open audio file "1.cdda": No such file or directory ERROR: cdrdao.toc:3: Cannot determine length of track data specification. help?
sasnfbi1234 · 460 weeks and 4 days ago
Hi, Sasnfbi1234! Thanks for trying my script. I asked Google and it (he? she?) said that you don't have the proper sox libraries installed. Here's the link http://blog.px.ns1.net/2008/06/27/sox-soxio-failed-reading-unknown-file-type/ If you're using Debian (or a Debian derived distribution like Ubuntu) you can fix it like so: apt-get install libsox-fmt-all
hackerb9 · 460 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: