home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :Pioneer-vp)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Pioneer-vp.lisp
- ;;
- ;; Copyright ⌐ 1991 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; video player class for controling Pioneer laserdisc players
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies :video-player
- :serial-port
- :Pioneer-u
- )
-
- (export '(Pioneer-vp))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defclass Pioneer-vp (serial-port video-player)
- ((disk-format :reader disk-format))
- (:default-initargs
- :open-on-init-p nil))
-
- (defmethod initialize-instance ((vp Pioneer-vp) &rest initargs &key model)
- ;this method exists solely to allow the :model keyword to be passed in from
- ;Pioneer-player-info plists
- (declare (ignore initargs model))
- (call-next-method))
-
- (defmethod vp-init :after ((vp Pioneer-vp))
- (sport-open vp :flush-p nil))
-
- (defmethod vp-dispose :after ((vp Pioneer-vp))
- (sport-close vp))
-
- (defmethod vp-load ((vp Pioneer-vp) &key)
- (when (char-equal #\1 (char (pld-cmd vp "?D") 0))
- (pld-cmd vp "SA")
- (setf (slot-value vp 'disk-format) (pld-disk-format vp))
- t))
-
- (defmethod vp-loaded-p ((vp Pioneer-vp))
- (and (slot-boundp vp 'disk-format)
- (eq (disk-format vp) (pld-disk-format vp))))
-
- (defmethod vp-max-frame ((vp Pioneer-vp))
- (ecase (disk-format vp)
- (:CAV 65535)
- (:CLV 863970)
- (:CLV-E 863970)))
-
- (defmethod vp-min-frame ((vp Pioneer-vp))
- 0)
-
- (defmethod vp-current-frame ((vp Pioneer-vp))
- (flet ((parse-int (frame-str)
- ;sometimes address strings are returned as "<00000" or ">XXXXXX"
- ;which I assume means your at the extreme addresses of the disk
- ;The Pioneer manuals don't document this feature.
- ;This fn safely handles these cases.
- (parse-integer frame-str
- :start (if (digit-char-p (char frame-str 0)) 0 1))))
- (ecase (pld-address-format vp (disk-format vp))
- (:frame (parse-int (pld-cmd vp "FR?F")))
- (:hmmss (hmmss-to-frame (parse-int (pld-cmd vp "TM?T"))))
- (:hmmssff (hmmssff-to-frame (parse-int (pld-cmd vp "FR?F")))))))
-
- (defmethod vp-seek ((vp Pioneer-vp) frame &key &allow-other-keys)
- (pld-cmd vp "SE" :frame frame)
- t)
-
- (defmethod vp-play ((vp Pioneer-vp))
- (if (frame-limit-p vp)
- (pld-cmd vp "SM" :frame (max-frame-limit vp))
- (pld-cmd vp "CL"))
- (pld-cmd vp "PL")
- t)
-
- (defmethod vp-stop ((vp Pioneer-vp))
- (pld-cmd vp "PA")
- t)
-
- (defmethod vp-freeze ((vp Pioneer-vp))
- (pld-cmd vp "ST")
- t)
-
- (defmethod vp-step ((vp Pioneer-vp) direction)
- (pld-cmd vp (ecase direction (:forward "SF") (:reverse "SR")))
- t)
-
- (defmethod vp-scan ((vp Pioneer-vp) direction speed-x)
- (let ((speed (max (min (* speed-x 60) 255) 1)))
- (ecase direction
- (:forward
- (if (frame-limit-p vp)
- (pld-cmd vp "SM" :frame (max-frame-limit vp))
- (pld-cmd vp "CL"))
- (pld-cmd vp "SPMF" :arg speed))
- (:reverse
- (if (frame-limit-p vp)
- (pld-cmd vp "SM" :frame (min-frame-limit vp))
- (pld-cmd vp "CL"))
- (pld-cmd vp "SPMR" :arg speed))))
- t)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defgeneric pld-address-format (vp disk-format))
-
- (defmethod pld-disk-format ((vp Pioneer-vp))
- (let ((response (pld-cmd vp "?D")))
- (if (char-equal #\1 (char response 0))
- (ecase (char response 1)
- (#\0 :CAV)
- (#\1 (ecase (char (pld-cmd vp "FR" :error-p nil) 0)
- (#\R :CLV-E)
- (#\E :CLV)))
- (#\X :unknown))
- :no-disk)))
-
- (defmethod pld-address ((vp Pioneer-vp) frame disk-format)
- (setf frame (min (max frame 0) (vp-max-frame vp)))
- (ecase (pld-address-format vp disk-format)
- (:frame (values frame :FR))
- (:hmmss (values (frame-to-hmmss frame) :TM))
- (:hmmssff (values (frame-to-hmmssff frame) :FR))))
-
-
- (defmethod pld-cmd ((vp Pioneer-vp) code-string
- &key
- (arg "")
- (frame nil)
- (response-p t)
- (error-p t)
- (flush-p t))
- (let ((cmd-string (if frame
- (multiple-value-bind (addr fmt) (pld-address vp frame (disk-format vp))
- (format nil "~a~a~a" fmt addr code-string))
- (format nil "~a~a" arg code-string))))
- (when (or flush-p response-p) (pld-flush vp))
- (sport-write-line vp cmd-string)
- (when response-p
- (let ((response (pld-read vp :wait-p t)))
- (when (char-equal #\E (char response 0))
- (when error-p (error "~a : Pioneer error code ~a" cmd-string response)))
- response))))
-
- (defmethod pld-read ((vp Pioneer-vp) &key (wait-p nil))
- (multiple-value-bind (str eoln-p) (sport-read-line vp :wait-p wait-p)
- (if eoln-p str (error "partial response (~s) read" str))))
-
- (defmethod pld-flush ((vp Pioneer-vp))
- (sport-flush vp))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
- ;a modest example - primative video controller for a Pioneer 8000
-
- (oou-dependencies :P8000-vp)
-
- (defparameter *vp*
- (make-instance
- 'P8000-vp
- :framehook-fn
- #'(lambda (frame)
- (set-dialog-item-text (view-named :cur-frame *w*) (princ-to-string frame)))
- ))
-
- (vp-init *vp*)
- (vp-load *vp*)
-
- (setf
- *w*
- (make-instance
- 'dialog
- :view-size #@(360 60)
- :view-subviews
- `(
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text "<<<"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-jump *vp* :reverse 500)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text "<<"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-scan *vp* :reverse 4)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text "|<"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-step *vp* :reverse)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text "Ñ"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-stop *vp*)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text ""
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-freeze *vp*)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text ">|"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-step *vp* :forward)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text ">"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-play *vp*)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text ">>"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-scan *vp* :forward 4)))
- ,(make-instance 'button-dialog-item
- :view-size #@(30 20)
- :dialog-item-text ">>>"
- :dialog-item-action #'(lambda (di) (declare (ignore di)) (vp-jump *vp* :forward 500)))
- ,(make-instance 'static-text-dialog-item
- :dialog-item-text "current frame number:")
- ,(make-instance 'static-text-dialog-item
- :view-nick-name :cur-frame
- :view-size #@(100 20)
- :dialog-item-text "????????"))))
-
- ;(vp-dispose *vp*)
-
- ;(vp-limit *vp* nil nil)
- ;(vp-limit *vp* 1401 1500)
-
- |#