lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a thick horizontal line (as its own staff)?


From: Mojca Miklavec
Subject: Re: How to create a thick horizontal line (as its own staff)?
Date: Thu, 21 Jul 2016 03:14:42 +0200

Dear David,

On 20 July 2016 at 22:49, David Nalesnik wrote:
> On Wed, Jul 20, 2016 at 10:05 AM, Mojca Miklavec wrote:
>>
>> One further thought.
>>
>> Given that it's super difficult to "transfer" information "across staves" ...
>>
>> Would it be feasible to allow the following input syntax (or something 
>> similar)?
>>
>>     melody = { c a c \startPush f g a \stopPush h c d }
>>     \new PianoStaff <<
>>         \new Voice = "melody" \fixed c' {
>>           \melody
>>        }
>>        \new Dynamics \with {
>>          \override VerticalAxisGroup.nonstaff-nonstaff-spacing.padding = 1
>>        } {
>>          \melody
>>        }
>>     >>
>>
>
> With the example I gave above, this would work fine.  The horizontal
> line engraver is only consisted to the Dynamics context, so the
> push/pull events will only produce a line there.  Conversely, the
> Dynamics context won't typeset the notes.

Nice.

> You will run into problems with this approach if you add dynamics to
> your melody, however, since they will of course appear in the Dynamics
> context.
>
> The best solution would be to define your own context.  (Instructions
> for doing this are found here:
> http://lilypond.org/doc/v2.19/Documentation/notation/defining-new-contexts)

Thank you. I skimmed over that text, but had no idea what I could use
it for earlier.

> I've gone ahead and defined an "AccordionPushPull" context which
> modifies the definition of a Dynamics context (definition found in
> engraver-init.ly in the source) to include the horizontal line
> engraver and nothing else.  So you can safely include your melody
> variable and not need to worry about extraneous elements being
> typeset.

Wonderful!
This is soooo much more elegant than typing it twice. It seems to work
with all the examples I have so far.

> P.S. I've attached two files, showing how you can cut down on the
> clutter in your input file by using an include.

Thank you. I already added the majority in one file, but wasn't sure
about layout / context part. Being able to remove also that makes me
even more happy :)

> Just to demonstrate how you could make an engraver to create different
> behavior, I wrote one to color note heads red.
>
> Add this definition to accordion.ily:
>
> accordionRedPushEngraver =
> #(lambda (context)
>    (let ((push? #f))
>      (make-engraver
>       (listeners ((accordion-push-span-event engraver event)
>                   (if (= START (ly:event-property event 'span-direction))
>                       (set! push? #t)
>                       (set! push? #f))))
>       (acknowledgers
>        ((note-head-interface engraver grob source-engraver)
>         (if push?
>             (set! (ly:grob-property grob 'color) red)))))))
>
> Then add the engraver in example.ly like this:
>
> \new PianoStaff <<
>   \new Staff <<
>     \new Voice = "melody" \with { \consists \accordionRedPushEngraver } {
>       \melody
>     }

Cool!

That's another very strong reason for wanting to encode the
information just once.
(Not that I would be able to come up with such a definition myself. :)

... Time to head for the next challenge.

Thanks again,
    Mojca



reply via email to

[Prev in Thread] Current Thread [Next in Thread]