Compare commits

..

2 Commits

Author SHA1 Message Date
tux
5884ab9d2c rework authorsystem
* add translation, interlude, bridge and meloverse
* fix rendering bugs
2024-05-12 18:31:39 +02:00
199f515be9 fix verse-chord multiple transpose problem 2024-05-12 16:13:56 +02:00
2 changed files with 44 additions and 36 deletions

View File

@ -1,3 +1,4 @@
#(use-modules (ice-9 receive))
#(define-markup-command (print-songinfo layout props) () #(define-markup-command (print-songinfo layout props) ()
(define (songinfo-from songId key) (define (songinfo-from songId key)
(let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f))) (let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f)))
@ -62,17 +63,26 @@
) )
(define (render-contribution-group contributionPrefix authorIds) (define (render-contribution-group contributionPrefix authorIds)
(string-append contributionPrefix " " (string-join (format-authors authorIds) ", ")) (if (null? authorIds)
""
(string-append contributionPrefix " " (string-join (format-authors authorIds) ", ")))
) )
(define (render-partial-contribution-group prefixLookup authorData) (define (render-partial-contribution-group prefixLookup authorData)
(string-join (if (null? authorData)
(map (lambda (authorEntry) (render-contribution-group (numbered-contribution-prefix (cdr authorEntry) prefixLookup) (list (car authorEntry)))) authorData) ""
" ") (let ((firstAuthorContributions (cdar authorData)))
(receive (authorDataSame authorDataOther)
(partition (lambda (authorEntry) (equal? (cdr authorEntry) firstAuthorContributions)) authorData)
(string-append
(render-contribution-group (numbered-contribution-prefix firstAuthorContributions prefixLookup) (map car authorDataSame))
" "
(render-partial-contribution-group prefixLookup authorDataOther)
))))
) )
(define (join-present items) (define (join-present items joiner)
(string-join (filter string? items) "; ") (string-join (filter (lambda (item) (and (string? item) (not (string-null? (string-trim-both item))))) items) joiner)
) )
(define (poet-and-composer-from-authors authors) (define (poet-and-composer-from-authors authors)
@ -87,6 +97,10 @@
(compositionIds (find-author-ids-by 'composition authors)) (compositionIds (find-author-ids-by 'composition authors))
(bridgeIds (find-author-ids-by 'bridge authors)) (bridgeIds (find-author-ids-by 'bridge authors))
(interludeIds (find-author-ids-by 'interlude authors)) (interludeIds (find-author-ids-by 'interlude authors))
(year_text (chain-assoc-get 'header:year_text props #f))
(year_translation (chain-assoc-get 'header:year_translation props #f))
(year_melody (chain-assoc-get 'header:year_melody props #f))
(year_composition (chain-assoc-get 'header:year_composition props #f))
) )
(if (and (equal? poetIds composerIds) (null? translatorIds) (null? versePoetData) (null? verseComposerData) (null? voiceComposerData) (null? compositionIds) (null? bridgeIds) (null? interludeIds)) (if (and (equal? poetIds composerIds) (null? translatorIds) (null? versePoetData) (null? verseComposerData) (null? voiceComposerData) (null? compositionIds) (null? bridgeIds) (null? interludeIds))
(list (list
@ -98,41 +112,35 @@
(ly:output-def-lookup layout 'poetPrefix) (ly:output-def-lookup layout 'poetPrefix)
" " " "
(join-present (list (join-present (list
(if (not (null? poetIds)) (join-present (list
(render-contribution-group "" poetIds) (render-contribution-group "" poetIds)
#f) year_text
(if (not (null? versePoetData)) ) ", ")
(render-partial-contribution-group 'versePrefix versePoetData) (render-partial-contribution-group 'versePrefix versePoetData)
#f) (join-present (list
(if (not (null? translatorIds))
(render-contribution-group (ly:output-def-lookup layout 'translationPrefix) translatorIds) (render-contribution-group (ly:output-def-lookup layout 'translationPrefix) translatorIds)
#f) year_translation
)) ) ", ")
) "; ")
)) ))
(if (and (null? composerIds) (null? compositionIds) (null? verseComposerData) (null? voiceComposerData) (null? bridgeIds) (null? interludeIds)) #f (if (and (null? composerIds) (null? compositionIds) (null? verseComposerData) (null? voiceComposerData) (null? bridgeIds) (null? interludeIds)) #f
(string-append (string-append
(ly:output-def-lookup layout 'composerPrefix) (ly:output-def-lookup layout 'composerPrefix)
" " " "
(join-present (list (join-present (list
(if (not (null? composerIds)) (join-present (list
(render-contribution-group "" composerIds) (render-contribution-group "" composerIds)
#f) year_melody
(if (not (null? verseComposerData)) ) ", ")
(render-partial-contribution-group 'versePrefix verseComposerData) (render-partial-contribution-group 'versePrefix verseComposerData)
#f)
(if (not (null? voiceComposerData))
(render-partial-contribution-group 'voicePrefix voiceComposerData) (render-partial-contribution-group 'voicePrefix voiceComposerData)
#f) (join-present (list
(if (not (null? compositionIds))
(render-contribution-group (ly:output-def-lookup layout 'compositionPrefix) compositionIds) (render-contribution-group (ly:output-def-lookup layout 'compositionPrefix) compositionIds)
#f) year_composition
(if (not (null? bridgeIds)) ) ", ")
(render-contribution-group (ly:output-def-lookup layout 'bridgePrefix) bridgeIds) (render-contribution-group (ly:output-def-lookup layout 'bridgePrefix) bridgeIds)
#f)
(if (not (null? interludeIds))
(render-contribution-group (ly:output-def-lookup layout 'interludePrefix) interludeIds) (render-contribution-group (ly:output-def-lookup layout 'interludePrefix) interludeIds)
#f) ) "; ")
))
))))) )))))
(list #f #f) (list #f #f)
) )
@ -152,8 +160,8 @@
(copyright (chain-assoc-get 'header:copyright props #f)) (copyright (chain-assoc-get 'header:copyright props #f))
(translation (chain-assoc-get 'header:translation props #f)) (translation (chain-assoc-get 'header:translation props #f))
(pronunciation (chain-assoc-get 'header:pronunciation props #f)) (pronunciation (chain-assoc-get 'header:pronunciation props #f))
(year_text (chain-assoc-get 'header:year_text props #f)) (year_text (if (string? (car poet-and-composers)) #f (chain-assoc-get 'header:year_text props #f)))
(year_melody (chain-assoc-get 'header:year_melody props #f))) (year_melody (if (string? (car poet-and-composers)) #f (chain-assoc-get 'header:year_melody props #f))))
(markup (markup
#:override (cons 'songinfo:poet-maybe-with-composer #:override (cons 'songinfo:poet-maybe-with-composer
(if (and poet-maybe-with-composer (not (and (string? poet-maybe-with-composer) (string-null? poet-maybe-with-composer)))) poet-maybe-with-composer #f)) (if (and poet-maybe-with-composer (not (and (string? poet-maybe-with-composer) (string-null? poet-maybe-with-composer)))) poet-maybe-with-composer #f))

View File

@ -232,12 +232,12 @@
#{ #{
\markup { \markup {
\override #`(baseline-skip . ,intraverse-vspace) \override #`(baseline-skip . ,intraverse-vspace)
\pad-left #-10 \pad-left #-5
\score-equal-height #verse-line-height \score-lines { \score-equal-height #verse-line-height \score-lines {
\transposable \transposable
<< <<
\new Devnull { #(if (ly:music? verse-break-voice) verse-break-voice) } \new Devnull { #(if (ly:music? verse-break-voice) verse-break-voice) }
#(if (ly:music? verse-chords) verse-chords #{ \chords { \verseChords } #}) #(if (ly:music? verse-chords) (music-clone verse-chords) #{ \chords { \verseChords } #})
\new NullVoice { #(if (ly:music? verse-reference-voice) verse-reference-voice #{ \global \firstVoice #}) } \new NullVoice { #(if (ly:music? verse-reference-voice) verse-reference-voice #{ \global \firstVoice #}) }
\addlyrics { #lyrics } \addlyrics { #lyrics }
>> >>
@ -245,7 +245,7 @@
\lyricsWithChordsLayout \lyricsWithChordsLayout
\context { \context {
\Staff \Staff
\override LeftEdge.space-alist.first-note = #'(fixed-space . 10.0) \override LeftEdge.space-alist.first-note = #'(fixed-space . 5.0)
} }
} }
} }