1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
;;;ConvertToWholeMeasureRests
;This version copes with multiple rests equal to a whole measure rest as long as they are not broken up (e.g. by a barline)
;the loop misses some on the first run so it is called twice
(let ()
(define (do-one)
(if (and (Rest?) (not (d-Directive-chord? "WholeMeasureRest")))
(let ((measuredur (duration::GetWholeMeasureInTicks))
(this (d-GetDurationInTicks)))
(d-SetMark)
(while (and (d-CursorRight) (Rest?))
(set! this (+ this (d-GetDurationInTicks))))
(if (not (Rest?))
(d-CursorLeft))
(if (eq? this measuredur)
(begin
(d-Cut)
(if (None?)
(d-WholeMeasureRest)
(begin
(while (and (d-CursorRight) (not (Appending?))))
(d-Cut)
(d-WholeMeasureRest)
(d-Paste))))))))
(define (do-staff)
(d-MoveToBeginning)
(do-one)
(while (d-NextObject)
(do-one)))
(define (do-movement)
(while (d-StaffUp))
(do-staff)
(while (d-StaffDown)
(do-staff)))
(let ((old-volume (d-MasterVolume)))
(d-PushPosition)
(d-MasterVolume 0)
(while (d-PreviousMovement))
(do-movement)
(do-movement)
(while (d-NextMovement)
(do-movement)
(do-movement))
(d-MasterVolume old-volume)
(d-PopPosition)))
|