lilypond-user
[Top][All Lists]
Advanced

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

Re: Lilypond structure / implicit - explicit / with statement


From: Thomas Morley
Subject: Re: Lilypond structure / implicit - explicit / with statement
Date: Sun, 3 Apr 2016 18:33:34 +0200

2016-04-03 16:59 GMT+02:00 Bernard <address@hidden>:

> All boils down to what is the \with statement.

Well,
http://www.lilypond.org/doc/v2.19/Documentation/learning-big-page#modifying-context-properties
seems pretty clear to me. There you can read:
" When a context is created with a \new command it may be followed
_immediately_ by a \with { … } block in which the default property
values are set."

Please tell whats wrong with it.


> If I could view, within an implicit context , like :
> {c'}
> the full explicit context like :
> \score {
> \new Staff {
> \new Voice {c'}
> }
> }


Well, I don't get what problem you seem to have. The following may of
some help, though:

\version "2.19.36"

#(define (single-context-parent-tree ctx)
  (if (and (ly:context? ctx) (ly:context? (ly:context-parent ctx)))
      (single-context-parent-tree (ly:context-parent ctx))
      (format #f "~a" ctx)))

printBottomContextParents =
\context Bottom
\applyContext
  #(lambda (a)
    (let ((ls (drop-right
                (string-split
                  (single-context-parent-tree a)
                  (car (string->list "(")))
                1)))
    (format #t "\n\nThe Context-parent-tree:")
    (format #t
      "\n(Only contexts of type Global, Score, Staff and Voice are printed)")
    (for-each
      (lambda (s)
        (format #t "\n~a~a"
          (cond ((string-contains s "Score")
                 (make-string 1 #\tab))
                ((string-contains s "Staff")
                 (make-string 2 #\tab))
                ((string-contains s "Voice")
                 (make-string 3 #\tab))
                (else ""))
          (string-trim-both s (lambda (c)
                                (or (eqv? c #\>)
                                    (eqv? c #\sp)
                                    (eqv? c #\)))))))
      ls)))

m = { c''4  }

  \new Score = "my-score"
    <<
      \new Staff = "staff-1"
        \new Voice = "voice-1"
        <<
          \new Voice = "voice-1a" { \voiceOne \m }
          \new Voice = "voice-1b" { \voiceTwo \m }
        >>
      \new Staff = "staff-2"
        \new Voice = "voice-2"
        <<
          \new Voice = "voice-2a" { \voiceOne \printBottomContextParents \m }
          \new Voice = "voice-2b" { \voiceTwo \m }
        >>
    >>

{ \printBottomContextParents \m }


You'll get in terminal:

The Context-parent-tree:
(Only contexts of type Global, Score, Staff and Voice are printed)
#<Global_context Global
    #<Context Score=my-score
        #<Context Staff=staff-1
            #<Context Voice=voice-1
            #<Context Voice=voice-1a
            #<Context Voice=voice-1b
        #<Context Staff=staff-2
            #<Context Voice=voice-2
            #<Context Voice=voice-2a
            #<Context Voice=voice-2b


The Context-parent-tree:
(Only contexts of type Global, Score, Staff and Voice are printed)
#<Global_context Global
    #<Context Score=\new
        #<Context Staff=\new
            #<Context Voice


Don't care about the Global-context, it's not really user accessable.


Cheers,
  Harm



reply via email to

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