]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/generating-random-notes.ly
Merge commit 'ce4b499'
[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 allows you to generate 24 random notes (or as
9 many as you want), based on the current time (or any randomish number
10 you might wish to specify instead, so you can obtain the same random
11 notes each time): i.e. to get different random notes patterns, just
12 change this 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 }