]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/generating-random-notes.ly
Merge branch 'translation' into staging
[lilypond.git] / Documentation / snippets / generating-random-notes.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.dsi.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.17.11"
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
23 \score {
24   {
25     $(let ((random-state (seed->random-state (current-time))))
26        (make-sequential-music
27          (map (lambda (x)
28                 (let ((idx (random 12 random-state)))
29                   (make-event-chord
30                    (list
31                     (make-music 'NoteEvent
32                                 'duration (ly:make-duration 2 0 1/1)
33                                 'pitch (ly:make-pitch
34                                         (quotient idx 7)
35                                         (remainder idx 7)
36                                         0))))))
37               (make-list 24))))
38   }
39 }