lilypond-user
[Top][All Lists]
Advanced

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

Re: Refer to a staff relatively, not by name


From: Thomas Morley
Subject: Re: Refer to a staff relatively, not by name
Date: Tue, 2 Apr 2013 01:20:00 +0200

2013/4/1 Urs Liska <address@hidden>
>
> OK, thanks for the information.
>
> And does anybody know how/if one can retrieve information about the existing 
> (staff) context? Some property accible by Scheme?


Hi Urs,

below a possibility, though, not sure if it is really helpful.
I'm using Eluze's example and
http://lists.gnu.org/archive/html/lilypond-user/2010-01/msg00668.html
Thanks Reinhold.

\verson "2.17.15"

%%%% Helper functions, which simply print out the observed Music
%%%% in a nice format:
#(define (format-ctx engraver event)
  (let* ((context (ly:translator-context engraver))
         (ctx (ly:context-id context))
         (ctx-name (ly:context-name context))
         ;(mus (ly:event-property event 'music))
         )
    (ly:message "We are in \"~a\" with name \"~a\"\n\n" ctx-name ctx)
  )
)

%%%% The actual engraver definition: We just install a listener.

ctxInfo =
#(list
   (cons 'listeners
    (list
     (cons 'note-event format-ctx))))

\layout {
  \context {
    % I add this to the score, so all voices are caught. You can also only add
    % the engraver to selected voices to get the statistics split down.
    \Staff
    \consists #ctxInfo
  }
}

\new ChoirStaff <<
  \new Staff = "One" \with { instrumentName = "ctx 1" }
    { \clef "treble_8" s1 * 6 }

  \new Staff = "Two" \with { instrumentName = "ctx 2" }
    { \clef treble s1 * 6 }

  \new Staff = "Three" \with { instrumentName = "ctx 3" }
    { \clef alto s1 * 6 }

  \new Staff = "Four" \with { instrumentName = "ctx 4" }
    \relative f {
      \clef bass c4 d e f
      \change Staff = "Three" g' a b c
      \change Staff = "Two" g a b c
      \change Staff = "One" g, a b c
      \change Staff = "Three" g a b c
      \change Staff = "Four" g a b c
    }
>>


HTH,
  Harm



reply via email to

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