lilypond-user
[Top][All Lists]
Advanced

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

Re: Define nr of measures per system


From: Urs Liska
Subject: Re: Define nr of measures per system
Date: Wed, 7 Mar 2018 13:02:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0



Am 06.03.2018 um 18:47 schrieb Kieren MacMillan:
Hi Omri,

Another beginner question, but can't seem to find the answer in the 
documentation:
is it possible to define a constant number of measures per staff system?
There is no dead-simple, built-in way… but there are many ways of accomplishing 
what you want, each with pros and cons depending on exactly what functionality 
and flexibility you want.

For a constant number of measures per system, my favourite is David K's 
\bar-keeper, which I’ve shown in the snippet below.

(Aside: I’m not sure why this isn’t in the main base code… Given that David K 
coded it, I imagine it’s the most elegant solution possible to the problem he 
was tasked to solve. And it is a function that many, many users would 
appreciate having access to.)


Another approach that works well (and could easily be enhanced if there is interest) would involve openLilyLib packages, namely the page-layout package. Internally this uses the edition-engraver to "inject" breaks at specific positions which are targeting "measures", regardles of time signatures.

The current interface would be (skipping the installation and set-up here):

%%%
\include "oll-core/package.ily"
\loadPackage \with {
  modules = conditional-breaks
}
page-layout
\registerBreakSet my-breaks
\setBreaks my-breaks line-breaks 5.8.13.17.21.25
\applyconditionalBreaks my-breaks
%%%

This would apply line breaks at the measures given in the dot-separated list.

What I think would be a useful enhancement would be a function that adds a regular list of breaks, possibly limited to a section, for example with

\setBreaks my-breaks line-breaks 5.12.17.23.51
\addRegularBreaks my-breaks line-breaks 26 4 6

which would insert "6" breaks after "4" measures each, starting with "26", i.e. 26.30.34.38.42.46 Other interfaces could be thought of, in particular ways that apply the regular measures globally (i.e. not starting at a specific point) or "from here throughout the end".

Is this something I should add to the page-layout package?

Urs

Hope this helps!
Kieren.

%%%  SNIPPET BEGINS
\version "2.19"

#(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)))))))))))))))


\score {
   \new Score \with \bar-keeper 4 {
     \repeat unfold 100 { c''4 }
   }
}
%%%  SNIPPET ENDS
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: address@hidden


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

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