Mercurial > hg > amuse
changeset 258:aac79c0ac1b9
add within-short-bar-p, and use this to correctly calculate the
ioi-from-bar of anacruses
author | Jamie Forth <j.forth@gold.ac.uk> |
---|---|
date | Thu, 24 Feb 2011 18:50:38 +0000 |
parents | 30b6b848ec75 |
children | c4e9a7bb9897 |
files | base/generics.lisp base/methods.lisp base/package.lisp |
diffstat | 3 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/base/generics.lisp Thu Feb 24 18:40:23 2011 +0000 +++ b/base/generics.lisp Thu Feb 24 18:50:38 2011 +0000 @@ -477,6 +477,8 @@ (:documentation "The position of moment in the bar, measure in tactus beats.")) +(defgeneric within-short-bar-p (constituent)) + ;;;;;;;;;;;;;; ;; ;;
--- a/base/methods.lisp Thu Feb 24 18:40:23 2011 +0000 +++ b/base/methods.lisp Thu Feb 24 18:50:38 2011 +0000 @@ -545,10 +545,27 @@ (duration bar-duration)))))) (defmethod ioi-from-bar ((event event)) - (- (timepoint (onset event)) - (timepoint (current-bar event (composition event))))) + "Within-short-bar-p here is for catching anacruses. The correct IOI +of the event(s) from the barline can be calculated by finding the +corresponding position of timepoint 0 relative to the bar, and then +calculating the event IOI relative to that. FIXME: This will almost +certainly not be the desired behaviour if 'short bars' are found +within a piece. Also, what about 'long bars'? Also, more generally, +what should we do if get-app-time-sig gives us multiple +time-signatures? We should at least be checking." + (cond + ((within-short-bar-p event) + (+ (timepoint (onset event)) + (- (duration (bar-period (car (get-applicable-time-signatures + event (composition event))) + event)) + (duration (current-bar event (composition event)))))) + (t + (- (timepoint (onset event)) + (timepoint (current-bar event (composition event))))))) (defmethod ioi-from-bar ((constituent constituent)) + "FIXME: Check for short bars, or maybe just use the first event?" (- (timepoint (onset constituent)) (timepoint (current-bar constituent constituent)))) @@ -563,6 +580,15 @@ (tactus-duration (car (get-applicable-time-signatures o (composition o))))))) +(defmethod within-short-bar-p ((event linked-event)) + (let ((time-sig (get-applicable-time-signatures event + (composition event)))) + (assert (= (length time-sig) 1)) + (setf time-sig (car time-sig)) + (let ((bar-duration (bar-period time-sig (composition event))) + (current-bar (current-bar event (composition event)))) + (duration< current-bar bar-duration)))) + (defmethod beat-period ((moment standard-moment) (time-signature standard-time-signature) (composition composition))
--- a/base/package.lisp Thu Feb 24 18:40:23 2011 +0000 +++ b/base/package.lisp Thu Feb 24 18:50:38 2011 +0000 @@ -160,11 +160,13 @@ #:crotchet #:diatonic-pitch-cp #:diatonic-pitch-mp + #:bar-period #:current-beat #:current-bar #:ioi-from-bar #:onset-in-bar #:onset-in-bar-relative-to-tactus + #:within-short-bar-p ;; condition restart options #:use-whole-bar #:use-crotchet-beat