Mercurial > hg > xemacs-beta
comparison lisp/prim/sound.el @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | 0293115a14e9 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
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 | |
19 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
20 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | |
22 ;;; Synched up with: Not in FSF. | |
23 | |
24 ;;;###autoload | |
25 (or sound-alist | |
26 ;; these should be silent until sounds are loaded | |
27 (setq sound-alist '((ready nil) (warp nil)))) | |
28 | |
29 ;;;###autoload | |
30 (defun load-sound-file (filename sound-name &optional volume) | |
31 "Read in an audio-file and add it to the sound-alist. | |
32 | |
33 You can only play sound files if you are running on display 0 of the console | |
34 of a Sun SparcStation, SGI machine, or HP9000s700, or running a NetAudio | |
35 server. The sound file must be in the Sun/NeXT U-LAW format." | |
36 (interactive "fSound file name: \n\ | |
37 SSymbol to name this sound: \n\ | |
38 nVolume (0 for default): ") | |
39 (or (symbolp sound-name) (error "sound-name not a symbol")) | |
40 (or (null volume) (integerp volume) (error "volume not an integer or nil")) | |
41 (let (buf data) | |
42 (unwind-protect | |
43 (save-excursion | |
44 (set-buffer (setq buf (get-buffer-create " *sound-tmp*"))) | |
45 (buffer-disable-undo (current-buffer)) | |
46 (erase-buffer) | |
47 (insert-file-contents filename) | |
48 (setq data (buffer-string)) | |
49 (erase-buffer)) | |
50 (and buf (kill-buffer buf))) | |
51 (let ((old (assq sound-name sound-alist))) | |
52 ;; some conses in sound-alist might have been dumped with emacs. | |
53 (if old (setq sound-alist (delq old (copy-sequence sound-alist))))) | |
54 (setq sound-alist (cons | |
55 (purecopy | |
56 (nconc (list sound-name) | |
57 (if (and volume (not (eq 0 volume))) | |
58 (list ':volume volume)) | |
59 (list ':sound data))) | |
60 sound-alist))) | |
61 sound-name) | |
62 | |
63 ;;;###autoload | |
64 (defun load-default-sounds () | |
65 "Load and install some sound files as beep-types. | |
66 This only works if you're on display 0 of a Sun SparcStation, SGI machine, | |
67 or HP9000s700, or running a NetAudio server." | |
68 (interactive) | |
69 ;; #### - this should do NOTHING if the sounds can't be played. | |
70 (message "Loading sounds...") | |
71 (setq sound-alist nil) | |
72 (let ((default-directory data-directory)) | |
73 (load-sound-file "sounds/drum-beep.au" 'drum) | |
74 (load-sound-file "sounds/quiet-beep.au" 'quiet) | |
75 (load-sound-file "sounds/bass-snap.au" 'bass 80) | |
76 (load-sound-file "sounds/whip.au" 'whip 70) | |
77 (load-sound-file "sounds/cuckoo.au" 'cuckoo) | |
78 (load-sound-file "sounds/yeep.au" 'yeep) | |
79 (load-sound-file "sounds/hype.au" 'hype 100) | |
80 ) | |
81 (setq sound-alist | |
82 (append | |
83 '((default :sound bass) | |
84 (undefined-key :sound drum) | |
85 (undefined-click :sound drum) | |
86 ;; beginning-of-buffer or end-of-buffer errors. | |
87 (buffer-bound :sound drum) | |
88 ;; buffer-read-only error | |
89 (read-only :sound drum) | |
90 ;; non-interactive function or lambda called | |
91 (command-error :sound bass) | |
92 (y-or-n-p :sound quiet) | |
93 (yes-or-no-p :sound quiet) | |
94 (auto-save-error :sound whip :volume 100) | |
95 (no-completion :sound whip) | |
96 (isearch-failed :sound quiet) | |
97 (isearch-quit :sound bass) | |
98 ;; QUIT: sound generated by ^G and it's variants. | |
99 (quit :sound quiet :volume 75) | |
100 ;; READY: time-consuming task has completed... compile, | |
101 ;; cvs-update, etc. | |
102 (ready :sound cuckoo) | |
103 ;; WARP: XEmacs has changed the selected-window or frame | |
104 ;; asynchronously... Especially when it's done by an | |
105 ;; asynchronous process filter. Perhaps by a debugger breakpoint | |
106 ;; has been hit? | |
107 (warp :sound yeep :volume 75) | |
108 ;; ALARM: used for reminders... | |
109 (alarm :sound cuckoo :volume 100) | |
110 ) | |
111 sound-alist)) | |
112 (message "Loading sounds...done") | |
113 ;; (beep nil 'quiet) | |
114 ) | |
115 | |
116 ;; sound.el ends here. |