repair transposition for books

This commit is contained in:
tux 2024-05-25 13:14:14 +02:00
parent bce9ffe763
commit 0199813a81
4 changed files with 29 additions and 20 deletions

View File

@ -4,5 +4,5 @@ inline-score =
#(define-music-function (music) (ly:music?)
(set! INLINESCOREMUSIC #{ \INLINESCOREMUSIC #music #})
#{
\transposable #music
\transposable #TRANSPOSITION #music
#})

View File

@ -1,7 +1,7 @@
% set the speed of the midi music
#(define midiQuarterNoteSpeed (if (defined? 'midiQuarterNoteSpeed) midiQuarterNoteSpeed 90))
MUSIC = { \transposable \MUSIC }
MUSIC = { \transposable #TRANSPOSITION \MUSIC }
verselayout = \layout {
\LAYOUT
@ -11,6 +11,7 @@ verselayout = \layout {
}
}
TEXT = \markuplist {
\override #`(transposition . ,TRANSPOSITION)
\override #`(verselayout . verselayout)
\override #`(verse-chords . ,#{ \chords { \verseChords } #})
\override #`(verse-reference-voice . ,#{ \global \firstVoice #})

View File

@ -1,13 +1,22 @@
TRANSPOSITION = ##f
TRANSPOSITION = #(cons #f #f)
transposeGlobal =
#(define-void-function (from to) (ly:pitch? ly:pitch?)
(set! TRANSPOSITION (cons from to)))
transposable =
#(define-music-function (music) (ly:music?)
(if TRANSPOSITION
#(define-music-function (fromto music) (pair? ly:music?)
(if (car fromto)
#{
\transpose #(car TRANSPOSITION) #(cdr TRANSPOSITION) #music
\transpose #(car fromto) #(cdr fromto) #music
#}
music))
% Akkorde in Strophen transponieren
#(define-markup-list-command (transpose layout props from to markuplist)
(markup? markup? markup-list?)
(define (markup->pitch m)
(ly:assoc-get (string->symbol (markup->string m)) pitchnames))
(interpret-markup-list layout (prepend-alist-chain 'transposition (cons (markup->pitch from) (markup->pitch to)) props) markuplist))

View File

@ -52,11 +52,6 @@
((center) (make-size-box-to-box-markup use-x use-y abox bbox))
((left) (make-size-box-to-box-left-aligned-markup use-x use-y abox bbox)))))
% Akkorde in Strophen transponieren
#(define-markup-list-command (transpose layout props from to markuplist)
(markup? markup? markup-list?)
(interpret-markup-list layout (prepend-alist-chain 'transposition (cons from to) props) markuplist))
#(define-markup-command (chord-alignment-style-dependent layout props chord-with-text) (markup?)
(interpret-markup layout props
(case songTextChordAlignment
@ -129,19 +124,22 @@
% Kompletten Vers mit Akkorden
#(define-markup-command (chordverse layout props stanza verse) (string-or-music? string?)
#:properties ((intraverse-vspace 0)(custom-verse-breaks '()))
#:properties (
(intraverse-vspace 0)
(custom-verse-breaks '())
(transposition (cons #f #f))
(verselayout generalLayout)
)
"Vers mit Akkorden"
(let* ((fromto (chain-assoc-get 'transposition props #f))
(transp (if fromto
(string-append "\\transpose " (car fromto) " " (cdr fromto))
""))
(verselayout (chain-assoc-get 'verselayout props generalLayout)))
(let ((transp (if (car transposition)
(string-append "\\transpose " (note-name->string (car transposition)) " " (note-name->string (cdr transposition)))
"")))
(interpret-markup layout props
(markup #:override `(baseline-skip . ,(+ intraverse-vspace songTextLineHeigth)) #:anchor-x-between #:stanza stanza
(make-wrap-newline-markup
(ly:regex-replace (ly:make-regex "\\(( *)([^,()]*)( *),([^)]*)\\)")
(ly:regex-replace (ly:make-regex "(([^ \n]*\\([^()]*,[^()]+\\)[^ \n(]*)+)") (handle-custom-newlines custom-verse-breaks verse) " \\concat { " 1 " } ")
"\\textup \\line { \"" 1 "\" " 2 " \"" 3 "\" } \\score { \\transposable " transp " \\chords { s4 " 4 " } \\layout { \\verselayout } }")
"\\textup \\line { \"" 1 "\" " 2 " \"" 3 "\" } \\score { " transp " \\chords { s4 " 4 " } \\layout { \\verselayout } }")
)
))))
@ -226,7 +224,8 @@
(verse-reference-voice #{#})
(verse-break-voice #{#})
(verse-line-height songTextLineHeigth)
(intraverse-vspace 0))
(intraverse-vspace 0)
(transposition (cons #f #f)))
"Vers mit Akkorden"
(interpret-markup layout props
#{
@ -234,7 +233,7 @@
\override #`(baseline-skip . ,intraverse-vspace)
\pad-left #-5
\score-equal-height #verse-line-height \score-lines {
\transposable
\transposable #transposition
<<
\new Devnull { #verse-break-voice }
#(music-clone verse-chords)