On Fri, Mar 22, 2019 at 1:01 AM Steve <Gronicus@sga.ninja> wrote:
>
> I believe I can see what is happening here but maybe someone can explain 
> least I run into this again.
>
> Situation 1: I am using "ws.MessageBeep(1)" to generate a tone through the 
> speakers. I wanted two tones to separate it from other tones that might 
> happen and placed that code a second time in the next line.  Sometimes it 
> would not beep, others just one beep.
>
> Situation 2" At the end of my program a report is generated and then it calls 
> timer1.py to remind me when to enter the next readings from the lab.  It 
> looks as if the report generation is interrupted when timer1.py is called.
>
> If I place "time.sleep(1)" between the commands for the beep, I get two beeps 
> one second apart reliably.
> If I place "time.sleep(5)" between the report generation the call for 
> timer1.py is called then apparently there is enough time for the report to be 
> generated.
>
> What is happening?

If I recall the context from previous discussion, "ws.MessageBeep(1)"
creates the same tone that you would get if you had a message box pop
up, right? In that case, Windows is probably suppressing duplicates -
if there's a tone already playing, it won't play it again.

This would be a good reason to switch back to using the PC speaker, as
that would actually consume as much time as the beep does. An easy way
to check this:

>>> t = time.time(); ws.MessageBeep(1); print(time.time() - t)

>>> t = time.time(); ws.Beep(262, 250); print(time.time() - t)

My prediction is that the first one will take negligible time, but the
second will pause for the quarter-second that the beep is taking.

Additionally, this would let you play tones of different pitches, to
separate them from other tones.

Alternatively, if you don't want to use ws.Beep(), it might be best to
switch to explicitly calling on VLC Media Player. Something like:

>>> subprocess.check_call(["vlc", "--play-and-exit", "some-file.wav"])

which should play whatever audio tone you like. Freely usable sound
bites can be obtained from various places on the internet, or you
might have some yourself. (If you have "American McGee's Alice", the
blunderbuss firing sound makes a great alarm tone.
SssssssssssBOOOOOMssssss.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to