Hi Kieren,

>> I'm playing with the bars-per-line-engraver as of LSR
>> http://lsr.di.unimi.it/LSR/Item?id=838
>>
>> When I increase the number of bars in my piece beyond a certain amount
>> (3500-4000 in my MWE) lilypond crashes with an access violation under linux.
> 
> Does that also happen with David Kastrup’s "bar-keeper" engraver?
> <https://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00239.html>

Thank you for that suggestion. I had saved the code back then but forgot
about it. Unfortunately it crashes likewise for me. See attached MWE.

Kind regards,
Michael
-- 
 Michael Gerdau       email: m...@qata.de
 GPG-keys available on request or at public keyserver
%\version "2.20.0"
\version "2.19.83"

#(define (index-list? x)
   (and (list? x)
        (every index? x)))

#(define (index-pattern numbers)
   "Convert an `index pattern' into a circular list.  Zeros are removed,
with the last zero preceding the part of the list that should become
circular.  If that list part is empty, the resulting list has no circular
end.  Without any zero, the whole list is turned into a circular one."
   (define (creverse! x y)
     "Reverse both x and y, make y circular and append to x."
     (if (pair? y)
         (let* ((rev-y (reverse! y))
                (rev-x (reverse! x rev-y)))
           (set-cdr! y rev-y)
           rev-x)
         (reverse! x y)))
   (let loop ((non-reps '()) (reps '()) (rest numbers))
     (cond ((null? rest) (creverse! non-reps reps))
           ((zero? (car rest))
            (loop (append! reps non-reps) '() (cdr rest)))
           ((index? (car rest))
            (loop non-reps (cons (car rest) reps) (cdr rest)))
           (else (ly:input-warning (*location*)
                                   (_ "Not an index: ~a") (car rest))
                 (loop non-reps reps (cdr rest))))))


bar-keeper =
#(define-scheme-function (numbers) (index-list?)
   "Create a context mod for consisting a Timing-level engraver
breaking after bar group lengths specified in the list.  If the list
is exhausted, it starts over from the start or from after a 0 marker
contained in the list.  If the list @emph{ends} address@hidden, line
breaking reverts to normal after using up the list."
   (ly:make-context-mod
    `((consists
       ,(lambda (c)
          (let ((target #f) (numbers (index-pattern numbers)))
            (make-engraver
             (acknowledgers
              ((paper-column-interface eng grob from)
               (and (pair? numbers)
                    (ly:grob-property grob 'non-musical #f)
                    (let ((bar (ly:context-property (ly:translator-context eng)
                                                    'internalBarNumber)))
                      (if (not target)
                          (set! target bar)
                          (set! (ly:grob-property grob 'line-break-permission)
                                (and (>= bar (+ target (car numbers)))
                                     (begin
                                       (set! target (+ target (car numbers)))
                                       (set! numbers (cdr numbers))
                                       'force)))))))))))))))

\paper {
  systems-per-page = #5
}
% \repeat unfold 3500 works with 2.19.83 and crashes with 2.20.0
% \repeat unfold 4000 crashed with both 2.19.83 and 2.20.0
music = \absolute { \repeat unfold 4000 { d'8 f' a' g'  d' f' b' d' } }

\score {
  \new Score \with \bar-keeper 2
  \new Staff { \music }
}

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to