;;;
(define-display-method EventChord (chord parser)
- ;; event_chord : simple_element post_events
- ;; | command_element
+ ;; event_chord : command_element
;; | note_chord_element
;; TODO : tagged post_events
;; tagged_post_event: '-' \tag embedded_scm post_event
(let* ((elements (ly:music-property chord 'elements))
- (simple-elements (filter (make-music-type-predicate
- 'NoteEvent 'ClusterNoteEvent 'RestEvent
- '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))
- ;; a non-empty articulation list is only possible with
- ;; chord entry.
- (null? (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 (duration->lily-string
- (ly:music-property simple-element 'duration)
- #:remember #t)))
- (format #f "~a~a~{~a~^ ~}"
- (music->lily-string simple-element parser)
- duration
- (map-in-order (lambda (music)
- (music->lily-string music parser))
- (filter post-event? elements))))
- (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* ((duration (duration->lily-string
- (ly:music-property (car chord-elements) 'duration)
- #:remember #t)))
- (format #f "< ~{~a ~}>~a~{~a~^ ~}"
- (map-in-order (lambda (music)
- (music->lily-string music parser))
- chord-elements)
- duration
- (map-in-order (lambda (music)
- (music->lily-string music parser))
- post-events)))
- ;; 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
(map-in-order (lambda (music)
(music->lily-string music parser))
- (ly:music-property mmrest 'articulations)))))
- (*previous-duration* dur)
- ly))
+ post-events))))
+ (else
+ ;; command_element
+ (format #f "~{~a~^ ~}" (map-in-order (lambda (music)
+ (music->lily-string music parser))
+ elements))))))
+
+(define-display-method MultiMeasureRestMusic (mmrest parser)
+ (format #f "R~a~{~a~^ ~}"
+ (duration->lily-string (ly:music-property mmrest 'duration)
+ #:remember #t)
+ (map-in-order (lambda (music)
+ (music->lily-string music parser))
+ (ly:music-property mmrest 'articulations))))
(define-display-method SkipMusic (skip parser)
(format #f "\\skip ~a" (duration->lily-string (ly:music-property skip 'duration) #:force-duration #t)))