annotate lisp/prim/sound.el @ 164:4e0740e5aab2

Added tag r20-3b8 for changeset 0132846995bd
author cvs
date Mon, 13 Aug 2007 09:43:39 +0200
parents 585fb297b004
children 41ff10fd062f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; sound.el --- Loading sound files in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
19 ;; along with XEmacs; see the file COPYING. If not, write to the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
20 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
21 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Synched up with: Not in FSF.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
24 (defgroup sound nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
25 "Configure XEmacs sounds and properties"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
26 :group 'environment)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
27
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
28 (defcustom sound-default-alist
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
29 '((default :sound bass)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
30 (undefined-key :sound drum)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
31 (undefined-click :sound drum)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
32 ;; beginning-of-buffer or end-of-buffer errors.
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
33 (buffer-bound :sound drum)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
34 ;; buffer-read-only error
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
35 (read-only :sound drum)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
36 ;; non-interactive function or lambda called
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
37 (command-error :sound bass)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
38 (y-or-n-p :sound quiet)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
39 (yes-or-no-p :sound quiet)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
40 (auto-save-error :sound whip :volume 100)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
41 (no-completion :sound whip)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
42 (isearch-failed :sound quiet)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
43 (isearch-quit :sound bass)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
44 ;; QUIT: sound generated by ^G and it's variants.
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
45 (quit :sound quiet :volume 75)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
46 ;; READY: time-consuming task has completed... compile,
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
47 ;; cvs-update, etc.
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
48 (ready :sound cuckoo)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
49 ;; WARP: XEmacs has changed the selected-window or frame
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
50 ;; asynchronously... Especially when it's done by an
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
51 ;; asynchronous process filter. Perhaps by a debugger breakpoint
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
52 ;; has been hit?
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
53 (warp :sound yeep :volume 75)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
54 ;; ALARM: used for reminders...
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
55 (alarm :sound cuckoo :volume 100)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
56 )
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
57 "The alist of sounds and associated error symbols.
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
58
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
59 Used to set sound-alist in load-default-sounds."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
60 :group 'sound
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
61 :type '(repeat
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
62 (group (symbol :tag "Name")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
63 (checklist :inline t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
64 :greedy t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
65 (group :inline t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
66 (const :format "" :value :sound)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
67 (symbol :tag "Sound"))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
68 (group :inline t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
69 (const :format "" :value :volume)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
70 (integer :tag "Volume"))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
71 (group :inline t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
72 (const :format "" :value :pitch)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
73 (integer :tag "Pitch"))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
74 (group :inline t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
75 (const :format "" :value :duration)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
76 (integer :tag "Duration"))))))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
77
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
78 (defcustom sound-load-alist
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
79 '((load-sound-file "drum-beep.au" 'drum)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
80 (load-sound-file "quiet-beep.au" 'quiet)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
81 (load-sound-file "bass-snap.au" 'bass 80)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
82 (load-sound-file "whip.au" 'whip 70)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
83 (load-sound-file "cuckoo.au" 'cuckoo)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
84 (load-sound-file "yeep.au" 'yeep)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
85 (load-sound-file "hype.au" 'hype 100)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
86 )
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
87 "A list of calls to load-sound-file to be processed by load-default-sounds.
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
88
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
89 Reference load-sound-file for more information."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
90
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
91 :group 'sound
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
92 :type '(repeat (sexp :tag "Sound")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
93 ))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
94
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
95 (defcustom default-sound-directory (concat data-directory "sounds/")
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
96 "Default directory to load a sound file from."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
97 :group 'sound
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
98 :type 'directory
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
99 )
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
100
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
101 (defcustom sound-ext ""
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
102 "Filename extensions to complete sound file name with. If more than one
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
103 extension is used, they should be separated by \":\". "
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
104 :group 'sound
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
105 :type 'string)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
106
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
107 (defcustom default-sound-directory-list ( list default-sound-directory )
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
108 "List of directories which to search for sound files"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
109 :group 'sound
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
110 :type '(repeat directory )
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
111 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (or sound-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; these should be silent until sounds are loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (setq sound-alist '((ready nil) (warp nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun load-sound-file (filename sound-name &optional volume)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Read in an audio-file and add it to the sound-alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
122 You can only play sound files if you are running on display 0 of the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
123 console of a machine with native sound support or running a NetAudio
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
124 server and XEmacs has the necessary sound support compiled in.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
125
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 98
diff changeset
126 The sound file must be in the Sun/NeXT U-LAW format, except on Linux,
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 98
diff changeset
127 where .wav files are also supported by the sound card drivers."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (interactive "fSound file name: \n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 SSymbol to name this sound: \n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 nVolume (0 for default): ")
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 136
diff changeset
131 (unless (symbolp sound-name)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 136
diff changeset
132 (error "sound-name not a symbol"))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 138
diff changeset
133 (unless (or (null volume) (integerp volume))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 138
diff changeset
134 (error "volume not an integer or nil"))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
135 (let (buf
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
136 data
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
137 (file (locate-file filename default-sound-directory-list sound-ext)))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 136
diff changeset
138 (unless file
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 136
diff changeset
139 (error "Couldn't load sound file %s" filename))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (set-buffer (setq buf (get-buffer-create " *sound-tmp*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (erase-buffer)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
145 (let ((coding-system-for-read 'binary))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 134
diff changeset
146 (insert-file-contents file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq data (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (and buf (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (let ((old (assq sound-name sound-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; some conses in sound-alist might have been dumped with emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if old (setq sound-alist (delq old (copy-sequence sound-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq sound-alist (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (nconc (list sound-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if (and volume (not (eq 0 volume)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (list ':volume volume))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (list ':sound data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 sound-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 sound-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defun load-default-sounds ()
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 98
diff changeset
164 "Load and install some sound files as beep-types, using
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 98
diff changeset
165 `load-sound-file'. This only works if you're on display 0 of the
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 98
diff changeset
166 console of a machine with native sound support or running a NetAudio
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 98
diff changeset
167 server and XEmacs has the necessary sound support compiled in."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; #### - this should do NOTHING if the sounds can't be played.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (message "Loading sounds...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq sound-alist nil)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
172 ;; this is where the calls to load-sound-file get done
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
173 (mapc 'eval sound-load-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (setq sound-alist
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
175 (append sound-default-alist
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 124
diff changeset
176 sound-alist))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (message "Loading sounds...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; (beep nil 'quiet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; sound.el ends here.