changeset 101:c5f04eb31071

monody methods for implementations/geerdes darcs-hash:20070726085425-f76cc-09a061f19b87dfac247358f8c8d66f3b4e5317e6.gz
author David Lewis <d.lewis@gold.ac.uk>
date Thu, 26 Jul 2007 09:54:25 +0100
parents ad9cca28fecf
children 59e69a32b8d9
files implementations/geerdes/methods.lisp
diffstat 1 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/implementations/geerdes/methods.lisp	Wed Jul 25 18:12:18 2007 +0100
+++ b/implementations/geerdes/methods.lisp	Thu Jul 26 09:54:25 2007 +0100
@@ -98,4 +98,49 @@
       LEFT JOIN midi_timesig ts ON (id=ts.constituent_id)
       LEFT JOIN midi_param param ON (id=param.constituent_id)
     WHERE c.file_id=" (princ-to-string file-id)
-    " ORDER BY start")))
\ No newline at end of file
+    " ORDER BY start")))
+
+(defmethod monody ((composition geerdes-composition))
+  (unless (amuse-geerdes::%monody composition)
+    (setf (amuse-geerdes::%monody composition)
+	  (get-monody composition)))
+  (amuse-geerdes::%monody composition))
+
+(defgeneric get-monody (composition))
+(defmethod get-monody ((composition geerdes-composition))
+  ;;; FIXME: FIXED-[THIS IS DANGEROUS - IT EDITS NOTE LENGTH]
+  ;; FIXME: As a result of this fix, notes no longer eq their monody
+  ;; versions
+  ;;; FIXME: This is a serious issue. Needs to be addressed by
+  ;; a proper implementation of constituent with annotations
+  ;;; From DTM: - Select notes
+  ;; on channel 4
+  (let ((vocal-line (loop for event being the elements of (lead-vocal-part composition)
+		       collect (copy-event event))))
+    (when vocal-line
+      (let* ((comp (make-instance 'geerdes-composition
+				  :file-id (file-id composition)
+				  :time (timepoint composition)
+				  :tempi (tempi composition)
+				  :time-signatures (time-signatures composition)
+				  :interval (duration composition)))
+	     (vocal-composition (sequence:adjust-sequence comp
+							  (length vocal-line)
+							  :initial-contents vocal-line))
+	     (monody (make-instance 'geerdes-monody
+				    :time (timepoint composition)
+				    :file-id (file-id composition)
+				    :tempi (tempi composition)
+				    :time-signatures (time-signatures composition)
+				    :interval (duration composition))) ;; Overly inclusive?
+	     (monody-events (monodificate vocal-composition)))
+	(sequence:adjust-sequence monody (length monody-events)
+				  :initial-contents monody-events)))))
+
+(defgeneric lead-vocal-part (time-ordered-constituent)
+  (:method (toc) (remove-if-not #'lead-vocalp toc)))
+
+(defgeneric lead-vocalp (event)
+  (:method (e) (declare (ignore e)) nil))
+(defmethod lead-vocalp ((event geerdes-pitched-event))
+  (= (midi-channel event) 4))