[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scheme problem in lilypond
From: |
Michael Vanier |
Subject: |
Re: scheme problem in lilypond |
Date: |
Fri, 19 Jan 2001 13:11:22 -0800 (PST) |
> Cc: address@hidden
> Content-Type: text/plain; charset=us-ascii
> Date: Fri, 19 Jan 2001 13:18:02 +0100
> From: Mats Bengtsson <address@hidden>
>
> > Hi,
> >
> > I was wondering why this fails in a lilypond file:
> >
> > (define speed 60)
> >
> > ...
> >
> > \midi {
> > \tempo 4 = #speed
> > }
> >
> >
> > I get this:
> >
> > foo.ly:95:0: error: parse error, expecting `DIGIT' or `NUMBER_IDENTIFIER'
> > or `UNSIGNED' or `REAL':
> >
> >
> > I can define and substitute strings with no problem, so why not numbers?
> > Is there a workaround?
>
> In the current Lilypond grammar (as defined by lily/parser.yy),
> the argument to the \tempo command bust be an unsigned integer
> and cannot be specified by a Scheme value. The same holds for,
> for example, note durations. I agree that this may seem inconsistent
> with the use of strings in the grammar. Why do you want to
> specify it in Scheme? If you wish, you could define a Lilypond
> identifier and use as the argument, though:
>
> speed = 60;
>
> \midi {
> \tempo 4 = \speed
> }
>
> /Mats
>
>
>
I'm using scheme definitions to specify a metronome marking like this:
#(define note
'(rows (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
#(define speed 60)
#(define speed-string `(string-append " = " ,(number->string 60)))
% Later, at the beginning of the notes:
c4^#`(rows ,note ,speed-string)
% Later still, for midi:
\midi {
\tempo 4 = 60
}
So even if I define \speed as you say, I still have the problem of getting
it into the metronome marking, which amounts to a way to convert scheme
variables into lilypond variables. Is there a function/macro that does
this?
Slightly off-topic, I'm glad to see lilypond becoming more and more
scheme-ified. Ultimately I think I would like it if most declarations
could be made in scheme e.g.
#(key c major) % instead of "\key c \major;"
#(midi (tempo 4 60))
etc., although I like the current note syntax the way it is. Defining a
clean syntax for music notation is clearly non-trivial.
Cheers,
Mike