lilypond-user
[Top][All Lists]
Advanced

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

Re: Parenthesize slashed grace with fingering?


From: Colin Campbell
Subject: Re: Parenthesize slashed grace with fingering?
Date: Wed, 02 Jan 2013 16:38:07 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 13-01-02 03:39 PM, Olivier Biot wrote:
On Wed, Jan 2, 2013 at 10:59 PM, Colin Campbell <address@hidden> wrote:
In transcribing some cello exercises, I need to show a slashed grace note, with a fingering, in parentheses.  The exercise involves shifting between first and third position on the same string, so it emphasizes the intermediate "target" position, with the intent that the grace note gets eliminated as the shift gets smoother.  The following gives me all I need except for the parentheses.  I'm a bit foggy from a virus, and I cannot find the magic incantation which will show both the grace note and the parenthesis. Using 2.17.10, by the way.
%<%<%<%<%<%<%<%<%<

e'2-1 ( \parenthesize \slashedGrace gs8-1 a2-2


%<%<%<%<%<%<%<%<%<

Any pointers to TFM or LSR gratefully received!

Cheers,
Colin

Hi Colin,

I found something in LSR snippet 186 (http://lsr.dsi.unimi.it/LSR/Item?id=186).

Here's a working example:

%%% BEGIN snippet:
\version "2.16.1"
\include "english.ly"

% LSR http://lsr.dsi.unimi.it/LSR/Snippet?id=186
#(define (parenthesize-callback callback)
   (define (parenthesize-stencil grob)
     (let* ((fn (ly:grob-default-font grob))
            (pclose (ly:font-get-glyph fn "accidentals.rightparen"))
            (popen (ly:font-get-glyph fn "accidentals.leftparen"))
            (subject (callback grob))
            ;; get position of stem
            (stem-pos (ly:grob-property grob 'stem-attachment))
            ;; remember old size
            (subject-dim-x (ly:stencil-extent subject X))
            (subject-dim-y (ly:stencil-extent subject Y)))

       ;; add parens
       (set! subject
             (ly:stencil-combine-at-edge
              (ly:stencil-combine-at-edge subject X RIGHT pclose 0)
              X LEFT popen 0))

       ;; adjust stem position
       (set! (ly:grob-property grob 'stem-attachment)
             (cons (- (car stem-pos) 0.43) (cdr stem-pos)))

       ;; adjust size
       (ly:make-stencil
        (ly:stencil-expr subject)
        (interval-widen subject-dim-x 0.5)
        subject-dim-y)))

   parenthesize-stencil)

\relative c'' {
  e2-1 ( \once \override NoteHead #'stencil = #(parenthesize-callback ly:note-head::print) \slashedGrace gs8-1  a-2 )
}
%%% END snippet

Hope this helps.

Best regards,

Olivier

That works fine, Olivier, and many thanks for the quick reply!  To save typing, I wrapped the first part of it in a variable:
pg = { \once \override NoteHead #'stencil = #(parenthesize-callback ly:note-head::print) } and the result is
e2-1 ( \pg \slashedGrace gs8-1 a-2)
which reproduces the original except for leaving the accidentals outside the parentheses, but I can live with that and my cello teacher may never see it.

Une bonne et heureuse année à tous!
Colin

-- 
I've learned that you shouldn't go through life with a catcher's mitt on both hands. 
You need to be able to throw something back. 
-Maya Angelou, poet (1928- )

reply via email to

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