0
|
1 ;;; sound.el --- Loading sound files in XEmacs
|
|
2
|
|
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
|
5
|
|
6 ;; This file is part of XEmacs.
|
|
7
|
|
8 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
9 ;; under the terms of the GNU General Public License as published by
|
|
10 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;; any later version.
|
|
12
|
|
13 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 ;; General Public License for more details.
|
|
17
|
|
18 ;; You should have received a copy of the GNU General Public License
|
16
|
19 ;; along with XEmacs; see the file COPYING. If not, write to the
|
70
|
20 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
16
|
21 ;; Boston, MA 02111-1307, USA.
|
0
|
22
|
|
23 ;;; Synched up with: Not in FSF.
|
|
24
|
|
25 ;;;###autoload
|
|
26 (or sound-alist
|
|
27 ;; these should be silent until sounds are loaded
|
|
28 (setq sound-alist '((ready nil) (warp nil))))
|
|
29
|
|
30 ;;;###autoload
|
|
31 (defun load-sound-file (filename sound-name &optional volume)
|
|
32 "Read in an audio-file and add it to the sound-alist.
|
|
33
|
70
|
34 You can only play sound files if you are running on display 0 of the console
|
|
35 of a Sun SparcStation, SGI machine, or HP9000s700, or running a NetAudio
|
|
36 server. The sound file must be in the Sun/NeXT U-LAW format."
|
0
|
37 (interactive "fSound file name: \n\
|
|
38 SSymbol to name this sound: \n\
|
|
39 nVolume (0 for default): ")
|
|
40 (or (symbolp sound-name) (error "sound-name not a symbol"))
|
|
41 (or (null volume) (integerp volume) (error "volume not an integer or nil"))
|
|
42 (let (buf data)
|
|
43 (unwind-protect
|
|
44 (save-excursion
|
|
45 (set-buffer (setq buf (get-buffer-create " *sound-tmp*")))
|
|
46 (buffer-disable-undo (current-buffer))
|
|
47 (erase-buffer)
|
|
48 (insert-file-contents filename)
|
|
49 (setq data (buffer-string))
|
|
50 (erase-buffer))
|
|
51 (and buf (kill-buffer buf)))
|
|
52 (let ((old (assq sound-name sound-alist)))
|
|
53 ;; some conses in sound-alist might have been dumped with emacs.
|
|
54 (if old (setq sound-alist (delq old (copy-sequence sound-alist)))))
|
|
55 (setq sound-alist (cons
|
|
56 (purecopy
|
|
57 (nconc (list sound-name)
|
|
58 (if (and volume (not (eq 0 volume)))
|
|
59 (list ':volume volume))
|
|
60 (list ':sound data)))
|
|
61 sound-alist)))
|
|
62 sound-name)
|
|
63
|
|
64 ;;;###autoload
|
|
65 (defun load-default-sounds ()
|
|
66 "Load and install some sound files as beep-types.
|
|
67 This only works if you're on display 0 of a Sun SparcStation, SGI machine,
|
|
68 or HP9000s700, or running a NetAudio server."
|
|
69 (interactive)
|
|
70 ;; #### - this should do NOTHING if the sounds can't be played.
|
|
71 (message "Loading sounds...")
|
|
72 (setq sound-alist nil)
|
|
73 (let ((default-directory data-directory))
|
|
74 (load-sound-file "sounds/drum-beep.au" 'drum)
|
|
75 (load-sound-file "sounds/quiet-beep.au" 'quiet)
|
|
76 (load-sound-file "sounds/bass-snap.au" 'bass 80)
|
|
77 (load-sound-file "sounds/whip.au" 'whip 70)
|
|
78 (load-sound-file "sounds/cuckoo.au" 'cuckoo)
|
|
79 (load-sound-file "sounds/yeep.au" 'yeep)
|
|
80 (load-sound-file "sounds/hype.au" 'hype 100)
|
|
81 )
|
|
82 (setq sound-alist
|
|
83 (append
|
|
84 '((default :sound bass)
|
|
85 (undefined-key :sound drum)
|
|
86 (undefined-click :sound drum)
|
|
87 ;; beginning-of-buffer or end-of-buffer errors.
|
|
88 (buffer-bound :sound drum)
|
|
89 ;; buffer-read-only error
|
|
90 (read-only :sound drum)
|
|
91 ;; non-interactive function or lambda called
|
|
92 (command-error :sound bass)
|
|
93 (y-or-n-p :sound quiet)
|
|
94 (yes-or-no-p :sound quiet)
|
|
95 (auto-save-error :sound whip :volume 100)
|
|
96 (no-completion :sound whip)
|
|
97 (isearch-failed :sound quiet)
|
|
98 (isearch-quit :sound bass)
|
|
99 ;; QUIT: sound generated by ^G and it's variants.
|
|
100 (quit :sound quiet :volume 75)
|
|
101 ;; READY: time-consuming task has completed... compile,
|
|
102 ;; cvs-update, etc.
|
|
103 (ready :sound cuckoo)
|
|
104 ;; WARP: XEmacs has changed the selected-window or frame
|
|
105 ;; asynchronously... Especially when it's done by an
|
|
106 ;; asynchronous process filter. Perhaps by a debugger breakpoint
|
|
107 ;; has been hit?
|
|
108 (warp :sound yeep :volume 75)
|
|
109 ;; ALARM: used for reminders...
|
|
110 (alarm :sound cuckoo :volume 100)
|
|
111 )
|
|
112 sound-alist))
|
|
113 (message "Loading sounds...done")
|
|
114 ;; (beep nil 'quiet)
|
|
115 )
|
|
116
|
|
117 ;; sound.el ends here.
|