- (simple-elements (filter (make-music-type-predicate
- 'NoteEvent 'ClusterNoteEvent 'RestEvent
- 'MultiMeasureRestEvent 'SkipEvent 'LyricEvent)
- elements)))
- (if ((make-music-type-predicate 'StaffSpanEvent 'BreathingEvent) (car elements))
- ;; first, a special case: StaffSpanEvent (\startStaff, \stopStaff)
- ;; and BreathingEvent (\breathe)
- (music->lily-string (car elements) parser)
- (if (and (not (null? simple-elements))
- (null? (cdr simple-elements))
- ;; special case: if this simple_element has any post_events in
- ;; its 'articulations list, it should be interpreted instead
- ;; as a note_chord_element to prevent spurious output, e.g.,
- ;; \displayLilyMusic < c-1\4 >8 -> c-1\48
- (null? (filter post-event?
- (ly:music-property (car simple-elements) 'articulations)))
- ;; same for simple_element with \tweak
- (null? (ly:music-property (car simple-elements) 'tweaks)))
- ;; simple_element : note | figure | rest | mmrest | lyric_element | skip
- (let* ((simple-element (car simple-elements))
- (duration (ly:music-property simple-element 'duration))
- (lily-string (format #f "~a~a~a~{~a ~}"
- (music->lily-string simple-element parser)
- (duration->lily-string duration)
- (if (and ((make-music-type-predicate 'RestEvent) simple-element)
- (ly:pitch? (ly:music-property simple-element 'pitch)))
- "\\rest"
- "")
- (map-in-order (lambda (music)
- (music->lily-string music parser))
- (filter post-event? elements)))))
- (*previous-duration* duration)
- lily-string)
- (let ((chord-elements (filter (make-music-type-predicate
- 'NoteEvent 'ClusterNoteEvent 'BassFigureEvent)
- elements))
- (post-events (filter post-event? elements)))
- (if (not (null? chord-elements))
- ;; note_chord_element : '<' (notepitch | drumpitch)* '>" duration post_events
- (let ((lily-string (format #f "< ~{~a ~}>~a~{~a ~}"
- (map-in-order (lambda (music)
- (music->lily-string music parser))
- chord-elements)
- (duration->lily-string (ly:music-property (car chord-elements)
- 'duration))
- (map-in-order (lambda (music)
- (music->lily-string music parser))
- post-events))))
- (*previous-duration* (ly:music-property (car chord-elements) 'duration))
- lily-string)
- ;; command_element
- (format #f "~{~a ~}" (map-in-order (lambda (music)
- (music->lily-string music parser))
- elements))))))))
-
-(define-display-method MultiMeasureRestMusic (mmrest parser)
- (let* ((dur (ly:music-property mmrest 'duration))
- (ly (format #f "R~a~{~a ~}"
- (duration->lily-string dur)
+ (chord-elements (filter (lambda (m)
+ (music-is-of-type? m 'rhythmic-event))
+ elements))
+ (post-events (filter post-event? elements))
+ (chord-repeat (ly:music-property chord 'duration)))
+ (cond ((ly:duration? chord-repeat)
+ (let ((duration (duration->lily-string chord-repeat #:remember #t)))
+ (format #f "q~a~{~a~^ ~}"
+ duration
+ (map-in-order (lambda (music)
+ (music->lily-string music parser))
+ post-events))))
+ ((pair? chord-elements)
+ ;; note_chord_element : '<' (notepitch | drumpitch)* '>" duration post_events
+ (let ((duration (duration->lily-string (ly:music-property
+ (car chord-elements)
+ 'duration) #:remember #t)))
+ ;; Format duration first so that it does not appear on chord elements
+ (format #f "< ~{~a ~}>~a~{~a~^ ~}"
+ (map-in-order (lambda (music)
+ (music->lily-string music parser))
+ chord-elements)
+ duration