Re: Using a variable with \relative

2011-09-11 Thread David Kastrup
Basso Ridiculoso basso.ridicul...@gmail.com writes:

 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.

-- 
David Kastrup


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Using a variable with \relative

2011-09-11 Thread Basso Ridiculoso
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.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Using a variable with \relative

2011-09-11 Thread David Kastrup
Basso Ridiculoso basso.ridicul...@gmail.com writes:

 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.

\relative f

will use whatever note starts that group as the \relative note (think
about it!).

If you want to turn this into a music function, you can to this like
myrelative =
#(define-music-function (parser location music) (ly:music?)
  #{ \relative f $music #})

Does that do what you want?

-- 
David Kastrup


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Using a variable with \relative

2011-09-09 Thread Basso Ridiculoso
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 }

}

}


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

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?

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 }
   #})


Any help would be appreciated, I have looked at some other functions, but
haven't seen anything similar.

Thanks,
Daniel
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user