(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

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

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 )...

These Might Interest You

  • This shell function takes a single argument, which is used as the base name of the .wav, .timing and .session files created. To create a screencast: screencast test type and talk ... then type 'exit' or to exit the screencast. test.wav will contain the audio from your screencast. test.session will contain text and control characters needed to paint the screen test.timing will contain timing information needed to synch individual keystrokes in test.session with the audio. to play back: aplay test.wav & scriptreplay test.{timing,session} NOTE: because the shell function uses the variable "$!", and bash likes to expand '!' during history expansion, you will need to turn off bash's history before you enter the shell function. This can be achieved using the command set +H

    screencast() { arecord -R 1000 -f cd -t wav $1.wav & RECPID=$!; echo "Starting screencast in new shell. Exit subshell to quit."; script -t 2> $1.timing -a $1.session; kill $RECPID; }
    bartonski · 2011-01-20 14:35:47 0
  • Sometimes audio and video are not sync'ed. The factor 1.0884 is the quotient 48000/44100. One mplayer plays the audio file in the background, the other the video in the foreground. You can dump the audio file before with another commandlinefu Show Sample Output

    mplayer test.mp3 < /dev/null & mplayer test.avi -nosound -speed 1.0884
    fxj · 2009-10-31 09:33:33 0
  • fade [type] fade-in-length [stop-time [fade-out-length]] Apply a fade effect to the beginning, end, or both of the audio. An optional type can be specified to select the shape of the fade curve: q for quarter of a sine wave, h for half a sine wave, t for linear (`triangular') slope, l for logarithmic, and p for inverted parabola. The default is logarithmic. A fade-in starts from the first sample and ramps the signal level from 0 to full volume over fade-in-length sec? onds. Specify 0 seconds if no fade-in is wanted. For fade-outs, the audio will be truncated at stop-time and the signal level will be ramped from full volume down to 0 starting at fade-out-length seconds before the stop-time. If fade-out-length is not specified, it defaults to the same value as fade-in-length. No fade-out is performed if stop-time is not specified. If the file length can be determined from the input file header and length-changing effects are not in effect, then 0 may be specified for stop-time to indicate the usual case of a fade-out that ends at the end of the input audio stream. All times can be specified in either periods of time or sample counts. To specify time periods use the format hh:mm:ss.frac format. To specify using sample counts, specify the number of samples and append the letter `s' to the sample count (for example `8000s').

    sox input.mp3 output.mp3 fade h 5 00:02:58 5
    kev · 2011-09-03 13:59:03 0
  • This will cause their computer to make a beeping sound after a random amount of time until it is killed.

    while true; do sleep $(($RANDOM%50)); timeout 1 speaker-test -f 20000 -t sine 2>/dev/null; done&
    noah018 · 2013-02-14 21:47:40 0
  • sudo apt-get install wv tetex-extra ghostscript

    wvPDF test.doc test.pdf
    anhpht · 2011-10-07 08:04:48 0

  • 5
    dd bs=1 seek=2TB if=/dev/null of=ext3.test
    Superhuman · 2009-09-03 08:35:20 0

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 · 444 weeks and 1 day 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 · 444 weeks 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 · 444 weeks 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: