]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/generating-random-notes.ly
Merge branch 'master' of git://git.sv.gnu.org/lilypond.git into td-lily
[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.38"
4
5 \header {
6   lsrtags = "pitches"
7  texidoc = "
8 This Scheme-based snippet generates 24 random notes (or as many as
9 required), based on the current time (or any randomish number you might
10 wish to specify instead, so you can obtain the same random notes each
11 time): i.e., to get different random notes patterns, just change this
12 number.
13 " }
14 % begin verbatim
15 \score {
16 { #(let ((random-state (seed->random-state (current-time))))
17     (ly:export
18      (make-music 'SequentialMusic 'elements
19       (map (lambda x
20            (let ((idx (random 12 random-state)))
21             (make-music 'EventChord
22              'elements (list (make-music 'NoteEvent
23                               'duration (ly:make-duration 2 0 1 1)
24                               'pitch (ly:make-pitch (quotient idx 7)
25                                       (remainder idx 7)
26                                       0))))))
27        (make-list 24)))))
28    }
29 }