Thank you! > Wouldn't you be better off getting rid of graces, and creating a grob like > TrillPitchHead from your engraver?
Probably, but I’m also trying to make this engraver something a person can just add to a LilyPond file without having to change anything else. I think most of the time people will input these kinds of bends as grace notes, so no matter what I’ll have to detect those. > you can get the moment of the current time step in the engravers using > > (ly:context-current-moment context) Thanks, this is a huge help. Thank you also for putting together the Extending LilyPond <https://extending-lilypond.readthedocs.io/> website; that website is the only reason I got as far as I did writing an engraver. > On Jan 7, 2023, at 1:04 PM, Jean Abou Samra <[email protected]> wrote: > > Le 07/01/2023 à 18:41, Nate Whetsell a écrit : >> Hi, >> >> I have a question about using a custom engraver to modify how grace notes >> appear when LilyPond’s new string bending is applied to them. This is the >> first custom engraver I’ve attempted to write, so I think I’ve overlooked >> something rather basic. The repository for the engraver is at >> https://github.com/nwhetsell/lilypond-bending-additions, and the current >> engraver is at >> >> https://github.com/nwhetsell/lilypond-bending-additions/blob/0bbfdaa9a76bef10c4b23cc97b1edede8fde2f2a/bending-additions.ily >> >> Conceptually, I’m trying to do three things: >> >> 1. If a string bend starts on a grace note, don’t reduce the size of the >> fret number in a TabStaff. >> >> 2. If, in addition, the bent grace note is a pre-bend, put the notehead in >> parentheses, and don’t draw ledger lines, flags, or stems. >> >> 3. If a string bend ends on a grace note, don’t draw the notehead, ledger >> lines, accidentals, flags, or stems (don’t draw anything, basically). > > > I'm ignorant about guitar techniques, but is this note really a grace note? > Wouldn't you be better off getting rid of graces, and creating a grob like > TrillPitchHead from your engraver? > > Assuming that grace notes are what you want in the first place ... > >> Bearing in mind that there’s a lot about writing engravers that I don’t know, > > > Maybe it will help to read > https://extending-lilypond.readthedocs.io/en/latest/translation.html#writing-an-engraver > > <https://extending-lilypond.readthedocs.io/en/latest/translation.html#writing-an-engraver> > > >> where I think I’m having difficulty is determining whether a note is a grace >> note. In short, I’m getting a notehead grob using an acknowledger and then >> checking the value of its ly:moment-grace >> <https://lilypond.org/doc/v2.24/Documentation/internals/scheme-functions#index-ly_003amoment_002dgrace >> >> <https://lilypond.org/doc/v2.24/Documentation/internals/scheme-functions#index-ly_003amoment_002dgrace>> >> in the engraver’s stop-translation-timestep method. However, this doesn’t >> work directly. In stop-translation-timestep, the moment of a notehead >> created in that timestep appears to always be null. > > > Yes, it's not set up yet. Basically, grob::when is meant to be used in the > backend (grob callbacks). During translation (in engravers), there is no > need. By definition, all note heads that arrive in the same time step are > grace notes iff that time step is a grace time step, and you can get the > moment of the current time step in the engravers using > > (ly:context-current-moment context) > > HTH
