Separating key cancellations from key signature changes: Difference between revisions
Import snippet from LSR |
mNo edit summary |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
By default, the accidentals used for key cancellations are placed adjacent to those for key signature changes. This behavior can be changed by overriding the <code>break-align-orders</code> property of the <code>BreakAlignment</code> grob. | By default, the accidentals used for key cancellations are placed adjacent to those for key signature changes. This behavior can be changed by overriding the <code>break-align-orders</code> property of the <code>BreakAlignment</code> grob. | ||
The value of <code>break-align-orders</code> is a vector of | The value of <code>break-align-orders</code> is a vector of length 3, with quoted lists of breakable items as elements. Each list describes the default order of prefatory matter at the end, in the middle, and at the beginning of a line, respectively. We are only interested in changing the behaviour in the middle of a line. | ||
If you look up the definition of <code>break-align-orders</code> in LilyPond's Internal Reference (see the [https://lilypond.org/doc/v2. | If you look up the definition of <code>break-align-orders</code> in LilyPond's Internal Reference (see the [https://lilypond.org/doc/v2.24/Documentation/internals/breakalignment <code>BreakAlignment</code>] grob), you get the following order in the second element: | ||
<pre>... | <pre>... | ||
| Line 10: | Line 10: | ||
key-signature | key-signature | ||
...</pre> | ...</pre> | ||
<lilypond version="2.24 | We want to change that, moving <code>key-cancellation</code> before <code>staff-bar</code>. To make this happen we use the <code>grob-transformer</code> function, which gives us access to the original vector as the second argument of the lambda function, here called <var>orig</var> (we don't need the first argument, <var>grob</var>). We return a new vector, with unchanged first and last elements. For the middle element, we first remove <code>key-cancellation</code> from the list, then adding it again before <code>staff-bar</code>. | ||
<lilypond version="2.24"> | |||
%LSR based on | %LSR based on | ||
%LSR https://stackoverflow.com/questions/40964806/scheme-inserting-a-number-in-a-list | %LSR https://stackoverflow.com/questions/40964806/scheme-inserting-a-number-in-a-list | ||
| Line 53: | Line 54: | ||
\cancellationFirst | \cancellationFirst | ||
\music } | \music } | ||
</lilypond> | </lilypond> | ||
[[Category:Pitches]] | [[Category:Pitches]] | ||
[[Category: | [[Category:Scheme]] | ||
[[Category:Tweaks and overrides]] | [[Category:Tweaks and overrides]] | ||
[[Category:Included in the official documentation]] | [[Category:Included in the official documentation]] | ||
[[Category:Snippet]] | |||