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