[Top][All Lists]

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

Scheme question

From: Marcus Macauley
Subject: Scheme question
Date: Fri, 13 Oct 2006 12:44:43 -0400
User-agent: Opera Mail/9.00 (Linux)

I've read in the Lilypond documentation chapter 11, "Interfaces for programmers", Appendix B, "Scheme tutorial", and the beginning of the Scheme manual at:

But I'm stuck on a simple problem which probably has a simple answer.

In the Lilypond Snippet Repository, there's an example titled, "Engraving music using Scheme expressions":

That works fine on my system (Lilypond 2.9.17, Linux).

But I'm trying to make a tiny addition to that code, and it isn't working.

Here is their example, which outputs the notes C and D:

#(define (make-note-req p d)
   (make-music 'NoteEvent
    'duration d
    'pitch p))

#(define (make-note elts)
   (make-music 'EventChord
    'elements elts))

#(define (seq-music-list elts)
   (make-music 'SequentialMusic
    'elements elts))

fooMusic = #(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))))))

\score { \fooMusic

I want to define a variable and plug it into, say, the second number of (ly:make-pitch 1 0 0).

So I would expect that I could simply put one of these lines at the beginning of the file:

mypitch = #0
#(define mypitch 0)

and then change the expression:
(ly:make-pitch 1 0 0)

(ly:make-pitch 1 $mypitch 0)

but when I do that, it complains:
"ERROR: Unbound variable: $mypitch"

Why doesn't this work?


reply via email to

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