howto do a robust simple cross platform beep

Gelonida N gelonida at gmail.com
Sat Jul 14 03:00:05 CEST 2012


Hi,


I just want to use a beep command that works cross platform.


I tried the simplest approach (just printing the BEL character '\a' 
chr(7) to the console.


This fails on my Ubuntu 12.04 host, as the pcspkr is in the list of the 
blacklisted kernel modules.

I found another snippet trying to push a sine wave  directly to /dev/audio

but I don't have write permissions to /dev/audio.

Other solutions seem to suggest to play a wav file, but of course first 
I had to write code creating me a wav file.

How do others handle simple beeps?


I just want to use them as alert, when certain events occur within a 
very long running non GUI application.


Thanks for any info.


What I do at the moment is:

For Windows I use winsound.Beep

For Linux I create some raw data and pipe it into sox's
'play' command.

I don't consider this very elegant.














More information about the Python-list mailing list