\version "2.14.2" % http://lists.gnu.org/archive/html/lilypond-user/2009-01/msg00588.html % http://lists.gnu.org/archive/html/lilypond-user/2009-01/msg00628.html % http://lists.gnu.org/archive/html/lilypond-user/2011-11/msg00196.html #(define (has-duration? music) (ly:duration? (ly:music-property music 'duration))) #(define (not-has-duration? music) (not (has-duration? music))) keepsOnlyFirstNote = #(define-music-function (parser location music) (ly:music?) (music-map (lambda (evt) (if (eq? 'EventChord (ly:music-property evt 'name)) (let ((elts (ly:music-property evt 'elements))) (if (has-duration? (car elts)) (ly:music-set-property! evt 'elements (cons (car elts) (filter not-has-duration? (cdr elts))))))) evt) music)) chordAlign = #(define-music-function (parser location dir)(number?) (define (chordNameCallback grob) " LEFT = -1 RIGHT = 1 CENTER = 0 " (let* ((ch (ly:text-interface::print grob))) (ly:stencil-aligned-to ch X dir))) ;; "2.15.24": remove the "$" in the following expression! #{ %\once \override ChordNames.ChordName #'stencil = #$chordNameCallback #}) Changes = \chordmode { \chordAlign #-1 r4 g:m r4 f8 d8:m7 ~ d1:m7 r4 g:m r4 f8 d8:m7 ~ d1:m7} Melody = \relative c'' { g4 c a f ~ f1 \break g4 c a f ~ f1 } \score { << \new RhythmicStaff \with { \override VerticalAxisGroup #'staff-staff-spacing = #'((basic-distance . 1) (minimum-distance . 1) (padding . 1)) \accepts "ChordNames" } << \new Voice \chords { \Changes } \new Voice { \keepsOnlyFirstNote \Changes } >> \new Staff { \key f \major \clef treble \time 4/4 \Melody } >> \layout { indent=0 \context { \ChordNames \override ChordName #'Y-offset = #4 \override ChordName #'font-size = #'-1 noChordSymbol = ##f chordChanges = ##t } \context { \RhythmicStaff \override StaffSymbol #'staff-space = #(magstep -3) \override StaffSymbol #'line-count = #0 \override BarLine #'stencil = ##f \override TimeSignature #'transparent = ##t \override NoteHead #'style = #'slash \override NoteColumn #'X-offset = #0.5 fontSize = #-7 \override Stem #'direction = #UP % = \stemUp } } % layout } % score