Fun with “beep”

At the end of my huge list of stuff I always install on a Debian box, I put a “beep” to let me know when it’s done, because I will no doubt be doing something else, most likely on a different screen, when it’s done.

Now, suppose you run a lot of processes you want to know when are done, it’s nice to have separate, easily distinguishable sounds for each event. Of course you could do this by playing a short mp3 or something with mpg321 or mplayer if you have a sound card set up on that particular box, but even if you do, playing short tunes on the PC speaker is so much more geeky, and thus cool, since you’ve already proven yourself to be a geek by working on the linux box in the first place.

Beep has the ability to play a sound at any frequency your PC speaker can do, and with configurable length… do I hear music?

Using the beep program, it’s easy to play simple melodies. Here are the frequencies for some basic notes:

262   C - "middle C"
277   C#
294   D
311   D#
330   E
349   F
370   F#
392   G
415   G#
440   A
466   A#
494   B

To find the frequencies of subsequent notes, simply multiply the highest note you know by 1.0595, and then round up or down as appropriate. For example, 494 * 1.0595 = 523.393, or 523 Hz, which should be the “C” note that’s one octave above middle C.

Taking it all one step further, this script would play Beethoven’s Für Elise, though with no sense of tone length.

#!/bin/bash

beep 659 120  #  Treble E
beep 0 120
beep 622 120  #  Treble D#
beep 0 120

beep 659 120  #  Treble E
beep 0 120
beep 622 120  #  Treble D#
beep 0 120
beep 659 120  #  Treble E
beep 0 120
beep 494 120  #  Treble B
beep 0 120
beep 587 120  #  Treble D
beep 0 120
beep 523 120  #  Treble C
beep 0 120

beep 440 120  #  Treble A
beep 0 140
beep 262 120  #  Middle C
beep 0 120
beep 330 120  #  Treble E
beep 0 120
beep 440 120  #  Treble A
beep 0 120

beep 494 120  #  Treble B
beep 0 140
beep 330 120  #  Treble E
beep 0 120
beep 415 120  #  Treble G#
beep 0 120
beep 494 120  #  Treble B
beep 0 120

beep 523 120  #  Treble C
beep 0 140
beep 330 120  #  Treble E
beep 0 120
beep 659 120  #  Treble E
beep 0 120
beep 622 120  #  Treble D#
beep 0 120

beep 659 120  #  Treble E
beep 0 120
beep 622 120  #  Treble D#
beep 0 120
beep 659 120  #  Treble E
beep 0 120
beep 494 120  #  Treble B
beep 0 120
beep 587 120  #  Treble D
beep 0 120
beep 523 120  #  Treble C
beep 0 120

beep 440 120  #  Treble A
beep 0 140
beep 262 120  #  Middle C
beep 0 120
beep 330 120  #  Treble E
beep 0 120
beep 440 120  #  Treble A
beep 0 120

beep 494 120  #  Treble B
beep 0 140
beep 330 120  #  Treble E
beep 0 120
beep 523 120  #  Treble C
beep 0 120
beep 494 120  #  Treble B
beep 0 140
beep 440 120  #  Treble A

This script is also horribly inefficient, calling beep upwards of a hundred times. Taking it another step, we can use the “-n” switch for each new note and queue them all up to play Axel Foley’s theme:

beep -f 659 -l 460 -n -f 784 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 880 -l 230 -n -f 659 -l 230 -n -f 587 -l 230 -n -f 659 -l 460 -n -f 988 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 1047-l 230 -n -f 988 -l 230 -n -f 784 -l 230 -n -f 659 -l 230 -n -f 988 -l 230 -n -f 1318 -l 230 -n -f 659 -l 110 -n -f 587 -l 230 -n -f 587 -l 110 -n -f 494 -l 230 -n -f 740 -l 230 -n -f 659 -l 460

Cool!

12 Comments

  • AkO says:

    Hi!
    I was wondering if you could do something similiar with windows or perhaps in java? The PC-speaker provides such awsome nostalgia. ^^

  • cfchris6 says:

    For this to work, CONFIG_INPUT_PCSPKR has to be set in the kernel config:
    -> Device Drivers
    -> Input device support
    -> Generic input layer (needed for keyboard, mouse, …)
    -> [*]Miscellaneous devices
    -> PC Speaker support

  • I’m getting to the same conclusion: I have multiple computers and I need to know when something goes wrong. I love to get them making a beep when they have completed the boot process, and now I’m adding a beep to know they have acknowledge when I manually push the power down button. But I wanted to do it with style, so I’m searching for nice beep tunes. Yours is splendid!!! I’m going to search in your blog if you have posted more tunes. Now, I’m trying to find short tunes, like the power rangers clock, or the star trek communicator. If I make my list, I’ll let you know!

  • tetrix says:

    Here a tetris music

    beep -f 330 -l 150 -n -f 1 -l 40 -n -f 494 -l 159 -n -f 1 -l 40 -n -f 660 -l 150 -n -f 1 -l 40 -n -f 590 -l 150 -n -f 660 -l 150 -n -f 494 -l 100 -n -f 494 -l 100 -n -f 523 -l 150 -n -f 1 -l 40 -n -f 440 -l 150 -n -f 1 -l 40 -n -f 494 -l 150 -n -f 1 -l 40 -n -f 392 -l 100 -n -f 392 -l 100 -n -f 440 -l 150 -n -f 370 -l 150 -n -f 1 -l 40 -n -f 392 -l 150 -n -f 1 -l 40 -n -f 330 -l 100 -n -f 330 -l 100 -n -f 370 -l 150 -n -f 1 -l 40 -n -f 294 -l 150 -n -f 1 -l 40 -n -f 330 -l 150 -n -f 247 -l 100 -n -f 247 -l 100 -n -f 261 -l 150 -n -f 1 -l 40 -n -f 311 -l 150 -n -f 1 -l 40 -n -f 330 -l 150 -n -f 1 -l 40 -n -f 247 -l 100 -n -f 247 -l 100 -n -f 262 -l 150 -n -f 1 -l 40 -n -f 370 -l 150 -n -f 1 -l 40 -n -f 330 -l 150 -n -f 1 -l 40 -n -f 494 -l 159 -n -f 1 -l 40 -n -f 660 -l 150 -n -f 1 -l 40 -n -f 590 -l 150 -n -f 660 -l 150 -n -f 494 -l 100 -n -f 494 -l 100 -n -f 523 -l 150 -n -f 1 -l 40 -n -f 440 -l 150 -n -f 1 -l 40 -n -f 494 -l 150 -n -f 1 -l 40 -n -f 392 -l 100 -n -f 392 -l 100 -n -f 440 -l 150 -n -f 370 -l 150 -n -f 1 -l 40 -n -f 392 -l 150 -n -f 1 -l 40 -n -f 330 -l 100 -n -f 330 -l 100 -n -f 370 -l 150 -n -f 1 -l 40 -n -f 294 -l 150 -n -f 1 -l 40 -n -f 330 -l 150 -n -f 247 -l 100 -n -f 247 -l 100 -n -f 261 -l 150 -n -f 1 -l 40 -n -f 311 -l 150 -n -f 1 -l 40 -n -f 330 -l 150 -n -f 1 -l 40 -n -f 247 -l 100 -n -f 247 -l 100 -n -f 262 -l 150 -n -f 1 -l 40 -n -f 370 -l 150 -n -f 1 -l 40 -n -f 330 -l 150 -n -f 1 -l 40

  • PlasticHat says:

    Final Fantasy victory theme ^_^

    beep -f987 -l53 -D53 -n -f987 -l53 -D53 -n -f987 -l53 -D53 -n -f987 -l428 -n -f784 -l428 -n -f880 -l428 -n -f987 -l107 -D214 -n -f880 -l107 -n -f987 -l857 -n -f740 -l428 -n -f659 -l428 -n -f740 -l428 -n -f659 -l107 -D107 -n -f880 -l428 -n -f880 -l107 -D107 -n -f830 -l428 -n -f880 -l107 -D107 -n -f830 -l428 -n -f830 -l107 -D107 -n -f740 -l428 -n -f659 -l428 -n -f622 -l428 -n -f659 -l107 -D107 -n -f554 -l1714 -n -f740 -l428 -n -f659 -l428 -n -f740 -l428 -n -f659 -l107 -D107 -n -f880 -l428 -n -f880 -l107 -D107 -n -f830 -l428 -n -f880 -l107 -D107 -n -f830 -l428 -n -f830 -l107 -D107 -n -f740 -l428 -n -f659 -l428 -n -f740 -l428 -n -f880 -l107 -D107 -n -f987 -l1714

  • Qua says:

    merry christmas =)
    beep -f 200 -l 444
    beep -f 265 -l 444
    beep -f 265 -l 222
    beep -f 295 -l 222
    beep -f 265 -l 222
    beep -f 245 -l 222
    beep -f 220 -l 444
    beep -f 220 -l 444
    beep -f 220 -l 444
    beep -f 295 -l 444
    beep -f 295 -l 222
    beep -f 330 -l 222
    beep -f 295 -l 222
    beep -f 265 -l 222
    beep -f 245 -l 444
    beep -f 200 -l 444
    beep -f 200 -l 444
    beep -f 330 -l 444
    beep -f 330 -l 222
    beep -f 345 -l 222
    beep -f 330 -l 222
    beep -f 300 -l 222
    beep -f 265 -l 444
    beep -f 220 -l 444
    beep -f 200 -l 444
    beep -f 220 -l 444
    beep -f 300 -l 444
    beep -f 245 -l 444
    beep -f 265 -l 888

  • sysadmin says:

    Awsome! QA team was very surprised while listening to some music from their usually very silent server :))

  • Adam Taylor says:

    Great article! I made the Mario victory theme:

    beep -f 130 -l 100 -n -f 262 -l 100 -n -f 330 -l 100 -n -f 392 -l 100 -n -f 523 -l 100 -n -f 660 -l 100 -n -f 784 -l 300 -n -f 660 -l 300 -n -f 146 -l 100 -n -f 262 -l 100 -n -f 311 -l 100 -n -f 415 -l 100 -n -f 523 -l 100 -n -f 622 -l 100 -n -f 831 -l 300 -n -f 622 -l 300 -n -f 155 -l 100 -n -f 294 -l 100 -n -f 349 -l 100 -n -f 466 -l 100 -n -f 588 -l 100 -n -f 699 -l 100 -n -f 933 -l 300 -n -f 933 -l 100 -n -f 933 -l 100 -n -f 933 -l 100 -n -f 1047 -l 400

  • Bob Dole says:

    I have found a github repository with some beep songs in shell script format

    https://github.com/adamrees89/beep-songs

Leave a Reply

Your email address will not be published. Required fields are marked *