I once was sniffing through this man page:

http://www.themanualpage.org/man/man4/console_codes.4.php

and noted that on the Linux console you could control the pitch and duration of the console bell by echoing escape codes:

ESC [ 10 ; n ] Set bell frequency in Hz. ESC [ 11 ; n ] Set bell duration in msec.

...you can test this with:

FREQ=440 DUR=500 echo -e "\e[10;$FREQ]\e[11;$DUR]" >/dev/console echo -e "\a" >/dev/console</p>

I then found pages like these:

which gave the frequencies of the different notes (because I don't know much technical stuff about music) and figured out that I could play music on the console...

I got the sheet music for our national anthem, and wrote a C program which would set the frequency and the duration, send a ^G and then usleep for the appropriate number of microseconds before playing the next note. (if you don't sleep you just get a mess of quick beeps because it sends the next one immediately - it doesn't wait for the playing beep to finish)

(I did need to get a musically aware friend to tell me which notes I should play sharp or flat - as some needed tweaking for it to be right)

I found this was a lot more attention getting and pleasant to listen to than using a normal beep as a signal when something was happening on my box (don't forget to reset it back to the normal pitch and duration after playing the tune though, otherwise your adjusted beeps could annoy you when you're using the console beep as a normal console beep!)

For a while I even left my old laptop running 24x7 in my bedroom and had a cron job to launch the binary at /dev/console (so it played through the PC speaker) in the morning as my alarm clock! - it worked nicely until the clock on the ancient laptop started to go silly ;o)


In reply to Re^2: Does Perl ring a bell? (shame) by serf
in thread Does Perl ring a bell? by kwaping

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.