]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/generating-random-notes.ly
LSR: Update.
[lilypond.git] / input / lsr / generating-random-notes.ly
1 %% Do not edit this file; it is auto-generated from LSR http://lsr.dsi.unimi.it
2 %% This file is in the public domain.
3 \version "2.11.50"
4
5 \header {
6   lsrtags = "pitches"
7
8   texidoc = "
9 This Scheme-based snippet generates 24 random notes (or as many as
10 required), based on the current time (or any randomish number specified
11 instead, in order to obtain the same random notes each time): i.e., to
12 get different random note patterns, just change this number.
13
14 "
15   doctitle = "Generating random notes"
16 } % begin verbatim
17 \score {
18   { #(let ((random-state (seed->random-state (current-time))))
19     (ly:export
20      (make-music 'SequentialMusic 'elements
21       (map (lambda x
22            (let ((idx (random 12 random-state)))
23             (make-music 'EventChord
24              'elements (list (make-music 'NoteEvent
25                               'duration (ly:make-duration 2 0 1 1)
26                               'pitch (ly:make-pitch (quotient idx 7)
27                                       (remainder idx 7)
28                                       0))))))
29        (make-list 24)))))
30   }
31 }