lilypond-devel
[Top][All Lists]
Advanced

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

Re: Setting up classical guitar fingerings


From: Valentin Petzel
Subject: Re: Setting up classical guitar fingerings
Date: Mon, 21 Feb 2022 12:27:36 +0100

Hello Luca,

A scheme engraver follows the concept of a closure, so it is some sort of 
function that returns different values on different arguments. This is somewhat 
the functional approach to OOP. So an engraver can be seen as an object that 
has some methods, which (as some sort of callback) need to be passed a 
reference to the actual engraver. So for example an acknowledger is  a 
function that takes as argument the engraver itself, the acknowledged grob and 
the original engraver producing the grob.

About after-line-breaking: Spacing is a kind of problematic thing. Spacing 
might rely on line breaking, but line breaking might rely on spacing. Thus 
Lilypond first creates some sort of spacing approximation, it then calculates 
the line breaking, and then finalizes the spacing.

Our problem is that something like Beaming and thus stem length (on which we 
want depend our spacing) are only really fixed after line breaking.

For such things each grob as two callbacks before-line-breaking and after-
line-breaking that are called on the grob before calculating the line breaking 
and after calculating the line breaking. Using this we can tweak the grobs 
after the line breaking is calculated to do what we want.

In this case I’m using a custom engraver to store Stems and Note Heads inside 
the properties of the Fingering grob (so that we can access them) and then in 
after-line-breaking we take the length of the stem, we check if there is 
Beaming on the left side, if there is we get the lowest beam position and use 
it to estimate the height of the Beam (this does still get messed up by very 
slanted Beams, it might be useful to also get a reference to the Beam grob to 
factor in the angle of the Beam). With this we can estimate the free space 
between NoteHead and Beam, and depending on this space, shift the Fingering 
grob.

Cheers,
Valentin

Am Montag, 21. Februar 2022, 08:58:36 CET schrieb Luca Fascione:
> Hi Valentin, thank you this is super interesting. There's a lot of
> information in there I want to read more carefully,
> but for the moment I have one question: when is after-line-breaking invoke?
> Or actually, better question: where do I go to discover when (and I guess
> by what) after-line-breaking is invoked?
> 
> Another thing at the moment I don't follow is the 'engraver' variable in
> the scheme engraver you wrote:
> where does that come from? (I suspect it's some kind of name available
> where the engraver is invoked, but again: how would I go at discovering
> this?)
> 
> Many thanks, this is very helpful
> Luca
> 
> On Sun, Feb 20, 2022 at 11:07 PM Valentin Petzel <valentin@petzel.at> wrote:
> > Hello,
> > 
> > our problem here is that such things like the positioning of beams are not
> > known for quite some time. But we could use something like
> > after-line-breaking
> > to adjust the results. Somewhat like here.
> > 
> > Valentin
> > 
> > Am Sonntag, 20. Februar 2022, 21:17:31 CET schrieb Luca Fascione:
> > > So... would anybody be able to lend a hand here please?
> > > 
> > > Many thanks
> > > Luca
> > > 
> > > On Sat, Feb 12, 2022 at 7:49 PM Luca Fascione <l.fascione@gmail.com>
> > 
> > wrote:
> > > > Hello,
> > > > sorry for the double-post, I'm unsure whether this should go to -user
> > 
> > or
> > 
> > > > -devel.
> > > > 
> > > > I'm looking for some guidance to set up fingering on classical guitar
> > > > sheets.
> > > > 
> > > > I am attaching a simple piece of music, with two engraving sets
> > 
> > (measures
> > 
> > > > 1-5 and 6-10), one "as-is" from lilypond, the other using some
> > > > trickery
> > > > involving one-note chords, purely to show a sample of what the result
> > 
> > I'm
> > 
> > > > after (and it's an approximation), vs what I get at the moment.
> > > > 
> > > > Measures 1-5 in the source look like what I am intending to type, but
> > 
> > it
> > 
> > > > has a number of engraving defects I don't understand (you can see the
> > > > beams
> > > > don't  avoid the fingerings, nor they are located correctly wrt the
> > > > accidentals, the second beat of measure 5 illustrates this well. I'm
> > 
> > not
> > 
> > > > super in love with measure 10 either, but if I understand the docs
> > > > correctly, the issue there is that the 'offset' correction is applied
> > > > post-layout, and so naturally it won't back-affect the placement of
> > > > the
> > > > beams.
> > > > 
> > > > I have made several other experiments, I'm just not wanting to waste
> > > > people's time. But setting Fingering.side-axis = #X seems somewhat
> > > > promising, but it seems unable to find any usable Y data about the
> > > > parents,
> > > > and smashes all numbers on the B line, as well as not dealing with
> > > > accidentals.
> > > > 
> > > > I have an engraving project in front of me, for which I'm more than
> > 
> > happy
> > 
> > > > to put in the time to contribute the code to a proper solution myself,
> > 
> > and
> > 
> > > > I really don't want to make poor use of time from folks busy with
> > > > other
> > > > work, but I feel I'll need some level of guidance as to what to do.
> > > > For
> > > > context I can do C++ and I can manage guile ok (I'm a software
> > > > engineer
> > > > for
> > > > work, I'm mostly working in the field of computer graphics).
> > > > 
> > > > I was looking into this problem several years ago also, and Han-Wen
> > > > Nienhuys at the time suggested I should use a positioning callback
> > > > attached
> > > > to the Fingering grobs, but I couldn't find a way to do such a thing
> > 
> > (in
> > 
> > > > particular I can't find what property to use for this). So far I've
> > 
> > traced
> > 
> > > > the Fingering system to be an instance of the Articulations/Scripts
> > > > system,
> > > > but that's as far as I got.
> > > > 
> > > > It seems to me what's needed would be to decide where the heads go,
> > 
> > then
> > 
> > > > the accidentals, at this stage deal with the fingering and only then
> > 
> > there
> > 
> > > > would be enough bboxes to reason about the beaming (this is the
> > > > skyline
> > > > concept I think). In reasoning about how Articulations are engraved,
> > 
> > it's
> > 
> > > > possible the order of events for fingering would be different from the
> > > > order of events in other articulations (which I think are laid out
> > 
> > after
> > 
> > > > beams are in place, if I am not mistaken), warranting a bigger change,
> > 
> > but
> > 
> > > > I have no idea where that is located/managed.
> > > > 
> > > > Many thanks for your time,
> > > > Luca

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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