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