]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/scheme/creating-a-sequence-of-notes-on-various-pitches.ly
Merge branch 'master' into lilypond/translation
[lilypond.git] / input / lsr / scheme / creating-a-sequence-of-notes-on-various-pitches.ly
1 %%  Do not edit this file; it is auto-generated from LSR!
2 \version "2.11.23"
3
4 \header { texidoc = "
5 In music that contains many occurrences of the same sequence of notes
6 at different pitches, you can use the following music function. It
7 takes a note, of which the pitch is used. The supporting Scheme
8 functions were borrowed from the Tips and Tricks document in the manual.
9
10 This example creates the rhythm used throughout Mars, from The Planets,
11 by Gustav Holst.
12 " }
13
14 #(define (make-note-req p d)
15   (make-music 'NoteEvent
16    'duration d
17    'pitch p))
18
19 #(define (make-note p d)
20   (make-music 'EventChord
21    'elements (list (make-note-req p d))))
22
23 #(define (seq-music-list elts)
24   (make-music 'SequentialMusic
25    'elements elts))
26
27 #(define (make-triplet elt)
28   (make-music 'TimeScaledMusic
29    'denominator 3
30    'numerator 2
31    'element elt))
32
33
34 rhythm = #(define-music-function (parser location note) (ly:music?)
35           "Make the rhythm in Mars (the Planets) at the given note's pitch"
36           (let* ((p (ly:music-property
37                       (car (ly:music-property note 'elements))
38                       'pitch)))
39           (seq-music-list (list
40             (make-triplet (seq-music-list (list
41               (make-note p (ly:make-duration 3 0 2 3))
42               (make-note p (ly:make-duration 3 0 2 3))
43               (make-note p (ly:make-duration 3 0 2 3))
44             )))
45             (make-note p (ly:make-duration 2 0))
46             (make-note p (ly:make-duration 2 0))
47             (make-note p (ly:make-duration 3 0))
48             (make-note p (ly:make-duration 3 0))
49             (make-note p (ly:make-duration 2 0))
50           ))))
51
52 \score {
53    \new Staff {
54        \time 5/4
55
56        \rhythm c'
57        \rhythm c''
58        \rhythm g
59    }
60 }
61