From 8abb84c2bf30e32702ecd274df7bfa114f0d851f Mon Sep 17 00:00:00 2001 From: Valentin Villenave
Date: Thu, 31 Oct 2013 21:15:06 +0100 Subject: [PATCH] Make Dynamics into a Staff-like context. This commit creates a DynamicsVoice context, and moves the former Dynamics context to a higher (Staff-like) level. This should allow to assign variables that contain polyphonic sections without unintended side effects (such as additional Voice and Staff contexts being created whenever a VoiceSeparator \\ is entered). --- input/regression/dynamics-polyphony.ly | 42 ++++++++++++++++++++++++++++++++++ ly/engraver-init.ly | 27 +++++++++++++++------- 2 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 input/regression/dynamics-polyphony.ly diff --git a/input/regression/dynamics-polyphony.ly b/input/regression/dynamics-polyphony.ly new file mode 100644 index 0000000..898913e --- /dev/null +++ b/input/regression/dynamics-polyphony.ly @@ -0,0 +1,42 @@ +\version "2.17.30" + +\header { + texidoc = "The Dynamics context can handle multiple voices, +even though it may lead to collisions." +} + +music = \relative c' { + f2\mp c' | + << % Creating two temporary DynamicsVoice contexts. + { bes8\> c d bes a2\p } + \\ + { g\sfz f } % collides with the spanner. + >> +} + +% The actual staves will be printed without dynamics. +#(define (dynamic? x) + (let ((name (ly:music-property x 'name))) + (or + (eq? name 'DynamicEvent) + (eq? name 'AbsoluteDynamicEvent) + (eq? name 'CrescendoEvent) + (eq? name 'DecrescendoEvent) + (eq? name 'SpanDynamicEvent)))) + +removeDynamics = +#(define-music-function (parser location music) (ly:music?) + (music-filter + (lambda (x) + (not (dynamic? x))) + music)) + +\score { + \new PianoStaff << + \new Staff \removeDynamics \music + \new Dynamics \music + \new Staff \removeDynamics { + \clef bass \transpose c c, \music + } + >> +} diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 9c8547d..27381b3 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -16,7 +16,7 @@ %%%% You should have received a copy of the GNU General Public License %%%% along with LilyPond. If not, see