Hi,

On Thu, Apr 3, 2014 at 6:08 AM, Simon Bailey <si...@bailey.at> wrote:

> Hi Urs,
>
>
> On Thu, Apr 3, 2014 at 11:54 AM, Urs Liska <u...@openlilylib.org> wrote:
>
>> is it possible to enforce a specific number of systems on a specific page?
>> For example to say: "I want a given music (e.g. between two manual page
>> breaks) on that page, but I also want to have it on 5 systems"?
>>
>> Or similarly asked: "Please distribute the following 50 measures on 16
>> staves."
>>
>> It that's currently not possible (which I assume) is there a reason
>> against it, or a reason why it is complicated to implement?
>>
>
> I had a similar question a month or so back. And was given this answer:
>
> http://lists.gnu.org/archive/html/lilypond-user/2014-01/msg01207.html
>
> I tried it out yesterday, using the following approach:
>
> - removed all manual breaks
> - compiled the piece "normally" without using this engraver.
> - judging from the generated output, started counting bars and layouting
> number of systems on each page (once the engraver runs out of instructions,
> it carries on with the default layout)
>
> i my case, this was done as the last step in layouting -- i was lucky, i
> didn't have to fine-tune any of my previous tweaks as i hardly changed the
> line breaks. it's probably not the best way to do things, but it works for
> me. ideally you would get all the music entered, then finalise the page
> layout, then fine-tune the output.
>
> hope this helps,
> sb
>
>
I actually wrote another engraver which handles measures per line/systems
per page.  It looks like development found its way into a private thread,
so I'm enclosing the result here.

Hopefully the example in the file should give an idea of its usage, but let
me know if you need more information.

There may be a problem with manually setting the bar number, so I'll have
to work through this some.

Anyway, hopefully this gets you started!

--David
\version "2.17.8"

#(define (expand-repetitions arg)
;; 4*5 --> 4 4 4 4 4
;; (at any level of nesting)
  (fold-right
    (lambda (elem prev)
            (cond ((pair? elem)
                   (cons (expand-repetitions elem) prev))
                  ((symbol? elem)
                   (let* ((str (symbol->string elem))
                          (split (string-split str #\*))
                          (split (map (lambda (elem) (string->number elem)) split)))
                     (append (make-list (cadr split) (car split))
                             prev)))
                  (else (cons elem prev))))
    '()
    arg))

#(define ((bars-per-line-systems-per-page-engraver lst) ctx)
  (let* ((bars-and-systems? (any pair? lst))
         (working-copy (expand-repetitions lst))
         (systems-per-page
           (if bars-and-systems?
               (car working-copy)
               #f))
         (last-measure-seen (ly:context-property ctx 'currentBarNumber))
         (last-measure-seen (if (null? last-measure-seen)
                                0
                                (1- last-measure-seen)))
         (total
           (if systems-per-page
               (+ (car systems-per-page) last-measure-seen 1)
               (+ (car working-copy) last-measure-seen 1))))
  `((stop-translation-timestep
      . ,(lambda (trans)
          (let ((internal-bar (ly:context-property ctx 'internalBarNumber))
                (current-col (ly:context-property ctx 'currentCommandColumn)))
            ;; we are only interested in the first NonMusicalPaperColumn of
            ;; each measure
            (if (and (> internal-bar last-measure-seen)
                     (= (remainder internal-bar total) 0)
                     (pair? working-copy))
                (begin
                  (set! (ly:grob-property current-col 'line-break-permission) 'force)
                  (set! last-measure-seen internal-bar)
                  (if bars-and-systems?
                      (begin
                        (if (null? (cdr systems-per-page))
                            (begin
                              (set! (ly:grob-property current-col 'page-break-permission) 'force)
                              (if (pair? (cdr working-copy))
                                  (begin
                                    (set! working-copy (cdr working-copy))
                                    (set! systems-per-page (car working-copy)))
                                  (set! working-copy '())))
                            (set! systems-per-page (cdr systems-per-page)))
                        (set! total (+ total (car systems-per-page))))
                      (begin
                        (if (null? (cdr working-copy))
                            (set! working-copy lst)
                            (begin
                              (set! working-copy (cdr working-copy))))
                              (set! total (+ total (car working-copy)))))))))))))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\relative c' {
  \repeat unfold 50 {
    \acciaccatura b8 c4 c c c
  }
}

\layout {
  ragged-right = ##t
  \context {
    \Staff
    %% The following override specifies measures per line only
    %\consists #(bars-per-line-systems-per-page-engraver '(5 7*5 1 3*3))

    %% The following line specifies measures per line and systems per page
    \consists #(bars-per-line-systems-per-page-engraver '((4*3) (4 2) (4*3) (5*4)))
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to