- ;; undesired elements (like articulations), a new empty chord is
- ;; built. Then, the pitch found in the previous chord are added to
- ;; the new chord, without any "decoration" (e.g. cautionary
- ;; accidentals, fingerings, text scripts, articulations).
- (make-music
- 'EventChord
- 'origin location
- 'elements (append! (filter identity
- (map (lambda (event)
- (and (eqv? (ly:music-property event 'name) 'NoteEvent)
- (make-music
- 'NoteEvent
- 'pitch (ly:music-property event 'pitch)
- 'duration duration)))
- (ly:music-property previous-chord 'elements)))
- articulations)))
+ ;; undesired elements (like articulations), a new empty chord is built.
+ ;; Then, the pitch found in the previous chord are added to the new
+ ;; chord, without any "decoration" (e.g. cautionary accidentals,
+ ;; fingerings, text scripts, articulations). Only the events of types
+ ;; given in `chord-elements-types' and `note-articulation-types' are
+ ;; copied from the original chord elements and note articulations,
+ ;; respectively.
+ (let ((elements (ly:music-property (ly:music-deep-copy previous-chord) 'elements)))
+ (make-music
+ 'EventChord
+ 'origin location
+ 'elements (append!
+ (map (lambda (note)
+ (let ((new-note (make-music 'NoteEvent
+ 'pitch (ly:music-property note 'pitch)
+ 'duration duration))
+ (articulations
+ (filter-events (ly:music-property note 'articulations)
+ note-articulation-types)))
+ (if (not (null? articulations))
+ (set! (ly:music-property new-note 'articulations)
+ articulations))
+ new-note))
+ (filter-events elements '(NoteEvent)))
+ (filter-events elements chord-element-types)
+ articulations))))