lilypond-user
[Top][All Lists]
Advanced

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

Re: Is there a way to prevent tied notes from triggering multiple note n


From: Matthew Probst
Subject: Re: Is there a way to prevent tied notes from triggering multiple note names with \context NoteNames?
Date: Fri, 9 Apr 2021 10:43:59 -0500

That's above and beyond what I was asking for, and gives me a way to enhance my understanding of the issues. If it requires coding beyond what you just showed me, I think I could carry on from here myself given what you provided.

Thanks Jean!

On Fri, Apr 9, 2021 at 10:39 AM Jean Abou Samra <jean@abou-samra.fr> wrote:

Le 09/04/2021 à 17:15, Matthew Probst a écrit :
> I've been using Lilypond to create lead sheets for a band that I'm in,
> and it works great for that.  Between that and a website I use for
> generating simple chord charts, we're covered for our notation purposes.
>
> I have some less skilled note readers in the band--they can read
> rhythm notation, and get a general idea of melody shape from the notes
> on the staff, but things go easier if they can see the note names for
> each note under the staff.  That's easy with LilyPond:
>
> LeadStaffWithNoteNames = \new Staff \with {
> instrumentName = #"Lead (notes)"
> }
> {
>     <<
>         \relative c'' {
>             \HomeKey
>             \clef treble
>             \LeadIntroFull
>             \LeadHeadFull
>    }
>    \context NoteNames {
>             \set printOctaveNames = ##f
>             \LeadIntroFull
>             \LeadHeadFull
>    }
>     >>
> }
>
> This works great, except for one cosmetic issue:  For tied notes, the
> note name is repeated for the second, third, etc. tied note.  While my
> weaker note-readers can comprehend this given that they can grasp the
> rhythmic notation, it's a bit of a hassle.
>
> Is there any good way to automate printing of note names underneath
> the staff while avoiding repetitions of the note name during ties?  I
> did a search of the snippets repository and the documentation for
> Lilypond 2.22.0, which I'm using.  I'm guessing that it might require
> custom Scheme instead of just configuration parameters, but I might be
> wrong.  I know Scheme the language and Lilypond the markup language,
> but not Lilypond the Scheme API.  I'm willing to do lifting on the
> code myself but would welcome pointers on how might be best to
> accomplish it. so I can best direct my learning.


Hello,

You want a custom Scheme engraver. Just a
few days ago I announced a document with
details about those:

https://lists.gnu.org/archive/html/lilypond-user/2021-04/msg00051.html

More precisely, engravers are explained here:

https://extending-lilypond.readthedocs.io/en/latest/translation.html#writing-an-engraver

Moreover, you need to draw a relation between
the Voice and NoteNames contexts. One way
to do so is to define a custom context type,
as documented at

https://lilypond.org/doc/v2.22/Documentation/notation/defining-new-contexts

All in all, this gives:

\version "2.22.0"

#(define (No_note_name_on_tied_note_engraver context)
    (let ((note-name #f)
          (ending-tie #f))
      (make-engraver
        (acknowledgers
          ((note-name-interface engraver grob source-engraver)
             (set! note-name grob)))
        (end-acknowledgers
          ((tie-interface engraver grob source-engraver)
             (set! ending-tie grob)))
        ((stop-translation-timestep engraver)
           (if ending-tie
               (ly:grob-suicide! note-name))
           (set! note-name #f)
           (set! ending-tie #f)))))

\layout {
   \context {
     \Score
     \accepts NoteNameContainer
   }
   \context {
     \name NoteNameContainer
     \type Engraver_group
     \accepts Staff
     \accepts NoteNames
     \consists #No_note_name_on_tied_note_engraver
   }
   \context {
     \NoteNames
     printOctaveNames = ##f
   }
}

notes = { c'1~ c' }

moreNotes = {
   \set tieWaitForNote = ##t
   d8~ d~ d~ d d4..~ e16 d1
}

<<
   \new NoteNameContainer <<
     \new Voice \notes
     \new NoteNames \notes
   >>
   \new NoteNameContainer <<
     \new Voice \moreNotes
     \new NoteNames \moreNotes
   >>
 >>

Best regards,
Jean


reply via email to

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