Re: [frogs] Re: New frog in an empty pond?

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


Hi, Janek!

Quoting Janek Warchol <janek.lilypond@xxxxxxxxx>:

Hi Pavel,

unfortunately this list is quite dead right now (time for a change?).

It's the second reply, I got, so maybe the list is not as dead as I feared.

It's great to see you working on LilyPond!

Cross-staff stems would indeed be a valuable addition.  I would begin by
reading code that creates brackets and cross-system barlines (and perhaps
grid lines).

I actually wanted to make a stopgap solution in Scheme. I wrote some code that looks for other stems and sets the stem length so it would touch the stem above (attached). But the code is unreliable. Some stems are not calculated yet. So I need a different approach to do my calculations at a later time. That's where an advice of an experienced developer could save a lot of time.

I'm going to see the C++ code, that's for sure. It may help me to understand some missing details. But the main missing detail at this point is using the appropriate interface in Scheme.

I don't think I can write C++ code for cross-staff stems at this point. The may reason is that I won't be able to meet the quality standards of the Lilypond core code.

It would be good indeed if you have a mentor; unfortunately, i don't think
you'll find one here, on frogs.  It's hard to find a mentor in general...
I'm not much Lily-knowledgeable, so i don't think i would be a good mentor
for you, but if you have any problems with git, our development cycle or
other general issues, feel free to ask me privately.

Mike has agreed to be my mentor.

--
Regards,
Pavel Roskin

\version "2.14.2"

#(define (grobParentByInterface grob intf axis)
   (if (memq intf (ly:grob-interfaces grob))
       grob
       (grobParentByInterface (ly:grob-parent grob axis) intf axis)))

#(define ((connectableStem? xref yref stemone dir below?) stemtwo)
   (cond
    ((not (memq 'stem-interface (ly:grob-interfaces stemtwo))) #f)
    ((equal? stemone stemtwo) #f)
    ((inf? (car (ly:grob-extent stemtwo xref X))) #f)
    ((not (equal? (ly:grob-extent stemone xref X) (ly:grob-extent stemtwo xref X))) #f)
    ((not (equal? dir (ly:grob-property stemtwo 'direction))) #f)
    ((below? (car (ly:grob-extent stemtwo yref Y)) (car (ly:grob-extent stemone yref Y))) #f)
    (else #t)))

#(define ((lowerStem? ref below?) lower upper)
   (below? (car (ly:grob-extent lower ref Y)) (car (ly:grob-extent upper ref Y))))

#(define (crossStaffLength grob)
   (let* ((papercolumn (grobParentByInterface grob 'paper-column-interface X))
          (elementarray (ly:grob-object papercolumn 'elements))
          (xref (ly:grob-common-refpoint-of-array grob elementarray X))
          (yref (ly:grob-common-refpoint-of-array grob elementarray Y))
          (elements (ly:grob-array->list elementarray))
          (dir (ly:grob-property grob 'direction))
          (below? (if (> dir 0) < >))
          (goodstems (filter (connectableStem? xref yref grob dir below?) elements))
          (beststems (sort goodstems (lowerStem? yref below?)))
          (peer (car (append beststems (list grob)))))
     (if (equal? grob peer)
         (begin (ly:programming-error "No suitable stem to connect to") 4)
         (if (> dir 0)
             (* 2 (- (car (ly:grob-extent peer yref Y))
                     (car (ly:grob-extent grob yref Y))))
             (* 2 (- (cdr (ly:grob-extent grob yref Y))
                     (cdr (ly:grob-extent peer yref Y))))))))

\score {
  \new StaffGroup <<
    \new Staff = "staffone" <<
      \new Voice {
        \voiceOne c''
      }
      \new Voice {
        \override Stem #'cross-staff = ##t
        \override Stem #'length = #crossStaffLength
        \voiceTwo c'
      }
      \new Voice {
        \voiceThree g' c'
      }
    >>
    \new Staff = "stafftwo" <<
      \new Voice {
        \clef bass \voiceOne g
      }
      \new Voice {
        \clef bass \voiceTwo e,
      }
      \new Voice {
        \clef bass \voiceThree d
        \override Stem #'cross-staff = ##t
        \override Stem #'length = #crossStaffLength
        f
      }
    >>
    \new Staff = "staffthree" <<
      \new Voice {
        \clef bass \voiceOne f
      }
      \new Voice {
        \clef bass \voiceTwo g,
      }
      \new Voice {
        \override Stem #'cross-staff = ##t
        \override Stem #'length = #crossStaffLength
        \clef bass \voiceThree c c
      }
    >>
  >>
  \layout { }
}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/