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: Richard Shann
Subject: Re: Creating an ly:pitch? value
Date: Sun, 20 Jul 2014 20:52:06 +0100

On Sun, 2014-07-20 at 20:29 +0200, David Kastrup wrote:
> Richard Shann <address@hidden> writes:
> 
> > In music which has a commentary the commentary often refers to excerpts
> > from the main music. When the main music is transposed it is sometimes
> > desirable that the music excerpts in the commentary should have the same
> > transposition.
> > To save editing these separately I would like to create a music function
> > which would be invoked before both the music and any excerpts and would
> > apply a given transposition.
> >
> > I have got as far as this, for transposing up a semitone as in
> > \transpose c cis
> >
> > \version "2.18.0"
> >
> > #(define denemo-transpose (ly:make-pitch 0 0 (/ 1 2)))
> 
> You can write 1/2 instead of (/ 1 2) here.  In 2.19.0, you can actually
> write
> #(define denemo-transpose #{ cis #})
> but I am afraid that this interpretation is not available in 2.18.0
> 
> > myfunc = #(define-music-function
> >      (parser location arg)
> >      (ly:music?)
> >      #{
> >         \transpose c' #denemo-transpose #arg
> >      #})
> >
> >
> > {c' d' e'
> > \myfunc 
> > {c' d' e'}}
> >
> > As you can see I have defined a global variable denemo-transpose to be
> > the pitch that c' should be transposed to.
> > 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.
> 
> You could try
> 
> denemo-transpose = cis'

ah - this is also Mark's suggestion. So a LilyPond assignment like that
is defining a scheme variable of the given name to be the scheme
structure that right hand side parses to. I get it (?). 
(I wonder, does that mean that all sorts of standard scheme variable
names such as "format" need to be avoided as names for LilyPond
assignments? Or is some scoping stuff in play here ...)

Thanks to both of you for speedy answers, sorry to ask what may seem so
elementary.

Richard





reply via email to

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