Autorensystem erweitert mit Angaben von Teilbeiträgen

This commit is contained in:
tux 2024-01-03 22:31:59 +01:00
parent f5d5e1b020
commit a0f60bc1c7
2 changed files with 38 additions and 7 deletions

View File

@ -1,6 +1,7 @@
\paper { \paper {
poetPrefix = "Worte:" poetPrefix = "Worte:"
composerPrefix = "Weise:" composerPrefix = "Weise:"
compositionPrefix = "Satz:"
poetAndComposerEqualPrefix = "Worte und Weise:" poetAndComposerEqualPrefix = "Worte und Weise:"
authorFormat = authorFormat =

View File

@ -27,18 +27,48 @@
(define (format-poet-and-composer authorId) (define (format-poet-and-composer authorId)
(string-append (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) " " (format-author authorId #f))) (string-append (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) " " (format-author authorId #f)))
(define (find-authors-by authorType authors) (define (find-author-ids-by contributionType authors)
(filter-map (lambda (authordata) (if (member authorType authordata) (car authordata) #f)) 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) (define (poet-and-composer-from-authors authors)
(if authors (if authors
(let* ( (let* (
(poetIds (find-authors-by 'text authors)) (poetIds (find-author-ids-by 'text authors))
(composerIds (find-authors-by 'melody authors)) (versePoetData (find-author-id-with-part-numbers 'verse authors))
(poets (map (lambda (poetId) (format-author poetId #f)) poetIds)) (allPoetIds (append poetIds (map car versePoetData)))
(composers (map (lambda (composerId) (format-author composerId (member composerId poetIds))) composerIds))) (composerIds (find-author-ids-by 'melody authors))
(if (equal? poetIds composerIds) (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 'poetAndComposerEqualPrefix) " " (string-join poets ", ")) #f)
(list (list
(string-append (ly:output-def-lookup layout 'poetPrefix) " " (string-join poets ", ")) (string-append (ly:output-def-lookup layout 'poetPrefix) " " (string-join poets ", "))