home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / prim / sound.el < prev    next >
Encoding:
Text File  |  1995-06-21  |  4.2 KB  |  115 lines

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