view implementations/midi-db/methods.lisp @ 312:32769840b715

Update midi-db example (add clapping music to db). Ignore-this: 36c28b012dc8a50b1daf6a7ec4de5105 darcs-hash:20100414183655-16a00-f4e9de706e2f6869d977fe35511507cb2a1d5bb0.gz
author j.forth <j.forth@gold.ac.uk>
date Wed, 14 Apr 2010 19:36:55 +0100
parents f99fd6a7bbfc
children c454b4fc9aad
line wrap: on
line source
(cl:in-package #:amuse-midi-db)

(defmethod list-collections ((package (eql *package*)) &key
			     compositions (stream *standard-output*))
  "FIXME: better formatting."
  (let ((collection-rows (%get-all-collection-headers)))
    (flet ((print-separator (&optional (columns 77))
	     (format stream "~% ~A"
		     (make-sequence 'string columns :initial-element #\-))))
      (loop for collection-row in collection-rows
	 do (destructuring-bind (collection-id collection-name description)
		collection-row
	      (format stream "~%Collection-id: ~A~% Name: ~A~% Description: ~A~%"
		      collection-id collection-name description)
	      (when compositions
		(list-compositions package
				   :collection-identifier
				   (make-midi-db-collection-identifier
				    collection-id))))
	 do (print-separator)))))

(defmethod list-compositions ((package (eql *package*)) &key
			      collection-identifier
			      (stream *standard-output*))
  (let ((composition-headers
	 (if collection-identifier
	     (%get-all-collection-composition-headers
	      collection-identifier)
	     (%get-all-composition-headers))))
    (loop for composition-header in composition-headers
       do (destructuring-bind (collection-id filename timebase start
					      duration owner version
					      creation-timestamp
					      deletion-timestamp)
	      composition-header
	    (format stream "~%Collection-id: ~A filename: ~A timebase: ~A start: ~A duration: ~A owner: ~A version: ~A created: ~A deleted: ~A~%"
		    collection-id filename timebase start duration owner
		    version creation-timestamp deletion-timestamp)))))