howto do a robust simple cross platform beep

Hans Mulder hansmu at xs4all.nl
Sun Jul 15 02:39:45 CEST 2012


On 14/07/12 20:49:11, Chris Angelico wrote:
> On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer <dieter at handshake.de> wrote:
>> I, too, would find it useful -- for me (although I do not hate myself).
>>
>> Surely, you know an alarm clock. Usually, it gives an audible signal
>> when it is time to do something. A computer can in principle be used
>> as a flexible alarm clock - but it is not so easy with the audible signal...
>> An audible signal has the advantage (over a visual one) that you can
>> recognize it even when you are not looking at the screen (because you
>> are thinking).
>>
>> Unfortunately, I had to give up. My new computer lacks a working
>> speaker...
> 
> There's a simple cheat you can do. Just invoke some other application
> to produce the sound! My current alarm clock comes in two modes: it
> either picks a random MIDI file from Gilbert and Sullivan's
> "Ruddigore", or it plays the "Alice: Madness Returns" theme; in each
> case it just invokes the file with its default association (see the
> "start" command in Windows, or "gnome-open" in, well, GNOME).
> 
> Of course, working speaker IS a prerequisite.

The other prerequisite is that the use is physically near the
compueter where your Python process is running.

If, for exmple, I'm ssh'ed into my webserver, then sending a sound
file to the server's speaker may startle someone in the data centre,
but it won't attract my attention.  If, OTOH, you do:

    print "\7"

, then an ASCII bell will be sent across the network, and my
terminal emulator will beep.

It all depends.


-- HansM





More information about the Python-list mailing list