Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25299 > unrolled thread
| Started by | Gelonida N <gelonida@gmail.com> |
|---|---|
| First post | 2012-07-14 03:00 +0200 |
| Last post | 2012-07-14 18:15 -0700 |
| Articles | 12 — 7 participants |
Back to article view | Back to comp.lang.python
howto do a robust simple cross platform beep Gelonida N <gelonida@gmail.com> - 2012-07-14 03:00 +0200
Re: howto do a robust simple cross platform beep Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-14 03:19 +0000
Re: howto do a robust simple cross platform beep Dieter Maurer <dieter@handshake.de> - 2012-07-14 19:54 +0200
Re: howto do a robust simple cross platform beep Chris Angelico <rosuav@gmail.com> - 2012-07-15 04:49 +1000
Re: howto do a robust simple cross platform beep Hans Mulder <hansmu@xs4all.nl> - 2012-07-15 02:39 +0200
Re: howto do a robust simple cross platform beep Chris Angelico <rosuav@gmail.com> - 2012-07-15 11:07 +1000
Re: howto do a robust simple cross platform beep Miki Tebeka <miki.tebeka@gmail.com> - 2012-07-14 11:43 -0700
Re: howto do a robust simple cross platform beep Miki Tebeka <miki.tebeka@gmail.com> - 2012-07-14 11:43 -0700
Re: howto do a robust simple cross platform beep rantingrickjohnson@gmail.com - 2012-07-14 18:15 -0700
Re: howto do a robust simple cross platform beep Gelonida N <gelonida@gmail.com> - 2012-07-24 23:39 +0200
Re: howto do a robust simple cross platform beep Chris Angelico <rosuav@gmail.com> - 2012-07-25 07:52 +1000
Re: howto do a robust simple cross platform beep rantingrickjohnson@gmail.com - 2012-07-14 18:15 -0700
| From | Gelonida N <gelonida@gmail.com> |
|---|---|
| Date | 2012-07-14 03:00 +0200 |
| Subject | howto do a robust simple cross platform beep |
| Message-ID | <mailman.2110.1342227619.4697.python-list@python.org> |
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.
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-07-14 03:19 +0000 |
| Message-ID | <5000e530$0$29995$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #25299 |
On Sat, 14 Jul 2012 03:00:05 +0200, Gelonida N wrote: > 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. Why? Do you hate your users? > 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. There is no cross-platform way to play a beep. Every few years, people complain that Python doesn't have a standard way to play a simple alert sound. Why ask for volunteers to write and maintain the code, and suddenly they go silent. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Dieter Maurer <dieter@handshake.de> |
|---|---|
| Date | 2012-07-14 19:54 +0200 |
| Message-ID | <mailman.2117.1342288491.4697.python-list@python.org> |
| In reply to | #25302 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: >> 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. > > Why? Do you hate your users? 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...
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-07-15 04:49 +1000 |
| Subject | Re: howto do a robust simple cross platform beep |
| Message-ID | <mailman.2119.1342291754.4697.python-list@python.org> |
| In reply to | #25302 |
On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer <dieter@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. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Hans Mulder <hansmu@xs4all.nl> |
|---|---|
| Date | 2012-07-15 02:39 +0200 |
| Subject | Re: howto do a robust simple cross platform beep |
| Message-ID | <50021151$0$6858$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #25318 |
On 14/07/12 20:49:11, Chris Angelico wrote:
> On Sun, Jul 15, 2012 at 3:54 AM, Dieter Maurer <dieter@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
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-07-15 11:07 +1000 |
| Subject | Re: howto do a robust simple cross platform beep |
| Message-ID | <mailman.2124.1342314447.4697.python-list@python.org> |
| In reply to | #25324 |
On Sun, Jul 15, 2012 at 10:39 AM, Hans Mulder <hansmu@xs4all.nl> wrote: > 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. > Sure, though other of the OP's ideas preclude that too. But you could use any network protocol that acknowledges sound (MUDs use \7 following the terminal). ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Miki Tebeka <miki.tebeka@gmail.com> |
|---|---|
| Date | 2012-07-14 11:43 -0700 |
| Message-ID | <7dab9ed5-6109-40ad-9886-55dd99ecefc9@googlegroups.com> |
| In reply to | #25299 |
> How do others handle simple beeps? http://pymedia.org/ ? I *think* the "big" UI frameworks (Qt, wx ...) have some sound support.
[toc] | [prev] | [next] | [standalone]
| From | Miki Tebeka <miki.tebeka@gmail.com> |
|---|---|
| Date | 2012-07-14 11:43 -0700 |
| Message-ID | <mailman.2118.1342291425.4697.python-list@python.org> |
| In reply to | #25299 |
> How do others handle simple beeps? http://pymedia.org/ ? I *think* the "big" UI frameworks (Qt, wx ...) have some sound support.
[toc] | [prev] | [next] | [standalone]
| From | rantingrickjohnson@gmail.com |
|---|---|
| Date | 2012-07-14 18:15 -0700 |
| Message-ID | <4ed2a36d-a034-45d8-84f7-aa71ff17d8b5@googlegroups.com> |
| In reply to | #25299 |
On Friday, July 13, 2012 8:00:05 PM UTC-5, gelonida wrote: > I just want to use a beep command that works cross platform. [...] I > just want to use them as alert, when certain events occur within a > very long running non GUI application. I can see a need for this when facing a non GUI interface. But even "IF" you do manage to play a sound in a cross platform manner; if the speaker volume is too low, or the speakers are turned off, or the computer does not have speakers connected, etc... your user will never hear the alert! In this case, beeping the built-in speaker has the fail-safe advantage. Why not wrap up the functionality and release a module yourself? If you are not sure how to access the speaker on one or more OSs then ask on the list. I would love to see some community effort behind this. PS: Better make sure this module does not exist though ;-)
[toc] | [prev] | [next] | [standalone]
| From | Gelonida N <gelonida@gmail.com> |
|---|---|
| Date | 2012-07-24 23:39 +0200 |
| Message-ID | <mailman.2555.1343165992.4697.python-list@python.org> |
| In reply to | #25328 |
On 07/15/2012 03:15 AM, rantingrickjohnson@gmail.com wrote:> On Friday, July 13, 2012 8:00:05 PM UTC-5, gelonida wrote: >> I just want to use a beep command that works cross platform. [...] I >> just want to use them as alert, when certain events occur within a >> very long running non GUI application. > > I can see a need for this when facing a non GUI interface. That's exactly my usecase. A rather tiny script running for hours and telling the users when results are ready. But even "IF" you do manage to play a sound in a cross platform manner; if the speaker volume is too low, or the speakers are turned off, or the computer does not have speakers connected, etc... your user will never hear the alert! In this case, beeping the built-in speaker has the fail-safe advantage. > Well the user starts the script, because he wants to get immediate notification while being able mimimize the window, work on a different a machine or doing some paperwork or discussions. So it would be up to him to configure the volume appropraitely. > Why not wrap up the functionality and release a module yourself? If you are not sure how to access the speaker on one or more OSs then ask on the list. I would love to see some community effort behind this. > I'm having no some ugly code, that is working on the platforms, that I am using. I'm rather busy, and have no experience in publishing coe, that's good enough for the community. I could try to use this a test case for learning to create communicty modules. Is there any decent getting started guide. Could I use github (as O know git already)? Assuming, the module would achieve a state, where it could be usable by others. How would one register on Pypi? > PS: Better make sure this module does not exist though ;-) > I didn't find one, that's why I asked here.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-07-25 07:52 +1000 |
| Subject | Re: howto do a robust simple cross platform beep |
| Message-ID | <mailman.2556.1343166755.4697.python-list@python.org> |
| In reply to | #25328 |
On Wed, Jul 25, 2012 at 7:39 AM, Gelonida N <gelonida@gmail.com> wrote: > On 07/15/2012 03:15 AM, rantingrickjohnson@gmail.com wrote:> On Friday, July > 13, 2012 8:00:05 PM UTC-5, gelonida wrote: >>> I just want to use a beep command that works cross platform. [...] I >>> just want to use them as alert, when certain events occur within a >>> very long running non GUI application. >> >> I can see a need for this when facing a non GUI interface. > That's exactly my usecase. > A rather tiny script running for hours and telling the users when results > are ready. Sounds reasonable. I'd be inclined to solve just my own problem, though; work it out for the platforms you use, and don't worry too much about the rest. But that's because I'm lazy :) > Could I use github (as O know git already)? You certainly could, though that doesn't help with the whole "building a module" part. (And I can't help there either, never done it. Sorry.) There are quite a few ways of creating an alert such as you describe. The easiest way may be to play a .WAV file rather than a system beep; there are a number of different options on different platforms, so your module could be written in pure Python and basically wrap the whole lot up into a huge bunch of "except ImportError" checks. Here's a few ways: http://stackoverflow.com/questions/307305/play-a-sound-with-python Burying all that complexity behind a simple "play_sound()" function would be handy, and you could easily start with just 2-3 options and add more later. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | rantingrickjohnson@gmail.com |
|---|---|
| Date | 2012-07-14 18:15 -0700 |
| Message-ID | <mailman.2125.1342314907.4697.python-list@python.org> |
| In reply to | #25299 |
On Friday, July 13, 2012 8:00:05 PM UTC-5, gelonida wrote: > I just want to use a beep command that works cross platform. [...] I > just want to use them as alert, when certain events occur within a > very long running non GUI application. I can see a need for this when facing a non GUI interface. But even "IF" you do manage to play a sound in a cross platform manner; if the speaker volume is too low, or the speakers are turned off, or the computer does not have speakers connected, etc... your user will never hear the alert! In this case, beeping the built-in speaker has the fail-safe advantage. Why not wrap up the functionality and release a module yourself? If you are not sure how to access the speaker on one or more OSs then ask on the list. I would love to see some community effort behind this. PS: Better make sure this module does not exist though ;-)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web