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?) #(define-music-function (music) (ly:music?)
(set! INLINESCOREMUSIC #{ \INLINESCOREMUSIC #music #}) (set! INLINESCOREMUSIC #{ \INLINESCOREMUSIC #music #})
#{ #{
\transposable #music \transposable #TRANSPOSITION #music
#}) #})

View File

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

View File

@ -1,13 +1,22 @@
TRANSPOSITION = ##f TRANSPOSITION = #(cons #f #f)
transposeGlobal = transposeGlobal =
#(define-void-function (from to) (ly:pitch? ly:pitch?) #(define-void-function (from to) (ly:pitch? ly:pitch?)
(set! TRANSPOSITION (cons from to))) (set! TRANSPOSITION (cons from to)))
transposable = transposable =
#(define-music-function (music) (ly:music?) #(define-music-function (fromto music) (pair? ly:music?)
(if TRANSPOSITION (if (car fromto)
#{ #{
\transpose #(car TRANSPOSITION) #(cdr TRANSPOSITION) #music \transpose #(car fromto) #(cdr fromto) #music
#} #}
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)) ((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))))) ((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?) #(define-markup-command (chord-alignment-style-dependent layout props chord-with-text) (markup?)
(interpret-markup layout props (interpret-markup layout props
(case songTextChordAlignment (case songTextChordAlignment
@ -129,19 +124,22 @@
% Kompletten Vers mit Akkorden % Kompletten Vers mit Akkorden
#(define-markup-command (chordverse layout props stanza verse) (string-or-music? string?) #(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" "Vers mit Akkorden"
(let* ((fromto (chain-assoc-get 'transposition props #f)) (let ((transp (if (car transposition)
(transp (if fromto (string-append "\\transpose " (note-name->string (car transposition)) " " (note-name->string (cdr transposition)))
(string-append "\\transpose " (car fromto) " " (cdr fromto)) "")))
""))
(verselayout (chain-assoc-get 'verselayout props generalLayout)))
(interpret-markup layout props (interpret-markup layout props
(markup #:override `(baseline-skip . ,(+ intraverse-vspace songTextLineHeigth)) #:anchor-x-between #:stanza stanza (markup #:override `(baseline-skip . ,(+ intraverse-vspace songTextLineHeigth)) #:anchor-x-between #:stanza stanza
(make-wrap-newline-markup (make-wrap-newline-markup
(ly:regex-replace (ly:make-regex "\\(( *)([^,()]*)( *),([^)]*)\\)") (ly:regex-replace (ly:make-regex "\\(( *)([^,()]*)( *),([^)]*)\\)")
(ly:regex-replace (ly:make-regex "(([^ \n]*\\([^()]*,[^()]+\\)[^ \n(]*)+)") (handle-custom-newlines custom-verse-breaks verse) " \\concat { " 1 " } ") (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-reference-voice #{#})
(verse-break-voice #{#}) (verse-break-voice #{#})
(verse-line-height songTextLineHeigth) (verse-line-height songTextLineHeigth)
(intraverse-vspace 0)) (intraverse-vspace 0)
(transposition (cons #f #f)))
"Vers mit Akkorden" "Vers mit Akkorden"
(interpret-markup layout props (interpret-markup layout props
#{ #{
@ -234,7 +233,7 @@
\override #`(baseline-skip . ,intraverse-vspace) \override #`(baseline-skip . ,intraverse-vspace)
\pad-left #-5 \pad-left #-5
\score-equal-height #verse-line-height \score-lines { \score-equal-height #verse-line-height \score-lines {
\transposable \transposable #transposition
<< <<
\new Devnull { #verse-break-voice } \new Devnull { #verse-break-voice }
#(music-clone verse-chords) #(music-clone verse-chords)