lilypond-user
[Top][All Lists]
Advanced

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

Re: Using a variable with \relative


From: Basso Ridiculoso
Subject: Re: Using a variable with \relative
Date: Sun, 11 Sep 2011 10:47:19 -0700

Apoligies about the nbsp's, not sure if it was Safari or gmail that
put those in there.

Is there a way to access the pitch variable and put that where I have
the \x so something like (and sorry about the javascript-y syntax) but
something like

x.pitch (but in scheme syntax of course)

so

\relative #( x.pitch #) {.....} or however it would look.

I am tying to generate a bunch of exercise files of which there will
be hundreds (and potentially thousands) of groups of notes and I want
them arranged a certain way. And the note that I want the groups to be
relative to changes based on the note that starts the group, and there
are far too many to put the specific relative note in by hand. So I
was hoping for a way to pass the entire group of notes into a function
and use whatever note starts that group as the \relative note by way
of a variable.

There are probably other ways to skin this cat, and I may just have to
change the way I generate the notes, but if I can access the pitch
value and make \relative see it somehow, that might work.

Thanks for the help!

Daniel

> Is there a way to do something similar to this:
>
>
> \include "english.ly"
>
> x = { c }
> y = { g }
>
> \score {
> <<
> \new Staff {
>     \clef "bass"
>
>     \relative \x { d e f g a }
>
>     \relative \y { bf a c d }
>
>     }
>  }

No (and please don't use unbreakable space in examples, since it makes
copy and paste impossible).

Pitches can't be placed into identifiers.

> Perhaps I need to write a function that sends in a variable?

Music functions return music expressions.  The newfangled scheme
functions (did I commit them already?) don't support ly:export (that
would have been real hard to do), and anyway, ly:export only works for
things that can be put into an identifier.

You can't expect \relative \x to work, but you could make \x { ... }
work in itself for making things relative to something.  And
\relative is a noop for unrelativable music.

> How does one dereference a variable inside of a function?
>
> For instance if I sent in \x how do I say "use the value of x"? Or is
> that necessary?

I have no idea what you are talking about.

>
> This doesn't seem to work either

> MyTestFunction =
> #(define-music-function
> ?? ? (parser location firstnote secondnote thirdnote fourthnote
> fifthnote sixthnote )
> ?? ? ( ly:music? ly:music? ly:music? ly:music? ly:music? ?ly:music? )
> ?? #{ ? ?
> ?? ? ? ? ? ? ? ?\relative $firstnote { $firstnote ? ?$secondnote ? ?
> $thirdnote ?}
> ?? ? ? ? ? ? ? ?\relative $sixthnote { $fourthnote ?$fifthnote
> $sixthnote }
> ?? #})

\relative takes a _pitch_ argument, not a music argument.  What problem
are you actually trying to solve?

I don't see that this makes much sense.



reply via email to

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