Neil Puttock schrieb:
2009/5/10 Marc Hohl <m...@hohlart.de>:

And here's my solution for tablature:

#(define (glissando::calc-tab-extra-dy grob)
 (let* ((original (ly:grob-original grob))
        (left-bound (ly:spanner-bound original LEFT))
        (right-bound (ly:spanner-bound original RIGHT))
        (left-pitch (ly:event-property (event-cause left-bound) 'pitch))
        (right-pitch (ly:event-property (event-cause right-bound) 'pitch))
        (left-staff-position (ly:grob-property left-bound 'staff-position))
        (right-staff-position (ly:grob-property right-bound
'staff-position))
        (extra-dy
           (if (and (= left-staff-position right-staff-position)
                    (ly:pitch<? right-pitch left-pitch))

Be careful here: ly:pitch<? compares pitches lexicographically, so
you'll come unstuck if the pitches differ only in alteration:

#(let ((c-natural (ly:make-pitch 0 0 0))
       (c-sharp (ly:make-pitch 0 0 SHARP)))
   (display (ly:pitch<? c-natural c-sharp))
   (newline)
   (display (ly:pitch<? c-sharp c-natural)))

Ok, I misinterpreted the "lexicographically", so I changed my definition to

#(define (glissando::calc-tab-extra-dy grob)
  (let* ((original (ly:grob-original grob))
         (left-bound (ly:spanner-bound original LEFT))
         (right-bound (ly:spanner-bound original RIGHT))
         (left-pitch (ly:event-property (event-cause left-bound) 'pitch))
         (right-pitch (ly:event-property (event-cause right-bound) 'pitch))
(left-staff-position (ly:grob-property left-bound 'staff-position)) (right-staff-position (ly:grob-property right-bound 'staff-position)))

    (if (and (= left-staff-position right-staff-position)
(< (ly:pitch-semitones right-pitch) (ly:pitch-semitones left-pitch)))
                -1
                 1 )))

to be called as you proposed:

\override Glissando #'extra-dy = #glissando::calc-tab-extra-dy


               -1
                1 ))) ;; I don't know why, but "0" doesn't work properly in
tablature, compare glissando::calc-extra-dy

Unless you can return the correct value or 0 (in the same way as
glissando::calc-extra-dy), you'll probably need to use cond and else:

Here I'm stuck, 'cause when I override the value for extra-dy manually, as in

dytest = \relative c {
  \set TabStaff.minimumFret = #2
  \override Glissando #'extra-dy = #0
  c4 \glissando cis \glissando c2
}

\score {
   \new TabStaff { \clef "tab" \dytest } }
the glissando line doesn't look as expected, it is parallel to the staff lines and therefore
invisible. So, strange as it seems, the value "1" must be right here.

Just for the record: I think it would be reasonable to move the glissando::calc-tab-extra-dy call to tablature.ly, so all files are backwards compatible and tablature users can profit from
the nicer glissando lines :-)

Marc
(cond
((right pitch is lower) -1)
(right pitch is higher) 1)
(else 0))

Regards,
Neil




_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to