]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/creating-a-sequence-of-notes-on-various-pitches.ly
726cf8422aa10fe9dfebeaae5618f5fc55662455
[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.38"
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
12 manual. This example creates the rhythm used throughout Mars, from
13 Gustav Holst's The Planets. 
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     \rhythm c'
58     \rhythm c''
59     \rhythm g
60   }
61 }