Hi Eric,

2008/7/15 Eric Knapp <[EMAIL PROTECTED]>:

> In this line:
>
>    (sp (ly:grob-property grob 'staff-position))
>
> The staff position of the note is assigned to the variable sp. How
> could I get the fingering digit of the note? For example:
>
>  c''-3
>
> I want to programmatically get the "3" as a number or text.

You need to find the interface which is associated with fingerings.

Following the paper trail in the docs from NR
(http://kainhofer.com/~lilypond/Documentation/user/lilypond/Fingering-instructions.html#Fingering-instructions)
to IR 
(http://kainhofer.com/~lilypond/Documentation/user/lilypond-internals/Fingering.html#Fingering),
you'll see a list of interfaces at the bottom of the page. The
important one is finger-interface.

The fingerings are stored in the 'text property as a string, so you
can read the string, convert it to a number then use case to
conditionally set arbitrary markup for each fingering.

Here's a quick example which changes the fingerings to roman numerals:

#(define (finger-text grob grob-origin context)
   (let* ((ifs (ly:grob-interfaces grob))
    (text (ly:grob-property grob 'text)))
     (if (memq 'finger-interface ifs)
   (begin
     (ly:grob-set-property! grob 'stencil ly:text-interface::print)
     (ly:grob-set-property! grob 'text
          (make-tiny-markup (make-text-markup
                 (case (string->number text)
                   ((5) "v")
                   ((4) "iv")
                   ((3) "iii")
                   ((2) "ii")
                   (else "i"))))
          )))))

\relative c' {
  \applyOutput #'Voice #finger-text
  <c-1 e-2 g-3 c-5>2
}

In the markup, you'll notice I've used make-text-markup: since the
default font for fingerings only has a few letters, this changes it
back to the normal text style.

> Also, the \applyOutput command only seems to run once.

I think that's a known limitation of \applyOutput.

As an alternative, you could override the default stencil for
fingerings, which will then work whenever a fingering is encountered:

\relative c' {
  \override  Fingering #'stencil = #(lambda (grob)
    (let* ((text (ly:grob-property grob 'text)))

      ly:text-interface::print (grob-interpret-markup grob
        (make-tiny-markup (make-text-markup
          (case (string->number text)
            ((5) "five")
            ((4) "four")
            ((3) "three")
            ((2) "two")
            (else "thumb"))
          )))))

  <c-1 e-2 g-3 c-5>
  <d-4>
}

Regards,
Neil


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to