all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs audio problem
@ 2013-01-31 18:32 Dan Espen
  2013-02-01 13:38 ` Jason Rumney
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Espen @ 2013-01-31 18:32 UTC (permalink / raw)
  To: help-gnu-emacs


I'm using Emacs 24.1.1 on Fedora Linux.

I while back, I started missing audible indications of errors so I
added this:

(setq ring-bell-function (lambda ()
 (play-sound-file "/home/me/audio/tap2.au")))

This works, but has an undesirable side effect.
It looks like keystrokes are ignored until after the sound plays.

For example, if I arrow up to beyond the top of a file 
I hear some taps.  If I try to do something else with the keyboard
before the sounds stop, the key strokes are ignored.

This doesn't happen running emacs -q.

I think the flushing of keystrokes may be normal,
just not noticeable without something in ring-bell-function.

I tried to speed up ring-bell-function by:

(setq my-sound (get-string-from-file "/home/me/audio/tap2.au"))
and then using:
(play-sound `(sound :data ,my-sound :volume 40))

This seems like it helps.

I added :volume 40 because, for some reason, the sound played too loud.
Coding the volume had the undesirable side effect of turning down (or up)
the volume on all sounds on the system.

That's no good either.

Anyone have a suggestion?

-- 
Dan Espen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs audio problem
  2013-01-31 18:32 Emacs audio problem Dan Espen
@ 2013-02-01 13:38 ` Jason Rumney
  2013-02-01 17:08   ` Dan Espen
  2013-02-02  3:08   ` Dan Espen
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Rumney @ 2013-02-01 13:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Friday, 1 February 2013 02:32:05 UTC+8, Dan Espen  wrote:
> 
> (setq ring-bell-function (lambda ()
> 
>  (play-sound-file "/home/me/audio/tap2.au")))
> 
> This works, but has an undesirable side effect.
> 
> It looks like keystrokes are ignored until after the sound plays.
> 
> Anyone have a suggestion?

Use start-process to have an external program play the sound.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs audio problem
  2013-02-01 13:38 ` Jason Rumney
@ 2013-02-01 17:08   ` Dan Espen
  2013-02-02  3:08   ` Dan Espen
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Espen @ 2013-02-01 17:08 UTC (permalink / raw)
  To: help-gnu-emacs

Jason Rumney <jasonrumney@gmail.com> writes:

> On Friday, 1 February 2013 02:32:05 UTC+8, Dan Espen  wrote:
>> 
>> (setq ring-bell-function (lambda ()
>> 
>>  (play-sound-file "/home/me/audio/tap2.au")))
>> 
>> This works, but has an undesirable side effect.
>> 
>> It looks like keystrokes are ignored until after the sound plays.
>> 
>> Anyone have a suggestion?
>
> Use start-process to have an external program play the sound.

That's an idea.

I tried to follow Emacs code to see if it does something different
for :data vs. :file for the volume issue,
but so far the logic remains hidden from me.
I don't give up easy, so I'll try again.

I'll report back about start-process when I get a chance to try it.

-- 
Dan Espen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs audio problem
  2013-02-01 13:38 ` Jason Rumney
  2013-02-01 17:08   ` Dan Espen
@ 2013-02-02  3:08   ` Dan Espen
  2013-02-02 11:59     ` Adam Jiang
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Espen @ 2013-02-02  3:08 UTC (permalink / raw)
  To: help-gnu-emacs

Jason Rumney <jasonrumney@gmail.com> writes:

> On Friday, 1 February 2013 02:32:05 UTC+8, Dan Espen  wrote:
>> 
>> (setq ring-bell-function (lambda ()
>> 
>>  (play-sound-file "/home/me/audio/tap2.au")))
>> 
>> This works, but has an undesirable side effect.
>> 
>> It looks like keystrokes are ignored until after the sound plays.
>> 
>> Anyone have a suggestion?
>
> Use start-process to have an external program play the sound.

You're right.  Thanks.

This is working for me:

(setq ring-bell-function (lambda ()
 (start-process "ding" nil "play" "/home/me/audio/tap2.au")))

Odd that invoking an external program and reading a file
over and over works better but it does.

-- 
Dan Espen


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Emacs audio problem
  2013-02-02  3:08   ` Dan Espen
@ 2013-02-02 11:59     ` Adam Jiang
  0 siblings, 0 replies; 5+ messages in thread
From: Adam Jiang @ 2013-02-02 11:59 UTC (permalink / raw)
  To: Dan Espen; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 970 bytes --]

It is not odd at all.

Comparing to the original code, play-sound blocks the current thread to
force you wait until it finished, start-process will folk another thread to
finish the work.


2013/2/2 Dan Espen <despen@verizon.net>

> Jason Rumney <jasonrumney@gmail.com> writes:
>
> > On Friday, 1 February 2013 02:32:05 UTC+8, Dan Espen  wrote:
> >>
> >> (setq ring-bell-function (lambda ()
> >>
> >>  (play-sound-file "/home/me/audio/tap2.au")))
> >>
> >> This works, but has an undesirable side effect.
> >>
> >> It looks like keystrokes are ignored until after the sound plays.
> >>
> >> Anyone have a suggestion?
> >
> > Use start-process to have an external program play the sound.
>
> You're right.  Thanks.
>
> This is working for me:
>
> (setq ring-bell-function (lambda ()
>  (start-process "ding" nil "play" "/home/me/audio/tap2.au")))
>
> Odd that invoking an external program and reading a file
> over and over works better but it does.
>
> --
> Dan Espen
>

[-- Attachment #2: Type: text/html, Size: 1647 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-02 11:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-31 18:32 Emacs audio problem Dan Espen
2013-02-01 13:38 ` Jason Rumney
2013-02-01 17:08   ` Dan Espen
2013-02-02  3:08   ` Dan Espen
2013-02-02 11:59     ` Adam Jiang

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.