]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/creating-a-sequence-of-notes-on-various-pitches.ly
8e00a97212491152e47a424f14c12d864eaa12f2
[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.39"
5
6 \header {
7   lsrtags = "pitches"
8
9 %% Translation of GIT committish: 5160eccb26cee0bfd802d844233e4a8d795a1e94
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.   This example
27 creates the rhythm used throughout Mars, from Gustav Holst's The
28 Planets.
29
30 "
31   doctitle = "Creating a sequence of notes on various pitches"
32 } % begin verbatim
33
34 #(define (make-note-req p d)
35    (make-music 'NoteEvent
36                'duration d
37                'pitch p))
38
39 #(define (make-note p d)
40    (make-music 'EventChord
41                'elements (list (make-note-req p d))))
42
43 #(define (make-triplet elt)
44    (make-music 'TimeScaledMusic
45                'denominator 3
46                'numerator 2
47                'element elt))
48
49 rhythm =
50 #(define-music-function (parser location note) (ly:music?)
51    "Make the rhythm in Mars (the Planets) at the given note's pitch"
52    (let ((p (ly:music-property
53              (car (ly:music-property note 'elements))
54              'pitch)))
55      (make-sequential-music
56       (list
57        (make-triplet (make-sequential-music
58                       (list
59                        (make-note p (ly:make-duration 3 0 2 3))
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 2 0))
63        (make-note p (ly:make-duration 2 0))
64        (make-note p (ly:make-duration 3 0))
65        (make-note p (ly:make-duration 3 0))
66        (make-note p (ly:make-duration 2 0))))))
67
68 \new Staff {
69   \time 5/4
70   \rhythm c'
71   \rhythm c''
72   \rhythm g
73 }