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