Generating random notes
This Scheme-based snippet generates 24 random notes (or as many as
required), based on the current time (or any randomish number specified
instead, in order to obtain the same random notes each time): i.e., to
get different random note patterns, just change this number.
\score {
{
$(let ((random-state (seed->random-state (current-time))))
(make-sequential-music
(map (lambda (x)
(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))))))
(make-list 24))))
}
}
![[image of music]](../ea/lily-9eaf5ee7.png)