lilypond-user
[Top][All Lists]
Advanced

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

Re: Tweaking notehead direction in chords


From: Paul Morris
Subject: Re: Tweaking notehead direction in chords
Date: Tue, 11 Dec 2012 16:00:33 -0500

Hi Arle,  

Below is a revised version that lets you just enter 1 and -1 to indicate your 
offsets. It then multiplies that by 1.251178 to get the precise offset amount.  
You could enter a slightly larger amount (like 1.1) for whole notes and adjust 
to taste.  This basically lets you work in units of "one standard note head 
width".

It also uses ly:grob-translate-axis! rather than setting the X-offset property 
of the NoteHead grob.  This accomplishes the same thing and avoids potential 
problems where setting the X-offset for NoteHead grobs in chords may not work 
in certain cases.  Thanks to Harm/Thomas Morley for this tip.[1]

Cheers,
-Paul

[1] http://lists.gnu.org/archive/html/bug-lilypond/2012-12/msg00017.html



%% BEGIN SNIPPET

#(define ((shift offsets) grob)
 (let ((note-heads (ly:grob-array->list (ly:grob-object grob 'note-heads))))
   (for-each
     (lambda (p q) (ly:grob-translate-axis! p (* q 1.251178) X))
     note-heads offsets)))

displaceHeads =
#(define-music-function (parser location offsets) (list?)
 #{
   \once \override NoteColumn #'before-line-breaking = #(shift offsets)
 #}
)

theMusic = {
 \displaceHeads #'(0 0 1)
 <c' e' g' >4

 \displaceHeads #'(0 1 1)
 <d' f' a'>

 \displaceHeads #'(0 1 1)
 <d' f' a'>

 \displaceHeads #'(0 0 1)
 < c' e' g'>

 \displaceHeads #'(-1 -1 0)
 < c'' e'' g''>

 \displaceHeads #'(-1 -1 0)
 < c''' e''' g'''>

 \displaceHeads #'(0 0 1)
 < c e g>

 \displaceHeads #'(0 -1 0)
 < c'' e'' g''>

 \displaceHeads #'(0 0 -1)
 < c'' e'' g''>
}

\new Staff {
 \theMusic
}



On Dec 11, 2012, at 3:15 PM, Arle Lommel <address@hidden> wrote:

> Brilliant, Paul. It isn't as easy as I'd hoped, but this works and is really 
> minimally difficult for me to use. I used 1.25 and -1.25 as values and it is 
> certainly close enough that I can't complain. This helps a *lot*.
> 
> Best regards,
> 
> Arle
> 
> On 2012 Dec 11, at 21:05 , Paul Morris wrote:
> 
>> Hi Arle,
>> 
>> On Dec 11, 2012, at 2:37 PM, Arle Lommel <address@hidden> wrote:
>> 
>>> I've been looking for how to tweak the direction of noteheads within 
>>> chords. I've got a few instances where Lilypond’s default isn't as clear as 
>>> when I flip the direction of some of the noteheads. I've searched the 
>>> repository and tried various tweaks using direction, but nothing seems to 
>>> matter. I'm sure it's easy, but I can't find it.
>>> 
>>> As a minimal example, consider this chord:
>>> 
>>> <e fis ais cis>4
>>> 
>>> The default is to have the e face left and the other heads face right, but 
>>> in the piece I am reproducing the e faces right and the fis faces left. 
>>> Doing it this way, as per the old engraver, increases the white space 
>>> between the noteheads and increases legibility.
>>> 
>>> Any guidance on how to achieve this? If there is an easy way, I would 
>>> suggest adding it to the LSR as well, since this is a basic sort of tweak 
>>> that others must surely need, but which doesn't seem to be easy to find.
>> 
>> I had trouble figuring this out earlier this year and David Nalesnik helped 
>> me out with the code below.[1]  I have had it on my list to add it to the 
>> LSR (while giving proper credit to David N.), as it is something that is not 
>> easy to figure out on your own.  
>> 
>> (I think the fully accurate horizontal offsets should be 1.251178 and 
>> -1.251178 rather than 1.3 or -1.3 for regular sized noteheads.  They would 
>> be a little larger for whole note note heads, but I don't know those values 
>> at the moment.)
>> 
>> Let me know if you have questions about how it works.
>> 
>> HTH,
>> -Paul
>> 
>> 
>> #(define ((shift offsets) grob)
>> (let ((note-heads (ly:grob-array->list (ly:grob-object grob 'note-heads))))
>>   (for-each
>>     (lambda (p q) (set! (ly:grob-property p 'X-offset) q))
>>     note-heads offsets)))
>> 
>> displaceHeads =
>> #(define-music-function (parser location offsets) (list?)
>> #{
>>   \once \override NoteColumn #'before-line-breaking = #(shift offsets)
>> #}
>> )
>> 
>> theMusic = {
>> \displaceHeads #'(0 0 1.3)
>> <c' e' g' >4
>> 
>> \displaceHeads #'(0 1.3 1.3)
>> <d' f' a'>
>> 
>> \displaceHeads #'(0 1.3 1.3)
>> <d' f' a'>
>> 
>> \displaceHeads #'(0 0 1.3)
>> < c' e' g'>
>> 
>> \displaceHeads #'(-1.3 -1.3 0)
>> < c'' e'' g''>
>> 
>> \displaceHeads #'(-1.3 -1.3 0)
>> < c''' e''' g'''>
>> 
>> \displaceHeads #'(0 0 1.3)
>> < c e g>
>> 
>> \displaceHeads #'(0 -1.3 0)
>> < c'' e'' g''>
>> 
>> \displaceHeads #'(0 0 -1.3)
>> < c'' e'' g''>
>> }
>> 
>> \new Staff {
>> \theMusic
>> }
>> 
>> [1] http://lists.gnu.org/archive/html/lilypond-user/2012-12/msg00186.html
> 




reply via email to

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