Slight restructuring of replay registration.
[mumble.git] / src / mumble.lisp
blob17ca7be32168c726c574ca9f73ebfbf6f583271b
1 ;;;
2 ;;; Mumble main body.
3 ;;; Julian Squires / 2004
4 ;;;
6 (in-package :mumble)
8 (eval-when (:compile-toplevel :load-toplevel :execute)
9 (defvar *replay-map* nil))
11 (defstruct replay
12 (name) (special-handler) (channel-creator) (output-fn))
14 (defun register-replay (name special-handler channel-creator output-fn)
15 (let ((replay (make-replay :name name :special-handler special-handler
16 :channel-creator channel-creator
17 :output-fn output-fn)))
18 (aif (position name *replay-map* :test #'equal :key #'replay-name)
19 (setf (nth it *replay-map*) replay)
20 (push replay *replay-map*))))
22 (defun set-tune-replay (name tune)
23 (dolist (replay *replay-map*)
24 (when (equal name (replay-name replay))
25 (setf (tune-replay tune) replay)
26 (return)))
27 (equal (replay-name (tune-replay tune)) name))
29 ;;;; HIGH-LEVEL
31 (defun compile-mumble (in-file out-file)
32 (with-open-file (stream in-file)
33 (let ((tune (parse-mumble-file stream)))
34 (funcall (replay-output-fn (tune-replay tune)) tune out-file))))