lilypond-user
[Top][All Lists]
Advanced

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

Re: Bar counts and repeats in repetitive music


From: Jeffery Shivers
Subject: Re: Bar counts and repeats in repetitive music
Date: Fri, 17 Feb 2017 12:24:11 -0500

> The bar number check works, but the printed bar numbers are still sequential, 
> which I don't understand.

It was clear that this was a context issue, but not so clear how to
address that. For the record, context-spec-music was the procedure
that makes this work. The following passes check and engraves as
intended:

=== begin snippet

repeatSect =
  #(define-music-function (parser location num mus)
    (number? ly:music?)
    (define startBar #f)
    #{
      #(make-apply-context
          (lambda (context)
            (let ((currentBar (ly:context-property context 'currentBarNumber)))
              (set! startBar currentBar))))
      \repeat volta #num { #mus }
      #(context-spec-music
          (make-apply-context
            (lambda (context)
              (let* ((endBar (ly:context-property context 'currentBarNumber))
                      (repLength (- endBar startBar))
                      (lenScaled (* repLength num))
                      (nextBar (+ startBar lenScaled)))
                (ly:context-set-property! context 'currentBarNumber nextBar))))
      'Score)
    #})

\score {
\new Staff {
  \override Score.BarNumber.break-visibility = #'#(#t #t #t)
    \barNumberCheck #1
    \repeatSect 4 { \rhPatternA }
    % adds 4 bars ... (1 + 4 = 5)
    \barNumberCheck #5
    \repeatSect 16 { \rhPatternA }
    % adds 16 bars ... (5 + 16 = 21)
    \barNumberCheck #21
    \repeatSect 4 { \rhPatternB }
    % adds 4 bars ... (21 + 4 = 25)
    \barNumberCheck #25
    \repeatSect 2 { \rhPatternA }
  }
}

=== end snippet

> But it's also essential that the performer is told how many times to repeat 
> each fragment! At the moment I've chickened out and used percent repeats with 
> counts :(

I'll have a look at this - probably a matter of adding a new engraver;
I've seen a trick that used \Dynamic context to display centered
measure numbers before, so maybe something like that.

On Fri, Feb 17, 2017 at 11:44 AM, Peter Toye <address@hidden> wrote:
> Jeffery,
>
> Thanks. There's a lot to look at here, as I'm not (yet?) a Scheme/Guile
> programmer! But as you hint it doesn't seem to work, though. The bar number
> check works, but the printed bar numbers are still sequential, which I don't
> understand.
>
> But it's also essential that the performer is told how many times to repeat
> each fragment! At the moment I've chickened out and used percent repeats
> with counts :(
>
> Best regards,
>
> Peter
> mailto:address@hidden
> www.ptoye.com
>
> -------------------------
>> Without investigating how the bar number engraver (I'm guessing, or
>> whatever engraves them), I am unsure how to correct what actually
>> gets *engraved* (which is obviously important), but here's a partial
>> solution.
>>
>> \adjustBarNum applies the repeats and does the calculations, and
>> seems to reset each next *currentBarNumber* to what it should be.
>> Maybe someone with more knowledge of how bar numbers are engraved
>> can have a look and see what is wrong/missing.



-- 

Jeffery Shivers
 jefferyshivers.com
 soundcloud.com/jefferyshivers



reply via email to

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