428
|
1 /* Sound functions.
|
|
2 Copyright (C) 1992, 1993, 1994 Lucid Inc.
|
|
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
563
|
24 /* This file Mule-ized by Ben Wing, 5-15-01. */
|
|
25
|
428
|
26 /* Originally written by Jamie Zawinski.
|
|
27 Hacked on quite a bit by various others. */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include <time.h>
|
|
31 #include "lisp.h"
|
|
32
|
|
33 #include "buffer.h"
|
|
34 #ifdef HAVE_X_WINDOWS
|
|
35 #include "console-x.h"
|
|
36 #endif
|
|
37 #include "device.h"
|
|
38 #include "redisplay.h"
|
563
|
39 #include "sound.h"
|
|
40
|
428
|
41 #include "sysdep.h"
|
|
42
|
442
|
43 #include "sysfile.h"
|
428
|
44
|
|
45 #ifdef HAVE_NATIVE_SOUND
|
442
|
46 # include "sysproc.h"
|
428
|
47 #endif
|
|
48
|
|
49 #ifdef HAVE_ESD_SOUND
|
563
|
50 extern int esd_play_sound_file (Extbyte *file, int vol);
|
|
51 extern int esd_play_sound_data (UChar_Binary *data, size_t length, int vol);
|
|
52 # define DEVICE_CONNECTED_TO_ESD_P(x) 1 /* #### better check */
|
428
|
53 #endif
|
|
54
|
458
|
55 Fixnum bell_volume;
|
|
56 Fixnum bell_inhibit_time;
|
428
|
57 Lisp_Object Vsound_alist;
|
|
58 Lisp_Object Vsynchronous_sounds;
|
|
59 Lisp_Object Vnative_sound_only_on_console;
|
|
60 Lisp_Object Q_volume, Q_pitch, Q_duration, Q_sound;
|
563
|
61 Lisp_Object Qsound_error;
|
428
|
62
|
|
63
|
|
64 #ifdef HAVE_NAS_SOUND
|
563
|
65 extern int nas_play_sound_file (Extbyte *name, int volume);
|
|
66 extern int nas_play_sound_data (UChar_Binary *data, int length, int volume);
|
428
|
67 extern int nas_wait_for_sounds (void);
|
563
|
68 extern Extbyte *nas_init_play (Display *);
|
|
69 #endif
|
428
|
70
|
563
|
71 DOESNT_RETURN
|
|
72 report_sound_error (const Char_ASCII *string, Lisp_Object data)
|
|
73 {
|
|
74 report_error_with_errno (Qsound_error, string, data);
|
|
75 }
|
428
|
76
|
|
77 DEFUN ("play-sound-file", Fplay_sound_file, 1, 3, "fSound file name: ", /*
|
|
78 Play the named sound file on DEVICE's speaker at the specified volume
|
|
79 \(0-100, default specified by the `bell-volume' variable).
|
|
80 On Unix machines the sound file must be in the Sun/NeXT U-LAW format
|
|
81 except under Linux where WAV files are also supported. On Microsoft
|
|
82 Windows the sound file must be in WAV format.
|
|
83 DEVICE defaults to the selected device.
|
|
84 */
|
|
85 (file, volume, device))
|
|
86 {
|
|
87 /* This function can call lisp */
|
|
88 int vol;
|
|
89 #if defined (HAVE_NATIVE_SOUND) || defined (HAVE_NAS_SOUND) \
|
|
90 || defined (HAVE_ESD_SOUND)
|
|
91 struct device *d = decode_device (device);
|
|
92 #endif
|
|
93 struct gcpro gcpro1;
|
|
94
|
|
95 CHECK_STRING (file);
|
|
96 if (NILP (volume))
|
|
97 vol = bell_volume;
|
|
98 else
|
|
99 {
|
|
100 CHECK_INT (volume);
|
|
101 vol = XINT (volume);
|
|
102 }
|
|
103
|
|
104 GCPRO1 (file);
|
|
105 while (1)
|
|
106 {
|
|
107 file = Fexpand_file_name (file, Qnil);
|
|
108 if (!NILP(Ffile_readable_p (file)))
|
|
109 break;
|
|
110 else
|
|
111 {
|
|
112 /* #### This is crockish. It might be a better idea to try
|
|
113 to open the file, and use report_file_error() if it
|
|
114 fails. --hniksic */
|
|
115 if (NILP (Ffile_exists_p (file)))
|
|
116 file =
|
563
|
117 signal_continuable_error (Qfile_error,
|
|
118 "File does not exist", file);
|
428
|
119 else
|
|
120 file =
|
563
|
121 signal_continuable_error (Qfile_error,
|
|
122 "File is unreadable", file);
|
428
|
123 }
|
|
124 }
|
|
125 UNGCPRO;
|
|
126
|
|
127 #ifdef HAVE_NAS_SOUND
|
|
128 if (DEVICE_CONNECTED_TO_NAS_P (d))
|
|
129 {
|
563
|
130 Extbyte *fileext;
|
428
|
131
|
442
|
132 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name);
|
428
|
133 /* #### NAS code should allow specification of a device. */
|
|
134 if (nas_play_sound_file (fileext, vol))
|
|
135 return Qnil;
|
|
136 }
|
|
137 #endif /* HAVE_NAS_SOUND */
|
|
138
|
|
139 #ifdef HAVE_ESD_SOUND
|
|
140 if (DEVICE_CONNECTED_TO_ESD_P (d))
|
|
141 {
|
563
|
142 Extbyte *fileext;
|
442
|
143 int result;
|
428
|
144
|
442
|
145 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name);
|
|
146
|
|
147 /* #### ESD uses alarm(). But why should we also stop SIGIO? */
|
|
148 stop_interrupts ();
|
|
149 result = esd_play_sound_file (fileext, vol);
|
|
150 start_interrupts ();
|
|
151 if (result)
|
428
|
152 return Qnil;
|
|
153 }
|
|
154 #endif /* HAVE_ESD_SOUND */
|
|
155
|
|
156 #ifdef HAVE_NATIVE_SOUND
|
|
157 if (NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d))
|
|
158 {
|
563
|
159 Extbyte *fileext;
|
428
|
160
|
442
|
161 LISP_STRING_TO_EXTERNAL (file, fileext, Qfile_name);
|
428
|
162 /* The sound code doesn't like getting SIGIO interrupts.
|
|
163 Unix sucks! */
|
|
164 stop_interrupts ();
|
563
|
165 play_sound_file (fileext, vol);
|
428
|
166 start_interrupts ();
|
|
167 QUIT;
|
|
168 }
|
|
169 #endif /* HAVE_NATIVE_SOUND */
|
|
170
|
|
171 return Qnil;
|
|
172 }
|
|
173
|
|
174 static void
|
|
175 parse_sound_alist_elt (Lisp_Object elt,
|
|
176 Lisp_Object *volume,
|
|
177 Lisp_Object *pitch,
|
|
178 Lisp_Object *duration,
|
|
179 Lisp_Object *sound)
|
|
180 {
|
|
181 *volume = Qnil;
|
|
182 *pitch = Qnil;
|
|
183 *duration = Qnil;
|
|
184 *sound = Qnil;
|
|
185 if (! CONSP (elt))
|
|
186 return;
|
|
187
|
|
188 /* The things we do for backward compatibility...
|
|
189 I wish I had just forced this to be a plist to begin with.
|
|
190 */
|
|
191
|
|
192 if (SYMBOLP (elt) || STRINGP (elt)) /* ( name . <sound> ) */
|
|
193 {
|
|
194 *sound = elt;
|
|
195 }
|
|
196 else if (!CONSP (elt))
|
|
197 {
|
|
198 return;
|
|
199 }
|
|
200 else if (NILP (XCDR (elt)) && /* ( name <sound> ) */
|
|
201 (SYMBOLP (XCAR (elt)) ||
|
|
202 STRINGP (XCAR (elt))))
|
|
203 {
|
|
204 *sound = XCAR (elt);
|
|
205 }
|
|
206 else if (INT_OR_FLOATP (XCAR (elt)) && /* ( name <vol> . <sound> ) */
|
|
207 (SYMBOLP (XCDR (elt)) ||
|
|
208 STRINGP (XCDR (elt))))
|
|
209 {
|
|
210 *volume = XCAR (elt);
|
|
211 *sound = XCDR (elt);
|
|
212 }
|
|
213 else if (INT_OR_FLOATP (XCAR (elt)) && /* ( name <vol> <sound> ) */
|
|
214 CONSP (XCDR (elt)) &&
|
|
215 NILP (XCDR (XCDR (elt))) &&
|
|
216 (SYMBOLP (XCAR (XCDR (elt))) ||
|
|
217 STRINGP (XCAR (XCDR (elt)))))
|
|
218 {
|
|
219 *volume = XCAR (elt);
|
|
220 *sound = XCAR (XCDR (elt));
|
|
221 }
|
|
222 else if ((SYMBOLP (XCAR (elt)) || /* ( name <sound> . <vol> ) */
|
|
223 STRINGP (XCAR (elt))) &&
|
|
224 INT_OR_FLOATP (XCDR (elt)))
|
|
225 {
|
|
226 *sound = XCAR (elt);
|
|
227 *volume = XCDR (elt);
|
|
228 }
|
|
229 #if 0 /* this one is ambiguous with the plist form */
|
|
230 else if ((SYMBOLP (XCAR (elt)) || /* ( name <sound> <vol> ) */
|
|
231 STRINGP (XCAR (elt))) &&
|
|
232 CONSP (XCDR (elt)) &&
|
|
233 NILP (XCDR (XCDR (elt))) &&
|
|
234 INT_OR_FLOATP (XCAR (XCDR (elt))))
|
|
235 {
|
|
236 *sound = XCAR (elt);
|
|
237 *volume = XCAR (XCDR (elt));
|
|
238 }
|
|
239 #endif /* 0 */
|
|
240 else /* ( name [ keyword <value> ]* ) */
|
|
241 {
|
|
242 while (CONSP (elt))
|
|
243 {
|
|
244 Lisp_Object key, val;
|
|
245 key = XCAR (elt);
|
|
246 val = XCDR (elt);
|
|
247 if (!CONSP (val))
|
|
248 return;
|
|
249 elt = XCDR (val);
|
|
250 val = XCAR (val);
|
|
251 if (EQ (key, Q_volume))
|
|
252 {
|
|
253 if (INT_OR_FLOATP (val)) *volume = val;
|
|
254 }
|
|
255 else if (EQ (key, Q_pitch))
|
|
256 {
|
|
257 if (INT_OR_FLOATP (val)) *pitch = val;
|
|
258 if (NILP (*sound)) *sound = Qt;
|
|
259 }
|
|
260 else if (EQ (key, Q_duration))
|
|
261 {
|
|
262 if (INT_OR_FLOATP (val)) *duration = val;
|
|
263 if (NILP (*sound)) *sound = Qt;
|
|
264 }
|
|
265 else if (EQ (key, Q_sound))
|
|
266 {
|
|
267 if (SYMBOLP (val) || STRINGP (val)) *sound = val;
|
|
268 }
|
|
269 }
|
|
270 }
|
|
271 }
|
|
272
|
|
273 DEFUN ("play-sound", Fplay_sound, 1, 3, 0, /*
|
|
274 Play a sound of the provided type.
|
|
275 See the variable `sound-alist'.
|
609
|
276
|
|
277 If the sound cannot be played in any other way, the standard "bell" will sound.
|
428
|
278 */
|
|
279 (sound, volume, device))
|
|
280 {
|
|
281 int looking_for_default = 0;
|
|
282 /* variable `sound' is anything that can be a cdr in sound-alist */
|
|
283 Lisp_Object new_volume, pitch, duration, data;
|
|
284 int loop_count = 0;
|
|
285 int vol, pit, dur;
|
|
286 struct device *d = decode_device (device);
|
|
287
|
|
288 /* NOTE! You'd better not signal an error in here. */
|
|
289
|
|
290
|
|
291 try_it_again:
|
|
292 while (1)
|
|
293 {
|
|
294 if (SYMBOLP (sound))
|
|
295 sound = Fcdr (Fassq (sound, Vsound_alist));
|
|
296 parse_sound_alist_elt (sound, &new_volume, &pitch, &duration, &data);
|
|
297 sound = data;
|
|
298 if (NILP (volume)) volume = new_volume;
|
|
299 if (EQ (sound, Qt) || EQ (sound, Qnil) || STRINGP (sound))
|
|
300 break;
|
|
301 if (loop_count++ > 500) /* much bogosity has occurred */
|
|
302 break;
|
|
303 }
|
|
304
|
|
305 if (NILP (sound) && !looking_for_default)
|
|
306 {
|
|
307 looking_for_default = 1;
|
|
308 loop_count = 0;
|
|
309 sound = Qdefault;
|
|
310 goto try_it_again;
|
|
311 }
|
|
312
|
|
313
|
|
314 vol = (INT_OR_FLOATP (volume) ? (int) XFLOATINT (volume) : bell_volume);
|
|
315 pit = (INT_OR_FLOATP (pitch) ? (int) XFLOATINT (pitch) : -1);
|
|
316 dur = (INT_OR_FLOATP (duration) ? (int) XFLOATINT (duration) : -1);
|
|
317
|
|
318 /* If the sound is a string, and we're connected to Nas, do that.
|
|
319 Else if the sound is a string, and we're on console, play it natively.
|
|
320 Else just beep.
|
|
321 */
|
|
322 #ifdef HAVE_NAS_SOUND
|
|
323 if (DEVICE_CONNECTED_TO_NAS_P (d) && STRINGP (sound))
|
|
324 {
|
563
|
325 const UChar_Binary *soundext;
|
428
|
326 Extcount soundextlen;
|
|
327
|
440
|
328 TO_EXTERNAL_FORMAT (LISP_STRING, sound,
|
|
329 ALLOCA, (soundext, soundextlen),
|
|
330 Qbinary);
|
563
|
331 if (nas_play_sound_data (soundext, soundextlen, vol))
|
428
|
332 return Qnil;
|
|
333 }
|
|
334 #endif /* HAVE_NAS_SOUND */
|
|
335
|
|
336 #ifdef HAVE_ESD_SOUND
|
|
337 if (DEVICE_CONNECTED_TO_ESD_P (d) && STRINGP (sound))
|
|
338 {
|
563
|
339 UChar_Binary *soundext;
|
428
|
340 Extcount soundextlen;
|
442
|
341 int succes;
|
428
|
342
|
440
|
343 TO_EXTERNAL_FORMAT (LISP_STRING, sound, ALLOCA, (soundext, soundextlen),
|
|
344 Qbinary);
|
442
|
345
|
|
346 /* #### ESD uses alarm(). But why should we also stop SIGIO? */
|
|
347 stop_interrupts ();
|
563
|
348 succes = esd_play_sound_data (soundext, soundextlen, vol);
|
442
|
349 start_interrupts ();
|
|
350 QUIT;
|
|
351 if(succes)
|
|
352 return Qnil;
|
428
|
353 }
|
|
354 #endif /* HAVE_ESD_SOUND */
|
|
355
|
|
356 #ifdef HAVE_NATIVE_SOUND
|
|
357 if ((NILP (Vnative_sound_only_on_console) || DEVICE_ON_CONSOLE_P (d))
|
|
358 && STRINGP (sound))
|
|
359 {
|
563
|
360 UChar_Binary *soundext;
|
428
|
361 Extcount soundextlen;
|
442
|
362 int succes;
|
428
|
363
|
440
|
364 TO_EXTERNAL_FORMAT (LISP_STRING, sound,
|
|
365 ALLOCA, (soundext, soundextlen),
|
|
366 Qbinary);
|
428
|
367 /* The sound code doesn't like getting SIGIO interrupts. Unix sucks! */
|
|
368 stop_interrupts ();
|
563
|
369 succes = play_sound_data (soundext, soundextlen, vol);
|
428
|
370 start_interrupts ();
|
|
371 QUIT;
|
442
|
372 if (succes)
|
|
373 return Qnil;
|
428
|
374 }
|
|
375 #endif /* HAVE_NATIVE_SOUND */
|
|
376
|
|
377 DEVMETH (d, ring_bell, (d, vol, pit, dur));
|
|
378 return Qnil;
|
|
379 }
|
|
380
|
|
381 DEFUN ("device-sound-enabled-p", Fdevice_sound_enabled_p, 0, 1, 0, /*
|
|
382 Return t if DEVICE is able to play sound. Defaults to selected device.
|
|
383 */
|
|
384 (device))
|
|
385 {
|
|
386 #ifdef HAVE_NAS_SOUND
|
|
387 if (DEVICE_CONNECTED_TO_NAS_P (decode_device (device)))
|
|
388 return Qt;
|
|
389 #endif
|
|
390 #ifdef HAVE_NATIVE_SOUND
|
|
391 if (DEVICE_ON_CONSOLE_P (decode_device (device)))
|
|
392 return Qt;
|
|
393 #endif
|
|
394 return Qnil;
|
|
395 }
|
|
396
|
|
397 DEFUN ("ding", Fding, 0, 3, 0, /*
|
|
398 Beep, or flash the frame.
|
|
399 Also, unless an argument is given,
|
|
400 terminate any keyboard macro currently executing.
|
|
401 When called from lisp, the second argument is what sound to make, and
|
|
402 the third argument is the device to make it in (defaults to the selected
|
|
403 device).
|
|
404 */
|
|
405 (arg, sound, device))
|
|
406 {
|
430
|
407 static time_t last_bell_time;
|
|
408 static struct device *last_bell_device;
|
428
|
409 time_t now;
|
|
410 struct device *d = decode_device (device);
|
|
411
|
|
412 XSETDEVICE (device, d);
|
|
413 now = time (0);
|
|
414
|
|
415 if (NILP (arg) && !NILP (Vexecuting_macro))
|
|
416 /* Stop executing a keyboard macro. */
|
563
|
417 invalid_operation ("Keyboard macro terminated by a command ringing the bell", Qunbound);
|
428
|
418
|
|
419 if (d == last_bell_device && now-last_bell_time < bell_inhibit_time)
|
|
420 return Qnil;
|
442
|
421 else if (!NILP (Vvisible_bell) && DEVMETH (d, flash, (d)))
|
428
|
422 ;
|
|
423 else
|
|
424 Fplay_sound (sound, Qnil, device);
|
|
425
|
|
426 last_bell_time = now;
|
|
427 last_bell_device = d;
|
|
428 return Qnil;
|
|
429 }
|
|
430
|
|
431 DEFUN ("wait-for-sounds", Fwait_for_sounds, 0, 1, 0, /*
|
|
432 Wait for all sounds to finish playing on DEVICE.
|
|
433 */
|
|
434 (device))
|
|
435
|
|
436 {
|
|
437 #ifdef HAVE_NAS_SOUND
|
|
438 struct device *d = decode_device (device);
|
|
439 if (DEVICE_CONNECTED_TO_NAS_P (d))
|
|
440 {
|
|
441 /* #### somebody fix this to be device-dependent. */
|
|
442 nas_wait_for_sounds ();
|
|
443 }
|
|
444 #endif
|
|
445 return Qnil;
|
|
446 }
|
|
447
|
|
448 DEFUN ("connected-to-nas-p", Fconnected_to_nas_p, 0, 1, 0, /*
|
|
449 Return t if connected to NAS server for sounds on DEVICE.
|
|
450 */
|
|
451 (device))
|
|
452 {
|
|
453 #ifdef HAVE_NAS_SOUND
|
|
454 return DEVICE_CONNECTED_TO_NAS_P (decode_device (device)) ? Qt : Qnil;
|
|
455 #else
|
|
456 return Qnil;
|
|
457 #endif
|
|
458 }
|
|
459 #ifdef HAVE_NAS_SOUND
|
|
460
|
|
461 static void
|
|
462 init_nas_sound (struct device *d)
|
|
463 {
|
|
464 #ifdef HAVE_X_WINDOWS
|
|
465 if (DEVICE_X_P (d))
|
|
466 {
|
563
|
467 Extbyte *err_message = nas_init_play (DEVICE_X_DISPLAY (d));
|
442
|
468 DEVICE_CONNECTED_TO_NAS_P (d) = !err_message;
|
428
|
469 /* Print out the message? */
|
|
470 }
|
|
471 #endif /* HAVE_X_WINDOWS */
|
|
472 }
|
|
473
|
|
474 #endif /* HAVE_NAS_SOUND */
|
|
475
|
|
476 #ifdef HAVE_NATIVE_SOUND
|
|
477
|
|
478 static void
|
|
479 init_native_sound (struct device *d)
|
|
480 {
|
|
481 if (DEVICE_TTY_P (d) || DEVICE_STREAM_P (d) || DEVICE_MSWINDOWS_P(d))
|
|
482 DEVICE_ON_CONSOLE_P (d) = 1;
|
|
483 #ifdef HAVE_X_WINDOWS
|
|
484 else
|
|
485 {
|
|
486 /* When running on a machine with native sound support, we cannot use
|
|
487 digitized sounds as beeps unless emacs is running on the same machine
|
|
488 that $DISPLAY points to, and $DISPLAY points to frame 0 of that
|
|
489 machine.
|
|
490 */
|
|
491
|
|
492 Display *display = DEVICE_X_DISPLAY (d);
|
563
|
493 Extbyte *dpy = DisplayString (display);
|
|
494 Extbyte *tail = strchr (dpy, ':');
|
428
|
495 if (! tail ||
|
|
496 strncmp (tail, ":0", 2))
|
|
497 DEVICE_ON_CONSOLE_P (d) = 0;
|
|
498 else
|
|
499 {
|
563
|
500 Extbyte dpyname[255], localname[255];
|
428
|
501
|
|
502 /* some systems can't handle SIGIO or SIGALARM in gethostbyname. */
|
|
503 stop_interrupts ();
|
|
504 strncpy (dpyname, dpy, tail-dpy);
|
|
505 dpyname [tail-dpy] = 0;
|
|
506 if (!*dpyname ||
|
|
507 !strcmp (dpyname, "unix") ||
|
|
508 !strcmp (dpyname, "localhost"))
|
|
509 DEVICE_ON_CONSOLE_P (d) = 1;
|
|
510 else if (gethostname (localname, sizeof (localname)))
|
|
511 DEVICE_ON_CONSOLE_P (d) = 0; /* can't find hostname? */
|
|
512 else
|
|
513 {
|
|
514 /* We have to call gethostbyname() on the result of gethostname()
|
|
515 because the two aren't guaranteed to be the same name for the
|
|
516 same host: on some losing systems, one is a FQDN and the other
|
|
517 is not. Here in the wide wonderful world of Unix it's rocket
|
|
518 science to obtain the local hostname in a portable fashion.
|
|
519
|
|
520 And don't forget, gethostbyname() reuses the structure it
|
|
521 returns, so we have to copy the fucker before calling it
|
|
522 again.
|
|
523
|
|
524 Thank you master, may I have another.
|
|
525 */
|
|
526 struct hostent *h = gethostbyname (dpyname);
|
|
527 if (!h)
|
|
528 DEVICE_ON_CONSOLE_P (d) = 0;
|
|
529 else
|
|
530 {
|
563
|
531 Extbyte hn [255];
|
428
|
532 struct hostent *l;
|
|
533 strcpy (hn, h->h_name);
|
|
534 l = gethostbyname (localname);
|
|
535 DEVICE_ON_CONSOLE_P (d) = (l && !(strcmp (l->h_name, hn)));
|
|
536 }
|
|
537 }
|
|
538 start_interrupts ();
|
|
539 }
|
|
540 }
|
|
541 #endif /* HAVE_X_WINDOWS */
|
|
542 }
|
|
543
|
|
544 #endif /* HAVE_NATIVE_SOUND */
|
|
545
|
|
546 void
|
|
547 init_device_sound (struct device *d)
|
|
548 {
|
|
549 #ifdef HAVE_NAS_SOUND
|
|
550 init_nas_sound (d);
|
|
551 #endif
|
|
552
|
|
553 #ifdef HAVE_NATIVE_SOUND
|
|
554 init_native_sound (d);
|
|
555 #endif
|
|
556 }
|
|
557
|
|
558 void
|
|
559 syms_of_sound (void)
|
|
560 {
|
563
|
561 DEFKEYWORD (Q_volume);
|
|
562 DEFKEYWORD (Q_pitch);
|
|
563 DEFKEYWORD (Q_duration);
|
|
564 DEFKEYWORD (Q_sound);
|
428
|
565
|
563
|
566 DEFERROR_STANDARD (Qsound_error, Qio_error);
|
428
|
567
|
|
568 DEFSUBR (Fplay_sound_file);
|
|
569 DEFSUBR (Fplay_sound);
|
|
570 DEFSUBR (Fding);
|
|
571 DEFSUBR (Fwait_for_sounds);
|
|
572 DEFSUBR (Fconnected_to_nas_p);
|
|
573 DEFSUBR (Fdevice_sound_enabled_p);
|
|
574 }
|
|
575
|
|
576
|
|
577 void
|
|
578 vars_of_sound (void)
|
|
579 {
|
|
580 #ifdef HAVE_NATIVE_SOUND
|
|
581 Fprovide (intern ("native-sound"));
|
|
582 #endif
|
|
583 #ifdef HAVE_NAS_SOUND
|
|
584 Fprovide (intern ("nas-sound"));
|
|
585 #endif
|
432
|
586 #ifdef HAVE_ESD_SOUND
|
|
587 Fprovide (intern ("esd-sound"));
|
|
588 #endif
|
428
|
589
|
|
590 DEFVAR_INT ("bell-volume", &bell_volume /*
|
|
591 *How loud to be, from 0 to 100.
|
|
592 */ );
|
|
593 bell_volume = 50;
|
|
594
|
|
595 DEFVAR_INT ("bell-inhibit-time", &bell_inhibit_time /*
|
|
596 *Don't ring the bell on the same device more than once within this many seconds.
|
|
597 */ );
|
|
598 bell_inhibit_time = 0;
|
|
599
|
|
600 DEFVAR_LISP ("sound-alist", &Vsound_alist /*
|
|
601 An alist associating names with sounds.
|
|
602 When `beep' or `ding' is called with one of the name symbols, the associated
|
|
603 sound will be generated instead of the standard beep.
|
|
604
|
|
605 Each element of `sound-alist' is a list describing a sound.
|
|
606 The first element of the list is the name of the sound being defined.
|
|
607 Subsequent elements of the list are alternating keyword/value pairs:
|
|
608
|
|
609 Keyword: Value:
|
|
610 ------- -----
|
|
611 sound A string of raw sound data, or the name of another sound to
|
|
612 play. The symbol `t' here means use the default X beep.
|
|
613 volume An integer from 0-100, defaulting to `bell-volume'
|
|
614 pitch If using the default X beep, the pitch (Hz) to generate.
|
|
615 duration If using the default X beep, the duration (milliseconds).
|
|
616
|
|
617 For compatibility, elements of `sound-alist' may also be:
|
|
618
|
|
619 ( sound-name . <sound> )
|
|
620 ( sound-name <volume> <sound> )
|
|
621
|
|
622 You should probably add things to this list by calling the function
|
|
623 load-sound-file.
|
|
624
|
|
625 Caveats:
|
|
626 - XEmacs must be built with sound support for your system. Not all
|
|
627 systems support sound.
|
|
628
|
|
629 - The pitch, duration, and volume options are available everywhere, but
|
|
630 many X servers ignore the `pitch' option.
|
|
631
|
|
632 The following beep-types are used by emacs itself:
|
|
633
|
|
634 auto-save-error when an auto-save does not succeed
|
|
635 command-error when the emacs command loop catches an error
|
|
636 undefined-key when you type a key that is undefined
|
|
637 undefined-click when you use an undefined mouse-click combination
|
|
638 no-completion during completing-read
|
|
639 y-or-n-p when you type something other than 'y' or 'n'
|
|
640 yes-or-no-p when you type something other than 'yes' or 'no'
|
|
641 default used when nothing else is appropriate.
|
|
642
|
|
643 Other lisp packages may use other beep types, but these are the ones that
|
|
644 the C kernel of Emacs uses.
|
|
645 */ );
|
|
646 Vsound_alist = Qnil;
|
|
647
|
|
648 DEFVAR_LISP ("synchronous-sounds", &Vsynchronous_sounds /*
|
|
649 Play sounds synchronously, if non-nil.
|
|
650 Only applies if NAS is used and supports asynchronous playing
|
|
651 of sounds. Otherwise, sounds are always played synchronously.
|
|
652 */ );
|
|
653 Vsynchronous_sounds = Qnil;
|
|
654
|
|
655 DEFVAR_LISP ("native-sound-only-on-console", &Vnative_sound_only_on_console /*
|
|
656 Non-nil value means play sounds only if XEmacs is running
|
|
657 on the system console.
|
442
|
658 Nil means always play sounds, even if running on a non-console tty
|
428
|
659 or a secondary X display.
|
|
660
|
|
661 This variable only applies to native sound support.
|
|
662 */ );
|
|
663 Vnative_sound_only_on_console = Qt;
|
|
664
|
|
665 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
|
|
666 {
|
|
667 void vars_of_hpplay (void);
|
|
668 vars_of_hpplay ();
|
|
669 }
|
|
670 #endif
|
|
671 }
|