\version "2.19.13" #(define (number-or-pitch? a) (or (integer? a) (ly:pitch? a))) %{ bass-staff = "lo" bass-clef = "bass" bv-one = { \voiceOne \harmonicsOn } bv-two = { \voiceTwo \harmonicsOn } tv-one = { \voiceOne \harmonicsOn } tv-two = \voiceTwo sv-one = { \voiceOne \harmonicsOn } sv-two = \voiceTwo %} bass-staff = "hi" bass-clef = "treble" bv-one = { \voiceFour \harmonicsOn } bv-two = { \voiceTwo \harmonicsOn } tv-one = { \voiceOne \harmonicsOn } tv-two = \voiceThree sv-one = { \voiceOne \harmonicsOn } sv-two = \voiceTwo chordmap = #(define-music-function (parser location start width music) (number-or-pitch? index? ly:music?) (if (ly:pitch? start) (set! start (ly:pitch-semitones start))) (map-some-music (lambda (m) (and (music-is-of-type? m 'event-chord) (begin (set! (ly:music-property m 'elements) (append-map (lambda (x) (let ((p (ly:music-property x 'pitch))) (if (ly:pitch? p) (let loop ((n (ly:make-pitch (- (ly:pitch-octave p) (floor (/ (- (ly:pitch-semitones p) start) 12))) (ly:pitch-notename p) (ly:pitch-alteration p))) (l '())) (if (< (ly:pitch-semitones n) (+ start width)) (loop (ly:pitch-transpose (ly:make-pitch 1 0 0) n) (cons (music-clone x 'pitch n) l)) l)) (list x)))) (ly:music-property m 'elements))) m))) music)) #(define (conflate keys vals) (define (folder k v res) (if (or (null? res) (not (equal? v (cdar res)))) (cons (cons (list k) v) res) (cons (cons (cons k (caar res)) (cdar res)) (cdr res)))) (fold-right folder '() keys vals)) #(define (one-set start count music) (map (lambda (kv) (let ((keys (car kv)) (m (cdr kv))) (cons (if (null? (cdr keys)) (format "~d" (car keys)) (format "~d–~d" (car keys) (last keys))) m))) (conflate (iota count 1) (map (lambda (i) #{ \chordmap #i #12 $music #}) (iota count (ly:pitch-semitones start)))))) #(define (bass-format-set pitch name) (let ((bass #{ \chordmap e,, 12 < $pitch >4 #}) (accf #{ \chordmap a, 41 < $pitch >4 #}) (accp (one-set #{ a, #} 20 #{ < $pitch >4 #}))) #{ << \context Staff = "hi" << \new Voice \with \tv-one { \tempo \markup \caps #name \transpose c c' $accf } \new Voice \with \tv-two { <>_"*" $accf } >> \context Staff = \bass-staff { \clef \bass-clef << \new Voice \with \bv-one \transpose c c' $bass \new Voice \with \bv-two { $bass } >> } >> $@(map (lambda (p) (let ((idx (car p)) (m (cdr p))) #{ << \context Staff = "hi" << \new Voice \with \tv-one \transpose c c' $m \new Voice \with \tv-two { <>_\markup #idx $m } >> \context Staff = \bass-staff << \new Voice \with \bv-one \transpose c c' $bass \new Voice \with \bv-two { $bass } >> >> #})) accp) #})) #(define (chord-format-set chord name) (let ((accf #{ \chordmap a, 41 $chord #}) (accp (one-set #{ a, #} 20 chord))) #{ << \new Voice \with \sv-one { \tempo \markup #name \transpose c c' $accf } \new Voice \with \sv-two { <>_"*" $accf } >> $@(map (lambda (p) (let ((idx (car p)) (m (cdr p))) #{ << \new Voice \with \sv-one \transpose c c' $m \new Voice \with \sv-two { <>_\markup #idx $m } >> #})) accp) #})) #(define (score-format-set pitch name) #{ \score { \new Staff = "hi" { \key $pitch \major \cadenzaOn $(bass-format-set pitch name) \bar "|" $@(map (lambda (c t) #{ \once \accidentalStyle forget $(chord-format-set c #{ \markup \concat { #name #t } #}) \bar "|" #}) (ly:music-property (ly:music-property (ly:music-property #{ \transpose c $pitch \chordmode { c4 c:m c:7^5 c:dim7^5 } #} 'element) 'element) 'elements) '("" "m" "7" "v")) } \layout { indent = 0 \context { \Staff \remove "Time_signature_engraver" \override TextScript.self-alignment-X = #CENTER \override VerticalAxisGroup.outside-staff-placement-directive = #'right-to-left-greedy } } } #}) #(set-global-staff-size 18) $@(map (lambda (p n) (score-format-set p n)) (event-chord-pitches #{ #}) #{ \markuplist { d♭ a♭ e♭ b f c g d a e h f♯ } #})