diff --git a/default_songinfo_style.ly b/default_songinfo_style.ly index 61e7aa8..4e5fa8a 100644 --- a/default_songinfo_style.ly +++ b/default_songinfo_style.ly @@ -1,6 +1,7 @@ \paper { poetPrefix = "Worte:" composerPrefix = "Weise:" + compositionPrefix = "Satz:" poetAndComposerEqualPrefix = "Worte und Weise:" authorFormat = diff --git a/footer_with_songinfo.ly b/footer_with_songinfo.ly index 33c56fe..962652a 100644 --- a/footer_with_songinfo.ly +++ b/footer_with_songinfo.ly @@ -27,18 +27,48 @@ (define (format-poet-and-composer authorId) (string-append (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) " " (format-author authorId #f))) - (define (find-authors-by authorType authors) - (filter-map (lambda (authordata) (if (member authorType authordata) (car authordata) #f)) authors) + (define (find-author-ids-by contributionType authors) + (filter-map (lambda (authordata) (if (member contributionType (cdr authordata)) (car authordata) #f)) authors) + ) + + (define (find-author-id-with-part-numbers contributionType authors) + (filter-map (lambda (authordata) + (let ((contributionNumbers (filter-map (lambda (contribution) (if (and (list? contribution) (equal? contributionType (car contribution))) (cadr contribution) #f)) (cdr authordata))) + (authorId (car authordata))) + (if (null? contributionNumbers) #f (cons authorId contributionNumbers)) + )) authors) + ) + + (define (render-contribution-numbers contributionNumbers) + (string-join (map (lambda (contributionNumber) (ly:format "~a." contributionNumber)) contributionNumbers) ", ") + ) + (define (render-verse-contribution contributionNumbers) + (string-append (render-contribution-numbers contributionNumbers) " Strophe: ") + ) + + (define (render-voice-contribution contributionNumbers) + (string-append (render-contribution-numbers contributionNumbers) " Stimme: ") ) (define (poet-and-composer-from-authors authors) (if authors (let* ( - (poetIds (find-authors-by 'text authors)) - (composerIds (find-authors-by 'melody authors)) - (poets (map (lambda (poetId) (format-author poetId #f)) poetIds)) - (composers (map (lambda (composerId) (format-author composerId (member composerId poetIds))) composerIds))) - (if (equal? poetIds composerIds) + (poetIds (find-author-ids-by 'text authors)) + (versePoetData (find-author-id-with-part-numbers 'verse authors)) + (allPoetIds (append poetIds (map car versePoetData))) + (composerIds (find-author-ids-by 'melody authors)) + (compositionIds (find-author-ids-by 'composition authors)) + (voiceComposerData (find-author-id-with-part-numbers 'voice authors)) + (poets (append + (map (lambda (poetId) (format-author poetId #f)) poetIds) + (map (lambda (versePoetEntry) (string-append (render-verse-contribution (cdr versePoetEntry)) (format-author (car versePoetEntry) (member (car versePoetEntry) poetIds)))) versePoetData) + )) + (composers (append + (map (lambda (composerId) (format-author composerId (member composerId allPoetIds))) composerIds) + (map (lambda (composerId) (string-append (ly:output-def-lookup layout 'compositionPrefix) " " (format-author composerId (member composerId allPoetIds)))) compositionIds) + (map (lambda (voiceComposerEntry) (string-append (render-voice-contribution (cdr voiceComposerEntry)) (format-author (car voiceComposerEntry) (member (car voiceComposerEntry) allPoetIds)))) voiceComposerData) + ))) + (if (and (equal? poetIds composerIds) (null? versePoetData) (null? voiceComposerData) (null? compositionIds)) (list (string-append (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) " " (string-join poets ", ")) #f) (list (string-append (ly:output-def-lookup layout 'poetPrefix) " " (string-join poets ", "))