#(define-public (move-chord-note n direction) (_i "Transpose a note (numbered as @var{n}) by one octave in @var{direction}.") (lambda (music) (let* ((elts (ly:music-property music 'elements)) (l (length elts)) ;; if direction is up, count from the bottom note upward, ;; if direction is down, count from the top note downward. (count-from (cond ((= direction UP) (- n 1)) ((= direction DOWN) (- l n)))) ;; Notes may not have been entered from bottom to top; ;; extract the pitches and their possible octavation. (pitches (map (lambda (x) (let ((oct (ly:music-property x 'octavation)) (p (ly:music-property x 'pitch))) (if (null? oct) p (ly:pitch-transpose p (ly:make-pitch oct 0 0))))) (filter (lambda (y) (music-is-of-type? y 'note-event)) elts)))) (if (and (music-is-of-type? music 'event-chord) (not (zero? n)) (>= l n)) (begin ;; Sort the actual notes, depending on their pitch. (set! elts (sort elts (lambda (a b) (ly:pitch2 \chordmode {c:maj es:6} %work also with chordmode } { <>^\markup "chords" \ac \bar "||" <>^\markup "drop 2" \dropNote 2 \ac \bar "||" <>^\markup "drop 4" \dropNote 4 \ac \bar "||" <>^\markup "drop 2 and 4" \dropNote 2 \dropNote 4 \ac \bar "||" <>^\markup "rise 1" \riseNote 1 \ac \bar "||" <>^\markup "rise 3" \riseNote 3 \ac \bar "||" <>^\markup "2nd inversion" \invertChords 2 \ac \bar "||" <>^\markup "\"down\" inversion" \invertChords -1 \ac \bar "||" }