comparison base/methods.lisp @ 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 b3260d1d2419
children c4e9a7bb9897
comparison
equal deleted inserted replaced
257:30b6b848ec75 258:aac79c0ac1b9
543 ((time> next-start moment) 543 ((time> next-start moment)
544 (make-standard-anchored-period (timepoint start) 544 (make-standard-anchored-period (timepoint start)
545 (duration bar-duration)))))) 545 (duration bar-duration))))))
546 546
547 (defmethod ioi-from-bar ((event event)) 547 (defmethod ioi-from-bar ((event event))
548 (- (timepoint (onset event)) 548 "Within-short-bar-p here is for catching anacruses. The correct IOI
549 (timepoint (current-bar event (composition event))))) 549 of the event(s) from the barline can be calculated by finding the
550 corresponding position of timepoint 0 relative to the bar, and then
551 calculating the event IOI relative to that. FIXME: This will almost
552 certainly not be the desired behaviour if 'short bars' are found
553 within a piece. Also, what about 'long bars'? Also, more generally,
554 what should we do if get-app-time-sig gives us multiple
555 time-signatures? We should at least be checking."
556 (cond
557 ((within-short-bar-p event)
558 (+ (timepoint (onset event))
559 (- (duration (bar-period (car (get-applicable-time-signatures
560 event (composition event)))
561 event))
562 (duration (current-bar event (composition event))))))
563 (t
564 (- (timepoint (onset event))
565 (timepoint (current-bar event (composition event)))))))
550 566
551 (defmethod ioi-from-bar ((constituent constituent)) 567 (defmethod ioi-from-bar ((constituent constituent))
568 "FIXME: Check for short bars, or maybe just use the first event?"
552 (- (timepoint (onset constituent)) 569 (- (timepoint (onset constituent))
553 (timepoint (current-bar constituent constituent)))) 570 (timepoint (current-bar constituent constituent))))
554 571
555 (defmethod onset-in-bar ((o moment)) 572 (defmethod onset-in-bar ((o moment))
556 "FIXME: Won't actually work for standard-moments because they do not 573 "FIXME: Won't actually work for standard-moments because they do not
560 577
561 (defmethod onset-in-bar-relative-to-tactus ((o moment)) 578 (defmethod onset-in-bar-relative-to-tactus ((o moment))
562 (1+ (/ (ioi-from-bar o) 579 (1+ (/ (ioi-from-bar o)
563 (tactus-duration 580 (tactus-duration
564 (car (get-applicable-time-signatures o (composition o))))))) 581 (car (get-applicable-time-signatures o (composition o)))))))
582
583 (defmethod within-short-bar-p ((event linked-event))
584 (let ((time-sig (get-applicable-time-signatures event
585 (composition event))))
586 (assert (= (length time-sig) 1))
587 (setf time-sig (car time-sig))
588 (let ((bar-duration (bar-period time-sig (composition event)))
589 (current-bar (current-bar event (composition event))))
590 (duration< current-bar bar-duration))))
565 591
566 (defmethod beat-period ((moment standard-moment) 592 (defmethod beat-period ((moment standard-moment)
567 (time-signature standard-time-signature) 593 (time-signature standard-time-signature)
568 (composition composition)) 594 (composition composition))
569 ;; Simple example - standard-time-signature has constant tactus 595 ;; Simple example - standard-time-signature has constant tactus