lilypond-user
[Top][All Lists]
Advanced

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

Re: Making notes in Scheme?


From: Marcus Macauley
Subject: Re: Making notes in Scheme?
Date: Sun, 15 Oct 2006 16:59:33 -0400
User-agent: Opera Mail/9.00 (Linux)

Nicolas Sceaux wrote:

"Marcus Macauley" <address@hidden> writes:

I see that there are basically two ways to make notes (music) from
within  a Scheme block. As far as I can tell, one way is powerful but
cumbersome,  and the other way is simple but not very powerful. I'm
hoping maybe  there's a third way that I haven't discovered yet, or
that the second way  is more powerful than I know.

May I ask what is exactly what you try to achieve? It might be easier to
advice you then.

BTW, have you tried using \displayMusic? its output can be
copy-and-pasted to build music expressions in scheme.

I tried it briefly, and I've seen its use demonstrated in the documentation, but it seems to require an abundance of information for each note, which I'm hoping to avoid.

What I'm trying to do is create a music function whereby one can input certain starting values, like:

\makeinfinityseries #2 #7 #1 #13

Those values would be used to generate a pitch series; and then that pitch series would be printed in the score.

I've got a working version where I specify those values at the top of the file, e.g.:

firstNote = #2
secondNote = #7
octave = #1
modulus = #13

and those definitions are followed by the Scheme code, which ends with a (make-music) thing that prints the music, without any \score block (or which is assigned to an identifier that I call from within the \score block).

The problem with that is I can only use one set of variables within the score -- I can only print one such pitch series. Of course, I could add another set of variables at the beginning, and process those separately, but I think it would be easiest and most flexible if I could do something like:

\score {
\makeinfinityseries #2 #7 #1 #13
\bar "|"
\makeinfinityseries #2 #9 #2 #13
\break
\makeinfinityseries #4 #5 #1 #13
}

...et cetera.

But I keep getting stuck with the (make-music) thing not printing music, or the variables being "unbound" at the point where they're used, or various other problems, and so I keep thinking there must be a simpler way to print notes from Scheme.

If Lilypond can do:

{ c'4 d' e' }

Surely, I would hope, Scheme can do something simpler than:

(make-music
  'SequentialMusic
  'elements
  (list (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 0 0))))
        (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 1 0))))
        (make-music
          'EventChord
          'elements
          (list (make-music
                  'NoteEvent
                  'duration
                  (ly:make-duration 2 0 1 1)
                  'pitch
                  (ly:make-pitch 0 2 0))))))

or even:

(seq-music-list
(list (make-note (list (make-note-req (ly:make-pitch 1 0 0) (ly:make-duration 2 0)))) (make-note (list (make-note-req (ly:make-pitch 1 1 0) (ly:make-duration 2 0)))) (make-note (list (make-note-req (ly:make-pitch 1 2 0) (ly:make-duration 2 0))))))

...especially as all I want, in this case, is pitches.

And because it's possible to manually type notes within a music function in Scheme, e.g.:

function =
#(define-music-function (parser location var1) (integer?)
#{
     c'4 d' e'
#})

It seems like it should also be possible to substitute variables for those notes, such as:

#(define-music-function (parser location var1) (integer?)
#{
     $firstnote #(list-ref notes 1) #(list-ref notes 2)
#})


From what I can tell, the key is the "ly:music" data type, but I don't know how to to use that from within Scheme, if it's even possible, much less how (if possible) to convert e.g. strings to ly:music.

The "ly:export" function may also have something to do with it, but if so, I haven't figured out quite what.

Thanks for your help,
Marcus




reply via email to

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