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: Bernard
Subject: Re: Lilypond structure / implicit - explicit / with statement
Date: Sun, 03 Apr 2016 21:02:30 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 03-04-16 18:33, Thomas Morley wrote:
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.
For me this, and that there can be no statement after the \with { ..} block for the Staff was possible, I did not know. As I just wrote to Paul Morris.


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

You are right, this does not help me. But I am surprised about you code. It does work but I have no idea how.

Sometimes I am just searching in the wrong directions and then it is good that you or others point this out to me.

Thanks very much.

With regards

Bernard




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]