]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/creating-a-sequence-of-notes-on-various-pitches.ly
LSR: Update.
[lilypond.git] / Documentation / snippets / creating-a-sequence-of-notes-on-various-pitches.ly
1 %% Do not edit this file; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% This file is in the public domain.
4 \version "2.13.4"
5
6 \header {
7   lsrtags = "pitches"
8
9 %% Translation of GIT committish: b2d4318d6c53df8469dfa4da09b27c15a374d0ca
10   texidoces = "
11 En una música que tenga muchas apariciones de la
12 misma secuencia de notas a distintas alturas, podría ser de
13 utilidad la siguiente función musical.  Admite una nota, de la que
14 sólo se utiliza su altura.  Las funciones de apoyo en Scheme se
15 han tomado prestadas del documento de \"Consejos y trucos\" de la
16 versión 2.10 del manual.  Este ejemplo crea las duraciones
17 rítmicas que se usan a todo lo largo de «Marte», de «Los Planetas»
18 de Gustav Holst.
19
20 "
21   doctitlees = "Crear una secuencia de notas a distintas alturas"
22
23   texidoc = "
24 In music that contains many occurrences of the same sequence of notes
25 at different pitches, the following music function may prove useful.
26 It takes a note, of which only the pitch is used.  The supporting
27 Scheme functions were borrowed from the \"Tips and tricks\" document in
28 the manual for version 2.10.   This example creates the rhythm used
29 throughout Mars, from Gustav Holst's The Planets.
30
31 "
32   doctitle = "Creating a sequence of notes on various pitches"
33 } % begin verbatim
34
35 #(define (make-note-req p d)
36    (make-music 'NoteEvent
37                'duration d
38                'pitch p))
39
40 #(define (make-note p d)
41    (make-music 'EventChord
42                'elements (list (make-note-req p d))))
43
44 #(define (make-triplet elt)
45    (make-music 'TimeScaledMusic
46                'denominator 3
47                'numerator 2
48                'element elt))
49
50 rhythm =
51 #(define-music-function (parser location note) (ly:music?)
52    "Make the rhythm in Mars (the Planets) at the given note's pitch"
53    (let ((p (ly:music-property
54              (car (ly:music-property note 'elements))
55              'pitch)))
56      (make-sequential-music
57       (list
58        (make-triplet (make-sequential-music
59                       (list
60                        (make-note p (ly:make-duration 3 0 2 3))
61                        (make-note p (ly:make-duration 3 0 2 3))
62                        (make-note p (ly:make-duration 3 0 2 3)))))
63        (make-note p (ly:make-duration 2 0))
64        (make-note p (ly:make-duration 2 0))
65        (make-note p (ly:make-duration 3 0))
66        (make-note p (ly:make-duration 3 0))
67        (make-note p (ly:make-duration 2 0))))))
68
69 \new Staff {
70   \time 5/4
71   \rhythm c'
72   \rhythm c''
73   \rhythm g
74 }