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