annotate lisp/prim/sound.el @ 70:131b0175ea99 r20-0b30

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