Jean-Alexis Montignies <[email protected]> writes:

[...]

> 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?

No.

> Should I write my own repeat function?

Won't help as arguments are evaluated before a function is being called.
The best you can do is writing a function that does not receive a music
expression but rather a music function as its argument and then
repeatedly call it.  Or just let randomNote take a count as argument.

> Or is the only way is really to have a scheme function returning a
> list of notes?

That's easier.

-- 
David Kastrup


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to