Since others have posted code, here's mine. In gui_gtk_x11.c:
At file scope:
#ifdef CANBERRA
# include <canberra.h>
static ca_context *canberra = 0;
#endif
In gui_mch_beep:
#ifdef CANBERRA
int ca_error;
if (!canberra) // static, initialize on first use
ca_context_create (&canberra);
ca_error = ca_context_play (canberra, 0,
CA_PROP_EVENT_ID, "bell",
CA_PROP_EVENT_DESCRIPTION, "vim beep",
CA_PROP_CANBERRA_CACHE_CONTROL, "volatile",
NULL);
if (ca_error)
fprintf(stderr, "%d error, %s\n", ca_error, ca_strerror(ca_error));
#else
...
But also, in misc1.c, in vim_beep:
#ifdef CANBERRA
// john I use a 100 ms beep, which plays asynchronously anyway
// so let's use 50 instead of 500
if (!did_init || ELAPSED_FUNC(start_tv) > 50)
#else
if (!did_init || ELAPSED_FUNC(start_tv) > 500)
#endif
Because libcanberra plays the sound in another thread, or something like that,
it doesn't block, and it handles playing multiple sounds. My keyboard repeat
rate is 50 Hz, and if I hold down the escape key I get 10 sounds a second,
because the sound is 100 ms (thanks to audacity). Having a very fast (that is,
a short attack stage) sound saves me a good fraction of second every time.
Thinking while typing, please excuse me...
The sound themes typically available for the xdg desktop standard have sounds
that are one or 2 seconds long, and usually start slowly. For me that wouldn't
suit vim.
I'd like a general scheme where a different sound could be set for at least
each auto command event. Maybe via an ex command, say "play". F.ex. one could
make vim like a smartphone with key sounds on with InsertCharPre. But I'd like
other events, too, with fine-grained control possible for errors and every
circumstance where vim presently issues a beep.
Python can play sounds, so I suppose I could make a call to python in auto
commands. Maybe all we need is an event for the bell, and for errors, maybe
passing or setting up some context via v:event. (It was a struggle for me to
get all the packages I needed to get my python to use GSound; documentation I
found was not quite up to date. )
So, my conclusion is that there could be an event for all the circumstances
where vim presently may beep, and the relevant item at :h 'belloff' could be
set in v:event. If an error has occurred then v:errmsg gives information.
Then some heroic plugin author can put together the python bits and pieces with
an appropriate sound theme. The large majority who want nothing to do with
sound can continue in their silence, or maybe flash their RGB, or send a
command to an odour generator ;).
Regards, John Little
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/06c490a5-53be-444c-8b9b-9edc033a7629%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.