[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
repeat unfold evaluated each time
From: |
Jean-Alexis Montignies |
Subject: |
repeat unfold evaluated each time |
Date: |
Fri, 12 Oct 2012 11:50:05 +0200 |
Hi,
I'm starting to play with scheme in Lilypond.
I'm adapting a snippet about creating random notes. I'd like to be able to make
the code more customizable for a non coding user.
So I tried something like this:
random-state = # (seed->random-state (current-time))
randomNote = #(define-music-function
(parser location) ()
(let ((idx (random 12 random-state)))
(make-event-chord
(list
(make-music 'NoteEvent
'duration (ly:make-duration 2 0
1 1)
'pitch (ly:make-pitch
(quotient idx 7)
(remainder idx 7)
0))))))
\score {
\repeat unfold 24 { $randomNote }
}
I excepted that I wouldn't get what I want :) : $randomNote would be called
only once a the result copied 24 times (24 identical notes).
Is there a way to force lilypond to evaluate the repeated music each time?
Should I write my own repeat function? Or is the only way is really to have a
scheme function returning a list of notes?
Jean-Alexis
- repeat unfold evaluated each time,
Jean-Alexis Montignies <=