lilypond-user
[Top][All Lists]
Advanced

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

Re: changing grob properties?


From: Marc Hohl
Subject: Re: changing grob properties?
Date: Sat, 16 May 2009 10:37:56 +0200
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

Neil Puttock schrieb:
2009/5/15 Marc Hohl <address@hidden>:

Upto now, I have achieved to make tablature fret numbers invisible which are
tied to another note.
But I don't know how to add parentheses to the numbers that are tied but
show up after a line break
(for example the first note in measure 5, see attachment).

I tried something like

(set! (ly:music-property note 'elements)
               (cons (make-music 'NoteEvent 'parenthesize #t)
                     (ly:music-property note 'elements)))

but I realized that a grob is not a music expression as the variable called
"note" in the code fragment above.

Indeed, once the grob's been created it's too late to be setting music
properties.

Then I came up with the vague idea to combine the TabNoteHead-Stencil with
the
stencil for the parentheses, but this was beyond my knowledge, it didn't
work.

It won't work, since the stencil callback for parentheses has some
rather specific requirements which are set in the
Parenthesis_engraver.

You could use markup to place the parentheses around the TabNoteHead,
but unless I'm mistaken, that's not possible inside a callback for
'after-line-breaking, since it's called after stencils have been
generated.
So can I use it as a callback for 'stencil? (see below)
\version "2.12.2"

#(define (tie::handle-tab-tie grob)
 (let* ((original (ly:grob-original grob))
        (tied-tabnotehead (ly:spanner-bound original RIGHT))

Should be (ly:spanner-bound grob RIGHT).

The unbroken grob is only used to obtain the list of broken spanners,
if there are any (remember that this callback will be called for every
tie, including those which aren't split).

        (siblings (if (ly:grob? original)
                    (ly:spanner-broken-into original) '() )))

   (if (and (>= (length siblings) 2)
           (eq? (car (last-pair siblings)) grob))
      ;; tie is split
      ;; just a dummy function here, parentheses should be inserted
      (begin (ly:grob-set-property! tied-tabnotehead 'transparent #f)

It would be easier to see whether this is actually working on the
correct grob if you changed the override to 'color.
Ok, I inserted

(ly:grob-set-property! tied-tabnotehead 'color (rgb-color 1 0 0))

and the first tab number (the one in measure 5) is now red, all other numbers
of tied notes disappear, as it should be.
             (newline)
             (display "Tie is split.")
             (newline))
      ;; tie is not split -> make fret number invisible
      (ly:grob-set-property! tied-tabnotehead 'transparent #t)
      );; end if
      ))

test = \relative c {
      f2 ~ f4 \parenthesize e
      g8 g ~ g g ~ g g~ g g ~
      g1
      c1 ~ \break c2 ~ c
      < c\3 e\2 g\1 >4 < c\3 e\2 g\1 > ~ < c\3 e\2 g\1 > < c\3 e\2 g\1 >
      \bar "|."
      }

\score {
  << \new Staff { \clef "G_8" \test }
     \new TabStaff { \clef "tab"
                     \override Tie  #'stencil = #tie::handle-tab-tie

Should be \override Tie #'after-line-breaking = #tie::handle-tab-tie

There's no stencil returned by the function, which is why you're
getting loads of programming errors and invisible ties.
Hm, I didn't get any errors, and invisible ties are exactly the feature I need.
At first, I used

\override Tie #'after-line-breaking = #tie::handle-tab-tie

but I didn't quite understand the term "after-line-breaking", since 
tie::handle-tab-tie is
called on _every_ tie. So I changed the call to
\override Tie  #'stencil = #tie::handle-tab-tie

and found out that it works, too, and has the advantage not to write
\override Tie  #'stencil = ##f

explicitly. But if this is a crude style, I won't apply it. On the other hand, 
when
this offers a possibility to change the TabNoteHead stencil on the fly, it 
could be used.

Can I switch to another tablature format, according to

\set tablatureFormat = #parenthesized-tab-format / which is not defined yet?

but this has the drawback that notes inside a chord would be parenthesized 
individually,
but - as David Stocker mentioned - chords should be included in _one_ pair of 
parentheses,
as this is the standard for this kind of notation.

Is the a possibility to handle these situations with a different approach? For
the "normal" case (i.e. tied notes within the same staff line) everything works
properly with tie::handle-tab-tie, so if there is a possibility to filter all 
notes
that are tied _and_ placed immediately after a line break and put parenthesizes
around them, it would be fine.

Marc



Regards,
Neil






reply via email to

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