Good point, shall we say, to match what is commonly done in this style ;)

No point in calling the same over and over again. How about: 

halve-half-stems = 
\override Stem.before-line-breaking = 
#(lambda (grob) 
(if (= 1 (ly:grob-property grob 'duration-log)) 
(let ((half-orig-lngth (/ (ly:grob-property grob 'length) 2))) 
(if (= DOWN (ly:grob-property grob 'direction)) 
(ly:grob-set-property! grob 'stem-begin-position 
(- (ly:grob-property grob 'stem-begin-position) 
half-orig-lngth))) 
(ly:grob-set-property! grob 'length half-orig-lngth)))) 
I was considering whether to us a variable, it's justified. 
Also, you forgot the (and set-position set-length), so it doesn't work in all 
cases. 

Here it is now with the (and set-position set-length): 
halve-half-stems =
\override Stem.before-line-breaking =
  #(lambda (grob)
    (let ((new-length (/ (ly:grob-property grob 'length) 2)))
      (if (= 1 (ly:grob-property grob 'duration-log))
        (if (= DOWN (ly:grob-property grob 'direction))
          (and (ly:grob-set-property! grob 'stem-begin-position
                 (- (ly:grob-property grob 'stem-begin-position) new-length))
               (ly:grob-set-property! grob 'length new-length))
          (ly:grob-set-property! grob 'length new-length)))))

Thanks, 
Carl
On 19/12/2016 00:34:27, Thomas Morley <[email protected]> wrote:
Hi Carl,

2016-12-18 6:20 GMT+01:00 Carl Williams :
> For those interested,
>
> I made some improvements to the solution for this. It now accounts for
> whether the stems are up or down, so as to match what is commonly done in
> modern tablature.

I really doubt about "commonly" ;)
I've seen so many different styles...

>
> I intend to make a tablature template incorporating this solution here also,
> http://lists.gnu.org/archive/html/bug-lilypond/2016-12/msg00022.html.
>
> %%%%%%%%%%%%%%%%
> \version "2.18.2"
>
> halve-half-stems =
> \override Stem.before-line-breaking =
> #(lambda (grob)
> (if (= 1 (ly:grob-property grob 'duration-log))
> (if (= DOWN (ly:grob-property grob 'direction))
> (and
> (ly:grob-set-property! grob 'stem-begin-position
> (- (ly:grob-property grob 'stem-begin-position)
> (/ (ly:grob-property grob 'length) 2)
> )
> )
> (ly:grob-set-property! grob 'length
> (/ (ly:grob-property grob 'length) 2)
> )
> )
> (ly:grob-set-property! grob 'length
> (/ (ly:grob-property grob 'length) 2)
> )
> )
> )
> )

No point in calling the same over and over again. How about:

halve-half-stems =
\override Stem.before-line-breaking =
#(lambda (grob)
(if (= 1 (ly:grob-property grob 'duration-log))
(let ((half-orig-lngth (/ (ly:grob-property grob 'length) 2)))
(if (= DOWN (ly:grob-property grob 'direction))
(ly:grob-set-property! grob 'stem-begin-position
(- (ly:grob-property grob 'stem-begin-position)
half-orig-lngth)))
(ly:grob-set-property! grob 'length half-orig-lngth))))

>
> %%%%%%%%%%%%%%%%
> %% EXAMPLES
> %%%%%%%%%%%%%%%%
>
> \new TabStaff \with {
> stringTunings = #ukulele-tuning
> \tabFullNotation
> \stemUp
> \halve-half-stems
> }
> \relative c' {
> \partial 2.. a'8 a4 a2 |
> a1 |
> \stemDown
> \partial 2.. g8\4 g4\4 g2\4 |
> g1\4 |
> }
> \new TabStaff \with {
> stringTunings = #ukulele-tuning
> \tabFullNotation
> \revert Stem.stencil
> \revert Stem.X-extent
> \stemUp
> \halve-half-stems
> }
> \relative c' {
> \partial 2.. a'8 a4 a2 |
> a1 |
> \stemDown
> \partial 2.. g8\4 g4\4 g2\4 |
> g1\4 |
> }
> %%%%%%%%%%%%%%%%

Cheers,
Harm
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to