lilypond-devel
[Top][All Lists]
Advanced

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

Help understanding how code works (or doesn't)


From: Carl Sorensen
Subject: Help understanding how code works (or doesn't)
Date: Tue, 14 Sep 2010 20:40:21 -0600

I'm trying to fix Issue 372, which has

\partial 4
\grace f16
d4 |
\repeat unfold 8 c8


fail to autobeam the 8th notes.

In running through the debugger, the problem is caused because a grace part
shows up in the measure position, so the autobeam never kicks in.

I think that the reason for this is because the \partial command sets only
the main part of the measure position.  And in this case, because of the
grace note, I think the grace part should be set as well.

So in order to try this, I decided to modify the code for \partial, which
IIUC appears in scm/ly-syntax-constructors.scm:

(define-ly-syntax-simple (partial dur)
  "Make a partial measure."
  (let ((mom (ly:moment-sub ZERO-MOMENT (ly:duration-length dur))))

    ;; We use `descend-to-context' here instead of `context-spec-music' to
    ;; ensure \partial still works if the Timing_translator is moved
    (descend-to-context
     (context-spec-music (make-property-set 'measurePosition mom) 'Timing)
     'Score)))


In order to get the grace part of the current moment, I think I need to use
make-apply-context.  So I wrote some code:

(define-ly-syntax-simple (partial dur)
  "Make a partial measure."
  (let ((mom (ly:moment-sub ZERO-MOMENT (ly:duration-length dur))))

    ;; We use `descend-to-context' here instead of `context-spec-music' to
    ;; ensure \partial still works if the Timing_translator is moved
    (descend-to-context
     (context-spec-music
       (make-apply-context
         (lambda (c) (let ((now (ly:context-current-moment c)))
                       (display "\nIn partial\n")
                       (display now)(newline)
                       (display mom)(newline)
                      (make-property-set 'measurePosition mom))))
         'Timing)  
     'Score)))


When I used this code, the autobeaming worked, but the bar check in the
above code failed. 

sorensen2:lilypond Carl$ lilypond test-372.ly
GNU LilyPond 2.13.34
Processing `test-372.ly'
Parsing...
Interpreting music...
In partial
#<Mom 0G-1/16>
#<Mom -1/4>

test-372.ly:7:5: warning: barcheck failed at: 1/4
  d4 
     |
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `test-372.ps'...
Converting to `./test-372.pdf'...
success: Compilation successfully completed

Note that at this point, I haven't changed the value to which I am setting
'measurePosition.  So, can anybody help me see why this code doesn't work?

Thanks,

Carl




reply via email to

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