lilypond-user
[Top][All Lists]
Advanced

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

Re: ly:pitch and string


From: Paul Morris
Subject: Re: ly:pitch and string
Date: Sat, 11 Oct 2014 12:04:04 -0700 (PDT)

Simon Albrecht-2 wrote
> well, now I did try and make a function for german note names, which 
> discerns major and minor also. Actually it works – the transposition is 
> applied correctly and there are no unexpected messages – but at testing 
> there seemed to be a memory problem: from some point onwards, the 
> newTonicString was always "eses" regardless of the input. Perhaps the 
> computer and I ought to go to sleep. (what a mad sentence that is…)
> And thanks again for your input, Paul.

Hi Simon, I see David has showed a better way.  In the meantime, with a few
edits, I got your function working, so just for good measure, here it is.
Cheers,
-Paul

%%%%%%%%%%%%%%
\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)))))

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' } }

%%%%%%%%%%%%%%



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/ly-pitch-and-string-tp167397p167425.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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