lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ly:pitch and string


From: Simon Albrecht
Subject: Re: ly:pitch and string
Date: Sun, 12 Oct 2014 18:50:40 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.1.2

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]