[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Do not display chord name after line break
From: |
Carl Sorensen |
Subject: |
Re: Do not display chord name after line break |
Date: |
Tue, 14 Jul 2020 00:18:26 +0000 |
User-agent: |
Microsoft-MacOutlook/10.10.16.200509 |
Harm, you are amazing!
Maybe too good -- you lower the pressure to fix LilyPond!
Thanks for all you do!
Carl
On 7/13/20, 6:16 PM, "Thomas Morley" <thomasmorley65@gmail.com> wrote:
Am Mo., 13. Juli 2020 um 19:40 Uhr schrieb Carl Sorensen
<carl.d.sorensen@gmail.com>:
>
> Hi Ernie,
>
> On Mon, Jul 13, 2020 at 7:03 AM Ernie Braganza <ernie.braganza@gmail.com>
> wrote:
>>
>> Hello,
>>
>> How can I stop the repeated chord name after the line break?
>> I thought the break-visibility settings for ChordName would work, for
>> example setting the beginning-of-line-invisible value to false:
>> \override Score.ChordName.break-visibility = ##(#t #t #f)
>> but that does not have any effect at all.
>
>
> The reason this does not have any effect is that the code executed when
> chordChanges is set to ##t changes the break-visiblity of the specific chord
> name (sets it to beginning-of-line-visible). And that code is in C++, not
> Scheme, so I don't know how to override it.
>
> I guess one could write a Scheme engraver for ChordName to replace the
> built-in one.
>
> You should also raise an issue on the issues list asking for an enhancement.
> The enhancement would need to add some additional property (or change the
> existing property from a simple boolean), because we'd need to separately
> control hiding of repeated chord names only when not at the beginning of the
> line, and always hiding repeated chord names.
>
> I actually think the best way to do it would be to change the chordChanges
> property from a boolean to a break-visibility. I can see that being quite
> easy to do.
>
> In the meantime, as a workaround, you might just wish to fill up your
> chordmode with a bunch of s chords, and only put the chords in where you want
> them displayed:
>
> \version "2.20.0"
> harmonies = \chordmode {
> d2 c
> \break
> % I don't want the repeated c chord name to display after the line break
> s d
> }
> \new ChordNames {
> \harmonies
> }
>
> HTH,
>
> Carl
>
Here an engraver which transforms the default stencil to an empty
stencil under certain conditions (it's not a rewrite of
Chord_name_engraver)
\new ChordNames
\with {
chordChanges = ##t
\consists
#(lambda (ctx)
(let* ((chord #f)
(last-chord #f))
(define (at-line-beginning? grob)
(let* ((col (ly:item-get-column grob))
(ln (ly:grob-object col 'left-neighbor))
(col-to-check (if (ly:grob? ln) ln col)))
(and (eq? #t (ly:grob-property col-to-check 'non-musical))
(= 1 (ly:item-break-dir col-to-check)))))
(make-engraver
(acknowledgers
((chord-name-interface this-engraver grob source-engraver)
(if chord
(begin
(set! last-chord chord)
(set! chord #f)))
(set! chord (ly:grob-property grob 'text))
;; If two subsequent chords are equal and chordChanges is enabled,
;; set 'after-line-breaking to a procedure which sets the stencil
;; to an empty-stencil if the new chord is at line-start.
(if (and (equal? chord last-chord)
(ly:context-property ctx 'chordChanges #f))
(ly:grob-set-property! grob 'after-line-breaking
(lambda (grob)
(if (at-line-beginning? grob)
(ly:grob-set-property! grob 'stencil empty-stencil))
;; keep default
(ly:chord-name::after-line-breaking grob))))))
((finalize this-engraver)
;; house keeping
(set! chord #f)
(set! last-chord #f)))))
}
\chordmode { d2 c~ \break c d }
HTH,
Harm