[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Moving accidentals above or below notes
From: |
Paul Morris |
Subject: |
Re: Moving accidentals above or below notes |
Date: |
Mon, 17 Dec 2012 15:53:26 -0500 |
On Dec 17, 2012, at 2:58 PM, Dominique Faure <address@hidden> wrote:
> Using the following code, I'd like to move accidentals above or below notes.
>
> ----------8<- - - - - - - - - -
> \version "2.16"
>
> accidentalBelow = {
> \once \override Score.Accidental #'extra-offset = #'(1.5 . -2.5)
> }
>
> accidentalAbove = {
> \once \override Score.Accidental #'extra-offset = #'(1.5 . 2.5)
> }
>
> \relative c'' {
> a16 b \accidentalAbove cis \accidentalAbove bes
> g a \accidentalBelow b \accidentalBelow c
> }
>
> \relative c'' {
> a b c b
> g a b c
> }
> ----------8<- - - - - - - - - -
>
> This almost works, but I was wondering how I could:
>
> 1) eliminate the extra horizontal space kept in front of notes where
> the accidental was originally drawn.
I think the following will work, use:
\override Score.Accidental #'before-line-breaking =
which performs the override before the spacing is calculated. You would set it
to your own scheme function that changes the position of the accidental grob.
In your function you could use the internal scheme function
ly:grob-translate-axis! (once for the X axis and once for Y axis) to do the
repositioning.
> 2) have it working without the need to know in advance how the stems
> are oriented.
In your scheme function you should be able to access the stem grob from the
accidental (via the note head grob) and check the stem direction property of
the stem grob. This will probably involve ly:grob-parent or something like it.
Then you can adjust the accidental above or below based on the stem direction
property.
These snippets may be helpful:
http://lsr.dsi.unimi.it/LSR/Item?id=621
http://lsr.dsi.unimi.it/LSR/Item?id=622
Searching for "grob" may find other relevant examples:
http://lsr.dsi.unimi.it/LSR/Search?q=grob
I don't have the time at the moment to offer more, but that should get you
started.
HTH,
-Paul