bug-lilypond
[Top][All Lists]
Advanced

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

Re: Stem.stem-begin-position not giving desired output on beamed stems (


From: Carl Williams
Subject: Re: Stem.stem-begin-position not giving desired output on beamed stems (tablature)
Date: Sun, 18 Dec 2016 18:08:28 +1300
User-agent: Mailbird/2.3.36.0

To anyone who's interested, 

I've tidied up the workaround for this. It now takes two inputs; stem-start and 
stem-length. 
It also now allows for above or below staff positioning. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.18.2"

beam-stem-height =
#(define-music-function (parser location start-in length-in)(number? number?)
  "Takes a list containing values for:
  - the stem-start in Y-direction
  - the stem-length
  Values can be positive or negative, depending on direction
  but may produce a warning if only one value is negative:
    'warning: weird stem size, check for narrow beams'
  "
  #{
    \override Stem.direction = #(if (positive? length-in) UP DOWN)
    \override Stem.stem-begin-position = #start-in
    \override Stem.length = #(abs length-in)
    \override Beam.after-line-breaking =
    #(lambda (grob)
      (let
        ( (stems (ly:grob-array->list (ly:grob-object grob 'stems)))
          (position (if (positive? length-in)
              (/ (+ start-in (- (abs length-in)
                (ly:grob-property grob 'beam-thickness))) 2)
              (/ (- start-in (- (abs length-in)
                (ly:grob-property grob 'beam-thickness))) 2)
            )
          )
        )
        (ly:grob-set-property! grob 'positions (cons position position))
        (for-each
          (lambda (stem)
            (ly:stem::calc-stem-begin-position stem)
            (ly:grob-set-property! stem 'length (abs length-in))
            (ly:grob-set-property! stem 'stem-begin-position start-in)
          )
        stems
        )
      )
    )
#})

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{
  \beam-stem-height #5 #7
  c''8[ d'']
  c''16[ d'']
  c''32[ d'']
  \autoBeamOff
  c''8 d''16 e''32
  \beam-stem-height #-7 #-10
  c''8[ d'']
  c''16[ d'']
  c''32[ d'']
  \autoBeamOff
  c''8 d''16 e''32
}

\new TabStaff \with {
  stringTunings = #ukulele-tuning
  \tabFullNotation
  \beam-stem-height #-5 #-5
} {
  \relative c' {
    r8 g'\4 c,4 e2 |
    a1 |
    g8\4 c, e a c,[ c] a'8 a |
    \beam-stem-height #5 #5
    r8 g\4 c,4 e2
    a1
    g8\4 c, e a c,[ c] a'8 a
  }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cheers, 
Carl

On 16/12/2016 22:09:09, Carl Williams <address@hidden> wrote:
Thanks Harm, 

That's just what I was after. 
I'm keen to learn more about how beam positions and stems are calculated. Then 
maybe I can calculate it using only 2 input variables. 
I think I'll have a look in the .scm files, and see what I can find. I'm not 
sure yet which one it'll be in.

Thanks for adding the feature request too. 

Cheers, 
Carl
On 16/12/2016 12:39:08, Thomas Morley <address@hidden> wrote:
Hi Carl,

2016-12-14 8:14 GMT+01:00 Carl Williams :
> Hi Everyone,
>
> First time using a mailing list.
> I've raked through the documentation pages all today and yesterday (and 
> learnt a lot), but still couldn't solve this.
>
> So I want to create (ukulele) tablature where all the stems and beams are 
> above the staff.
> I use the \override Stem.stem-begin-position to set the unbeamed stems above, 
> but I think it aught to affect the beamed stems too (they are stems too after 
> all!). bug?

I don't think so.
If I understand correctly, beamed stems are not really calculated on
their own, but mostly rely on the calculations of the beam.
Thus you need to make some effort to have it work.

> Does anyone know any workarounds?

Maybe something at the lines of:

\version "2.18.2"

testFunc =
#(define-music-function (parser location beg-end-beam-pos)(list?)
"Takes a list containing values for
- the stem-start in Y-direction
- the stem-length
- the positions of a possible beam.
TODO: The relationship between those values currently escapes me.
It should be possible to calculate the beam-positions, if the other values
are known.
"
#{
\stemUp
\override Beam.after-line-breaking =
#(lambda (grob)
(let ((stems (ly:grob-array->list (ly:grob-object grob 'stems))))
(ly:grob-set-property!
grob 'positions (cons (last beg-end-beam-pos) (last beg-end-beam-pos)))
(for-each
(lambda (stem)
(ly:stem::calc-stem-begin-position stem)
(ly:grob-set-property!
stem 'length (second beg-end-beam-pos))
(ly:grob-set-property!
stem 'stem-begin-position (first beg-end-beam-pos)))
stems)))
\override Stem.stem-begin-position = #(first beg-end-beam-pos)
\override Stem.length = #(second beg-end-beam-pos)
#})

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{
\testFunc #'(5 6 5.25)
c''8[ d'']
c''16[ d'']
c''32[ d'']
\autoBeamOff
c''8 d''16 e''32
}


\new TabStaff \with {
stringTunings = #ukulele-tuning
} {

\relative c' {
\testFunc #'(4.6 5 4.75)
\tabFullNotation
r8 g'\4 c,4 e2 |
a1 |
g8\4 c, e a c,[ c] a'8 a |
}
}

2016-12-15 1:24 GMT+01:00 Carl Williams :
> I think the original issue of Stem.stem-begin-position not working for 
> beamed-stems should be fixed. If it's not a bug, I call it a feature request.
>

Probably.
Added as
https://sourceforge.net/p/testlilyissues/issues/5012/

Cheers,
Harm

Attachment: test3.pdf
Description: Adobe PDF document

Attachment: test3.ly
Description: Text Data


reply via email to

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