Four Bars per Line/System, again :)

classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Four Bars per Line/System, again :)

Nils Hammerfest
Hello Users,

I am currently looking at Realbook layouts and user expectations.
"Four Bars per Line" in a Leadsheet seems to be a pretty common request.

I know there is the method with a invisible voice that breaks the staffs. But this seems like a hack. Using content to force the layout. And it gets tiresome if you have longer pieces or time signature changes.

So, is there a different method, probably more layout oriented? I saw there is  a way to force the systems per page. So is there a bars per lines layout command? Or isn't there one?

Nils

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Trevor Daniels

Nils you wrote Friday, May 18, 2012 7:45 PM

> I am currently looking at Realbook layouts and user expectations.
> "Four Bars per Line" in a Leadsheet seems to be a pretty common request.
>
> I know there is the method with a invisible voice that breaks the staffs.
> But this seems like a hack. Using content to force the layout. And it gets
> tiresome if you have longer pieces or time signature changes.
>
> So, is there a different method, probably more layout oriented? I saw
> there is  a way to force the systems per page. So is there a bars per
> lines layout command? Or isn't there one?

I usually have a variable called something like timeline in which I place
all things which apply to the score as a whole rather than to individual
staves or voices, things like breaks, key changes, time signature changes,
special bar lines, etc.  The individual items are positioned with spacer
rests, and the variable is included in parallel with at least one of the
music voices.

So for your particular case I would define

timeline = \repeat unfold nnn { s1*4 \break }

where nnn is determined by the length of the piece.

I don't consider this a hack.  It allows the actual notes to be kept
separate and clean.

Trevor


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Kieren MacMillan
Hi Trevor (and Nils),

> I usually have a variable called something like timeline in which I place all things which apply to the score as a whole rather than to individual staves or voices, things like breaks, key changes, time signature changes, special bar lines, etc.  The individual items are positioned with spacer rests, and the variable is included in parallel with at least one of the music voices.

For the record, one can now use tags to eliminate the need for spacer rests — much cleaner and more maintainable.

> So for your particular case I would define
> timeline = \repeat unfold nnn { s1*4 \break }

If you really want to FORCE [exactly] four bars per system, I think you need to use

    \repeat unfold nnn { \repeat unfold 4 { s1 \noBreak } \break }

> I don't consider this a hack.  It allows the actual notes to be kept separate and clean.

+1
Kieren.
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Kieren MacMillan
p.s.

Come to think of it, wouldn't this be a good place for a Scheme engraver [written by someone who, unlike me, knows Scheme well]? To wit, if the measures in a piece aren't all 4/4, then our suggestion(s) won't work; and every time the total number of measures changes you need to update; etc.

Couldn't there just be an engraver that says, “If I'm the k-th barline since the last system break, then break, otherwise noBreak”, that could be \consists-ed into the \Score?

Cheers,
Kieren.

On 2012-May-18, at 16:35, Kieren MacMillan wrote:

> Hi Trevor (and Nils),
>
>> I usually have a variable called something like timeline in which I place all things which apply to the score as a whole rather than to individual staves or voices, things like breaks, key changes, time signature changes, special bar lines, etc.  The individual items are positioned with spacer rests, and the variable is included in parallel with at least one of the music voices.
>
> For the record, one can now use tags to eliminate the need for spacer rests — much cleaner and more maintainable.
>
>> So for your particular case I would define
>> timeline = \repeat unfold nnn { s1*4 \break }
>
> If you really want to FORCE [exactly] four bars per system, I think you need to use
>
>    \repeat unfold nnn { \repeat unfold 4 { s1 \noBreak } \break }
>
>> I don't consider this a hack.  It allows the actual notes to be kept separate and clean.
>
> +1
> Kieren.
> _______________________________________________
> lilypond-user mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik
Hi,

On Fri, May 18, 2012 at 3:40 PM, Kieren MacMillan <[hidden email]> wrote:
p.s.

Come to think of it, wouldn't this be a good place for a Scheme engraver [written by someone who, unlike me, knows Scheme well]? To wit, if the measures in a piece aren't all 4/4, then our suggestion(s) won't work; and every time the total number of measures changes you need to update; etc.

Couldn't there just be an engraver that says, “If I'm the k-th barline since the last system break, then break, otherwise noBreak”, that could be \consists-ed into the \Score?

I can't believe that this works :) !!

\version "2.15.38"

#(define bars-per-line 4)

#(define line-break-every-nth-engraver
  (lambda (context)
     (make-engraver
       (acknowledgers ((paper-column-interface engraver grob source-engraver)
(let ((current-bar (ly:context-property context 'currentBarNumber)))    
  (if (= (remainder current-bar bars-per-line) 1)
      (if (eq? #t (ly:grob-property grob 'non-musical))
  (set! (ly:grob-property grob 'line-break-permission) 'force)
  (set! (ly:grob-property grob 'line-break-permission) '())))))))))
  
\relative c' {
  \repeat unfold 10 {
    \time 2/4
    c4 c
    \time 4/4
    c c c c
    \time 3/4
    c c c
    \time 1/4
    c
    \time 5/4
    c c c c c
    \time 7/4
    c c c c c c c
    \time 2/4
    c c
    \time 7/8
    c8 c c c c c c
    \time 2/2
    c2 c
  }
}

\layout {
  \context {
    \Score
    %% the following line necessary if you want to put more
    %% measures to a line than Lily wants to allow
    \override NonMusicalPaperColumn #'line-break-permission = ##f
    \consists #line-break-every-nth-engraver
  }
}


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Kieren MacMillan
Hi David,

> I can't believe that this works :) !!

1. Let's thank all the people (Han-Wen, Jan, David K., etc.) who have done such great work on the fundamentals, so that this actually works.
2. Let's all (except David N) thank David N for taking my idea and running with it so successfully.

=)

The 'Pond is the Place to Be™.
K.
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik


On Fri, May 18, 2012 at 6:50 PM, Kieren MacMillan <[hidden email]> wrote:
Hi David,

> I can't believe that this works :) !!

1. Let's thank all the people (Han-Wen, Jan, David K., etc.) who have done such great work on the fundamentals, so that this actually works.

Hear, hear!
 
2. Let's all (except David N) thank David N for taking my idea and running with it so successfully.

=)

Thank you for the great idea, Kieren!
 

The 'Pond is the Place to Be™.
K.

+1000

-David


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Jay Anderson
In reply to this post by David Nalesnik
Slightly better would be to get rid of the bars-per-line define so
it's self-contained:

#(define (line-break-every-nth-engraver bars-per-line)
  (lambda (context)
     (make-engraver
       (acknowledgers ((paper-column-interface engraver grob source-engraver)
         (let ((current-bar (ly:context-property context 'currentBarNumber)))
           (if (= (remainder current-bar bars-per-line) 1)
               (if (eq? #t (ly:grob-property grob 'non-musical))
                   (set! (ly:grob-property grob 'line-break-permission) 'force)
                   (set! (ly:grob-property grob 'line-break-permission) '())))))))))

...

\layout {
  \context {
    \Score
    %% the following line necessary if you want to put more
    %% measures to a line than Lily wants to allow
    \override NonMusicalPaperColumn #'line-break-permission = ##f
    \consists #(line-break-every-nth-engraver 4)
  }
}

-----Jay

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik
Hi,

On Fri, May 18, 2012 at 7:38 PM, Jay Anderson <[hidden email]> wrote:
Slightly better would be to get rid of the bars-per-line define so
it's self-contained:

True, thank you--I've incorporated your suggestion below.

Thinking about this some more, I figure the next logical step is to write an engraver which allows you to specify the number of measures for each line of the score.  I've come up with the solution below.

If you use the (commented-out) override and you have measures left over, these will be crammed into the last line.  Without the 'line-break-permission override, Lily will space the remaining measures as usual.

Hope this proves useful! 

Best,
David

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.15.38"

#(define (custom-line-breaks-engraver bar-list)
  (let ((total (1+ (car bar-list)))) ;; not sure why increment necessary
    (lambda (context)
      (make-engraver
        (acknowledgers ((paper-column-interface engraver grob source-engraver)
          (let ((current-bar (ly:context-property context 'currentBarNumber)))
            (if (and (pair? bar-list)
                     (= (remainder current-bar total) 0)
                     (eq? #t (ly:grob-property grob 'non-musical)))
                (begin
                  (set! (ly:grob-property grob 'line-break-permission) 'force)
                  (if (not (null? (cdr bar-list)))
                      (begin
                        (set! bar-list (cdr bar-list))
                        (set! total (+ total (car bar-list))))
                      (set! bar-list '())))))))))))

\relative c' {
  \repeat unfold 10 {
    \time 2/4
    c4 c
    \time 4/4
    c c c c
    \time 3/4
    c c c
    \time 1/4
    c
    \time 13/4
    c c c c c c c c c c c c c
    \time 9/4
    c c c c c c c c c
    \time 2/4
    c c
    \time 7/8
    c8 c c c c c c
    \time 2/2
    c2 c
  }
}

\layout {
  \context {
    \Score
    %% The following line necessary if you want to put more
    %% measures to a line than Lily wants to allow.
    %% Remaining measures will be crammed into last line.
    %\override NonMusicalPaperColumn #'line-break-permission = ##f
    \consists #(custom-line-breaks-engraver '(1 2 3 4 5 1 2 3 4 5))
  }



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Kieren MacMillan
Hi David,

> Thinking about this some more, I figure the next logical step is to write an engraver which allows you to specify the number of measures for each line of the score.  I've come up with the solution below.
> Hope this proves useful!

I have been hoping for something like this in Lilypond for years — literally years.
Thank you so much!

Kieren.
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

fedelogy
In reply to this post by Nils Hammerfest

I usually place a system-count in the layout block inside score block.
If you choose the right number, Lilypond should break lines regularly. Rarely I need to force a line break.

I think this is a much cleaner solution than using a variable with spacing rests.

Il giorno 18/mag/2012 20:45, "Nils" <[hidden email]> ha scritto:
Hello Users,

I am currently looking at Realbook layouts and user expectations.
"Four Bars per Line" in a Leadsheet seems to be a pretty common request.

I know there is the method with a invisible voice that breaks the staffs. But this seems like a hack. Using content to force the layout. And it gets tiresome if you have longer pieces or time signature changes.

So, is there a different method, probably more layout oriented? I saw there is  a way to force the systems per page. So is there a bars per lines layout command? Or isn't there one?

Nils

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Ole Schmidt-2
In reply to this post by David Nalesnik

Am 19.05.2012 um 04:19 schrieb David Nalesnik:

> Hi,
>
> On Fri, May 18, 2012 at 7:38 PM, Jay Anderson <[hidden email]> wrote:
>
>> Slightly better would be to get rid of the bars-per-line define so
>> it's self-contained:
>>
>
> True, thank you--I've incorporated your suggestion below.
>
> Thinking about this some more, I figure the next logical step is to write
> an engraver which allows you to specify the number of measures for each
> line of the score.  I've come up with the solution below.
>
> If you use the (commented-out) override and you have measures left over,
> these will be crammed into the last line.  Without the
> 'line-break-permission override, Lily will space the remaining measures as
> usual.
>
> Hope this proves useful!
>
> Best,
> David
>


Just want to report that the improved version gives the following error:

/Applications/LilyPond.app/Contents/Resources/share/lilypond/current/ly/init.ly:111:66: Fehler: syntax error, unexpected $end
   (ly:parser-error parser (_ "expected error, but none found"))))
                                                                 
The first version works fine...

best,
ole
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Janek Warchoł
David:
8O
I think this is worth including in LilyPond itself!!
Try to beat this, Finale! Hahaha!

On Sat, May 19, 2012 at 9:31 AM, ole <[hidden email]> wrote:
> Just want to report that the improved version gives the following error:
>
> /Applications/LilyPond.app/Contents/Resources/share/lilypond/current/ly/init.ly:111:66: Fehler: syntax error, unexpected $end
>   (ly:parser-error parser (_ "expected error, but none found"))))
>
> The first version works fine...

There's a missing closing brace.  If you add it, it works fine.

cheers,
Janek

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Janek Warchoł
David,

a couple of thoughts:
- what about looping the break pattern?  I.e. \consists
#(custom-line-breaks-engraver '(2 3 4)) = \consists
#(custom-line-breaks-engraver '(2 3 4 2 3 4 2 3 4 ... 2 3 4))?
- i'm not sure if this is desired or not, but changing current
barNumber confuses your function:

\version "2.15.38"

#(define (custom-line-breaks-engraver bar-list)
  (let ((total (1+ (car bar-list)))) ;; not sure why increment necessary
    (lambda (context)
      (make-engraver
        (acknowledgers ((paper-column-interface engraver grob source-engraver)
          (let ((current-bar (ly:context-property context 'currentBarNumber)))
            (if (and (pair? bar-list)
                     (= (remainder current-bar total) 0)
                     (eq? #t (ly:grob-property grob 'non-musical)))
                (begin
                  (set! (ly:grob-property grob 'line-break-permission) 'force)
                  (if (not (null? (cdr bar-list)))
                      (begin
                        (set! bar-list (cdr bar-list))
                        (set! total (+ total (car bar-list))))
                      (set! bar-list '())))))))))))

\relative c' {
  \set Score.currentBarNumber = #4
  c4 c c c c c c c c c c c c2 c
  c4 c c c c c c c c c c c c2 c
  c4 c c c c c c c c c c c c2 c
}

\layout {
  \context {
    \Score
    \consists #(custom-line-breaks-engraver '(4 4 4))  % the break
occurs after measure with number 4, not after 4 measures
  }
}

cheers,
Janek

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Johan Vromans
In reply to this post by David Nalesnik
David Nalesnik <[hidden email]> writes:

> Hope this proves useful!

Please submit to LSR...

-- Johan

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik
In reply to this post by Janek Warchoł
Hi Janek,

On Sat, May 19, 2012 at 4:27 AM, Janek Warchoł <[hidden email]> wrote:
David,

a couple of thoughts:
- what about looping the break pattern?  I.e. \consists
#(custom-line-breaks-engraver '(2 3 4)) = \consists
#(custom-line-breaks-engraver '(2 3 4 2 3 4 2 3 4 ... 2 3 4))?

Great idea--this means that you can fix the number of bars per line by using a single number as your argument.  I'll see what I can do!

- i'm not sure if this is desired or not, but changing current
barNumber confuses your function:

Yup, I suspected that it would!  Substituting 'internalBarNumber for 'currentBarNumber seems to do the trick:

 \version "2.15.38"

#(define (custom-line-breaks-engraver bar-list)
  (let ((total (1+ (car bar-list))))
    (lambda (context)
      (make-engraver
        (acknowledgers ((paper-column-interface engraver grob source-engraver)
          (let ((internal-bar (ly:context-property context 'internalBarNumber)))
            (if (and (pair? bar-list)
                     (= (remainder internal-bar total) 0)
                     (eq? #t (ly:grob-property grob 'non-musical)))
                (begin
                  (set! (ly:grob-property grob 'line-break-permission) 'force)
                  (if (null? (cdr bar-list))
                      (set! bar-list '())
                      (begin
                        (set! bar-list (cdr bar-list))
                        (set! total (+ total (car bar-list))))))))))))))


-David

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik
Hi again Janek,

On Sat, May 19, 2012 at 6:40 AM, David Nalesnik <[hidden email]> wrote:
Hi Janek,

On Sat, May 19, 2012 at 4:27 AM, Janek Warchoł <[hidden email]> wrote:
David,

a couple of thoughts:
- what about looping the break pattern?  I.e. \consists
#(custom-line-breaks-engraver '(2 3 4)) = \consists
#(custom-line-breaks-engraver '(2 3 4 2 3 4 2 3 4 ... 2 3 4))?

Great idea--this means that you can fix the number of bars per line by using a single number as your argument.  I'll see what I can do!

OK, this incorporates your idea of looping.  You specify a list as the argument of the function, and that grouping will loop until the end.  The example below shows how you would get four measures per line.  The score ends with whatever's left over, in this case the last two bars.

If you want to see the 2 3 4 pattern, do lthis:
\consists #(custom-line-breaks-engraver '(2 3 4))

Thanks for trying this out!  Please let me know if you run into any problems or have any more suggestions.

-David

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.15.38"
                    
#(define (custom-line-breaks-engraver bar-list)
  (let* ((working-copy bar-list)
         (total (1+ (car working-copy))))
    (lambda (context)
      (make-engraver
        (acknowledgers ((paper-column-interface engraver grob source-engraver)
          (let ((internal-bar (ly:context-property context 'internalBarNumber)))
            (if (and (pair? working-copy)
                     (= (remainder internal-bar total) 0)
                     (eq? #t (ly:grob-property grob 'non-musical)))
                (begin
                  (set! (ly:grob-property grob 'line-break-permission) 'force)
                  (if (null? (cdr working-copy))
                      (set! working-copy bar-list)
                      (begin
                        (set! working-copy (cdr working-copy))))
                        (set! total (+ total (car working-copy))))))))))))
                       
\relative c' {
 \set Score.currentBarNumber = #4
   \repeat unfold 10 {
     \time 5/4
     c4 c c c c
     \time 3/4
     c c c
     \time 3/2
     c2 c c
   }
}

\layout {
  \context {
    \Score
    %\override NonMusicalPaperColumn #'line-break-permission = ##f
    \consists #(custom-line-breaks-engraver '(4))
  }
}

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik
In reply to this post by Johan Vromans
Hi Johan,

Please submit to LSR...

Will do.  The LSR is running 2.14.2 right now, so I'll have to make some changes.  (In particular, the function uses David Kastrup's make-engraver macro which is fairly recent.)

-David 

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

Janek Warchoł
In reply to this post by David Nalesnik
Hi David,

On Sat, May 19, 2012 at 2:56 PM, David Nalesnik
<[hidden email]> wrote:
> OK, this incorporates your idea of looping.  You specify a list as the
> argument of the function, and that grouping will loop until the end.  The
> example below shows how you would get four measures per line.  The score
> ends with whatever's left over, in this case the last two bars.

It's perfect!  Thank you!  Will be handy when i'll be revising my
score of Allegri's Miserere (would you like a copy?).

cheers,
Janek

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Four Bars per Line/System, again :)

David Nalesnik
Hi Janek,

On Sat, May 19, 2012 at 8:17 AM, Janek Warchoł <[hidden email]> wrote:
Hi David,

On Sat, May 19, 2012 at 2:56 PM, David Nalesnik
<[hidden email]> wrote:
> OK, this incorporates your idea of looping.  You specify a list as the
> argument of the function, and that grouping will loop until the end.  The
> example below shows how you would get four measures per line.  The score
> ends with whatever's left over, in this case the last two bars.

It's perfect!  Thank you!  Will be handy when i'll be revising my
score of Allegri's Miserere (would you like a copy?).

Sure!  Please try it out on anything and everything you like.  I tried it on a complex piano score, and no problems :)

Best,
David 

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
123