Hello Paul,

Thanks for your help in improving the helper functions; however, ‘inverting’ string-append and cond seems to be based on a misunderstanding. It needs to be

%%%%%%%%%%%%%%
\version "2.19.12"
\language "deutsch"

pitch-to-key-string-german =
#(define-scheme-function
   (parser location p mode)
   (ly:pitch? string?)
   (let*
    ((major? (equal? mode "major"))
     (nn (ly:pitch-notename p))
     (nn-string (if major?
                    (list-ref '("C" "D" "E" "F" "G" "A" "H") nn)
                    (list-ref '("c" "d" "e" "f" "g" "a" "h") nn)))
     (alt (ly:pitch-alteration p))
     (alt-num (+ 2 (* 2 (ly:pitch-alteration p))))
     (alt-string (list-ref '("eses" "es" "" "is" "isis") alt-num))
     ;pitch without octave
     (na (cons nn alt))
     ;helper functions for exceptions in german note naming
     (test (lambda (n a) (equal? na (cons n a))))
     (exc (lambda (ma mi) (if major? ma mi))))

    (string-append nn-string
      (cond
       ((test 2 -1) (exc "Eses" "eses"))
       ((test 2 -1/2) (exc "Es" "es"))
       ((test 5 -1) (exc "Asas" "asas"))
       ((test 5 -1/2) (exc "As" "as"))
       ((test 6 -1/2) (exc "B" "b"))
       (else alt-string)))))

(cond

((test 2 -1) (exc "Eses" "eses"))

((test 2 -1/2) (exc "Es" "es"))

((test 5 -1) (exc "Asas" "asas"))

((test 5 -1/2) (exc "As" "as"))

((test 6 -1/2) (exc "B" "b"))

(else (string-append nn-string alt-string)))))


newTonic = disis'

newTonicString = \pitch-to-key-string-german \newTonic "major"

% for testing:
#(display (string-append "in-" newTonicString))

\bookOutputSuffix #(string-append "in-" newTonicString)

\score { \transpose c \newTonic { c' } }

%%%%%%%%%%%%%%
and then it works very well.

Yours, Simon
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to