lilypond-user
[Top][All Lists]
Advanced

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

Re: Creating an ly:pitch? value


From: Mark Polesky
Subject: Re: Creating an ly:pitch? value
Date: Sun, 20 Jul 2014 11:46:12 -0700

Richard Shann wrote:
> My problem is that the syntax for ly:make-pitch is
> difficult to generate, but I can't seem to find anything
> to convert a string like "cis'" to an ly:pitch? datum.

Richard,

I'm having trouble visualizing what you're trying to
accomplish, couldn't you just do this?

**********************

myPitch = cis'

myfunc =
#(define-music-function
   (parser location arg)
   (ly:music?)
   #{ \transpose c' #myPitch #arg #})

{
  c' d' e'
  \myfunc { c' d' e' }
}

**********************

Otherwise, if for some reason you really need to convert
a string to a pitch object, here's one way to do it:

**********************

stringToPitch =
#(define-scheme-function
   (parser location str)
   (string?)
   (let* ((clone (ly:parser-clone parser '() location))
          (expr (ly:parse-string-_expression_ clone str)))
       (ly:make-pitch (ly:pitch-octave expr)
                      (ly:pitch-notename expr)
                      (ly:pitch-alteration expr))))

myPitch = \stringToPitch #"cis'"

myfunc =
#(define-music-function
   (parser location arg)
   (ly:music?)
   #{ \transpose c' #myPitch #arg #})

{
  c' d' e'
  \myfunc { c' d' e' }
}

**********************

Hope this helps,
Mark

reply via email to

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