]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/generating-random-notes.ly
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[lilypond.git] / Documentation / snippets / generating-random-notes.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.di.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.18.0"
8
9 \header {
10   lsrtags = "pitches, really-cool, scheme-language"
11
12   texidoc = "
13 This Scheme-based snippet generates 24 random notes (or as many as
14 required), based on the current time (or any randomish number specified
15 instead, in order to obtain the same random notes each time): i.e., to
16 get different random note patterns, just change this number.
17
18 "
19   doctitle = "Generating random notes"
20 } % begin verbatim
21
22 \score {
23   {
24     $(let ((random-state (seed->random-state (current-time))))
25        (make-sequential-music
26          (map (lambda (x)
27                 (let ((idx (random 12 random-state)))
28                   (make-event-chord
29                    (list
30                     (make-music 'NoteEvent
31                                 'duration (ly:make-duration 2 0 1/1)
32                                 'pitch (ly:make-pitch
33                                         (quotient idx 7)
34                                         (remainder idx 7)
35                                         0))))))
36               (make-list 24))))
37   }
38 }