\version "2.19.81" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% After: %%%% %%%% http://lsr.di.unimi.it/LSR/Item?id=856 %%%% see also lists.gnu.org/archive/html/lilypond-user/2013-12/msg00828.html %%%% by Paul Morris %% tonic-num: number of the tonic note 0-6, C=0, B=6 %% acc-type: the accidental sign type, 1/2=sharp, -1/2=flat %% acc-count: the number and type of accidentals in the key signature %% values are: -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 %% (negative = flats, positive = sharps) %% tonic-acc: #f if the tonic note is not sharp or flat, otherwise a pair %% maj-num: number of the tonic note 0-6, if the key sig were major %% mode-num: number of the mode 0-6 %% txt-size: size of key name text %% mult: for correct resizing when the staff is resized %% This list will be filled by the engraver and %% 'replace-key-sig-name'-markup-command accesses it #(define key-signature-list '()) #(define update-key-signature-list ;; Update `key-signature-list' by a pair containing a number and `entry' ;; The numbers increase. (lambda (entry) (set! key-signature-list (cons (cons (1+ (length key-signature-list)) entry) key-signature-list)))) #(define (initial-moment? ctx) "Is current-moment the @code{ZERO-MOMENT} or before?" (not (ly:momentstring arg) "key-signature-name") (make-line-markup (assoc-get which key-signature-list (list "??"))) arg))) \layout { \context { \Staff \consists \Store_initial_key_engraver } } %%%%%%%%%%%%%%%%%%%%%%%%% %% EXAMPLES %%%%%%%%%%%%%%%%%%%%%%%%% txt = \markuplist { Some text later that states that the above piece starts in key-signature-name key } lazySpacer = \markup \column { \vspace #1 \draw-hline } \new Staff \relative f'' { \key cis \minor c1 d \key b \minor a1 } \markup \replace-key-sig-name #1 \txt \lazySpacer \new Staff \relative f'' { \key gis \minor c1 d \key d \major a1 } \markup \replace-key-sig-name #2 \txt \lazySpacer \new Staff \relative f'' { c1 d a1 } \markup \replace-key-sig-name #3 \txt \lazySpacer \new Staff \relative f'' { \key c \major c1 d a1 } \markup \replace-key-sig-name #4 \txt \lazySpacer \new Staff \relative f'' { \key as \major c1 d \key d \major a1 } \markup \replace-key-sig-name #5 \txt \lazySpacer