Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(35)

Side by Side Diff: ly/chord-repetition-init.ly

Issue 5595043: Reimplement ChordRepetition facility. (Closed)
Patch Set: Incorporate DOC improvements from James with amendments. Created 13 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lily/parser.yy ('k') | ly/music-functions-init.ly » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 %%% -*- Mode: Scheme -*- 1 %%% -*- Mode: Scheme -*-
2 \version "2.14.0" 2 \version "2.15.28"
3 %{ 3 %{
4 Chord repetition behavior is not customizable in the parser. That
5 is due to it usually being done by the toplevel music handler
6 affecting every bit of music at the same time, not closely related
7 to music input. Customized behavior is instead accomplished by
8 calling \chordRepeats explicitly on some music list with a list of
9 event types you wish to keep by default (if any events of that kind
10 are found already on the repeat chord, however, they still get
11 removed from the original).
4 12
5 The following functions define the chord repetition behavior, and may 13 The default behavior is straightforward: don't keep anything but the
6 be invoked by the user to customize it. 14 rhythmic events themselves.
7
8 ly:parser-set-repetition-symbol
9 set the chord repetition shortcut.
10 `q' is the default value set in this file.
11
12 ly:parser-set-repetition-function
13
14 set the function that is invoked when a chord repetition symbol
15 is encountered by the parser: a four argument function
16 (previous-chord, location, duration, list of articulations) which is
17 supposed to return a new chord.
18 `default-repeat-chord' is the default function set in this file.
19 `tab-repeat-chord' may be used in tablatures to preserve the string informatio n.
20 %} 15 %}
21 16
22 #(define-public ((make-repeat-chord-function chord-element-types note-articulati on-types) 17 chordRepeats =
23 previous-chord location duration articulations) 18 #(define-music-function (parser location event-types music)
24 "Make a chord repetition function. 19 ((list? '()) ly:music?)
25 The returned functions copies the notes from @var{previous-chord} into a new cho rd. 20 "Walk through @var{music} putting the notes of the previous chord
26 Chord elements, which type is found in @var{chord-element-types}, are copied int o 21 into repeat chords, as well as an optional list of @var{event-types}
27 the new chord. Note articulations, which type is found in @var{note-articulation -types}, 22 such as @code{#'(string-number-event)}."
28 are also copied. All other events are not copied into the new chord." 23 (expand-repeat-chords! (cons 'rhythmic-event event-types) music))
29 (define (filter-events events event-types)
30 (filter (lambda (event)
31 » (and (memq (ly:music-property event 'name) event-types) event))
32 » events))
33 ;; If previous-chord has an length property, then it means that it
34 ;; has been processed by a music iterator. In other words, the chord
35 ;; has been memorized from an other music block, which is certainly not
36 ;; what the user has intended, as anywy the result will be buggy.
37 ;; In that case, raise a warning.
38 (if (not (and (ly:music? previous-chord)
39 » » (null? (ly:music-property previous-chord 'length))))
40 (ly:input-message location
41 » » » (_ "No memorized chord in music block before chord repe tition")))
42 ;; Instead of copying the previous chord, then removing the
43 ;; undesired elements (like articulations), a new empty chord is built.
44 ;; Then, the pitch found in the previous chord are added to the new
45 ;; chord, without any "decoration" (e.g. cautionary accidentals,
46 ;; fingerings, text scripts, articulations). Only the events of types
47 ;; given in `chord-elements-types' and `note-articulation-types' are
48 ;; copied from the original chord elements and note articulations,
49 ;; respectively.
50 (let ((elements (ly:music-property (ly:music-deep-copy previous-chord) 'eleme nts)))
51 (make-music
52 'EventChord
53 'origin location
54 'elements (append!
55 (map (lambda (note)
56 (let ((new-note (make-music 'NoteEvent
57 'origin location
58 'pitch (ly:music-property no te 'pitch)
59 'duration duration))
60 (articulations
61 (filter-events (ly:music-property note 'articulat ions)
62 note-articulation-types)))
63 (if (not (null? articulations))
64 (set! (ly:music-property new-note 'articulations)
65 articulations))
66 new-note))
67 (filter-events elements '(NoteEvent)))
68 (filter-events elements chord-element-types)
69 articulations))))
70 24
71 #(define-public default-repeat-chord 25 tabChordRepeats =
72 (make-repeat-chord-function '() '())) 26 #(define-music-function (parser location event-types music)
27 ((list? '()) ly:music?)
28 "Walk through @var{music} putting the notes, fingerings and string
29 numbers of the previous chord into repeat chords, as well as an
30 optional list of @var{event-types} such as @code{#'(articulation-event)}."
31 #{ \chordRepeats
32 #(append '(string-number-event fingering-event) event-types)
33 #music
34 #})
73 35
74 #(define-public tab-repeat-chord 36 tabChordRepetition =
75 (make-repeat-chord-function '(StringNumberEvent) '(StringNumberEvent))) 37 #(define-void-function (parser location) ()
76 38 (_i "Include the string and fingering information in a chord repetition.
77 % default settings 39 This function is deprecated; try using @code{\tabChordRepeats} instead.")
78 #(ly:parser-set-repetition-symbol parser 'q) 40 (ly:parser-define! parser '$chord-repeat-events
79 #(ly:parser-set-repetition-function parser default-repeat-chord) 41 » » '(string-number-event fingering-event)))
OLDNEW
« no previous file with comments | « lily/parser.yy ('k') | ly/music-functions-init.ly » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b