Hi,

On Wed, Oct 22, 2014 at 8:59 AM, Les Editions Valmajour <
p...@editions-valmajour.fr> wrote:

> Hi Kieren,
> I thought about this option, and I found how to add a counter in the
> shortInstrumentName; http://lsr.di.unimi.it/LSR/Item?id=543 (and it works
> and give the perfect placement I want) but I don't know how to link it to
> the number of the bar beginning the system :)
> Thanks anyway,
> Best regards,
> Pierre
>
> Le 22-10-2014 15:55, Kieren MacMillan a écrit :
>
>  Bonjour, Pierre!
>>
>>  I would like to position the bar numbers for a piano system in front of
>>> and centered on StartSystem Brace. Like if it was in the place of the
>>> Instrument Name (or Short Instrument Name).
>>>
>> The best way, I imagine, would be for shortInstrumentName to actually
>> *be* a call-back function that displays the bar number.
>>
>
Interesting idea to hook onto instrument names since that would handle the
positioning.

See my experiments in the attached file.

I first tried an engraver, but you can see the problem!  The bar number
text is set once and for all to 21--which is the last measure LilyPond sees
(one beyond the 100 of the score).

I next tried a callback for InstrumentName.after-line-breaking.  It works,
but there's no way I know of to get the bar number, so you have to add it
to the list that the function is called with.

Maybe the best way is to write something to change the positioning of
BarNumber, but I need to work on something other than LilyPond for the time
being, so any takers welcome!

Hope this helps.

Best,
David
\version "2.19.15"

barLineAtSystemBeginning =
#(lambda (context)
   (let ((text #f))
     (make-engraver
      (acknowledgers ((system-start-text-interface engraver grob source-engraver)
                      (set! text grob)))
      ((process-music trans)
       (if (ly:grob? text)
           (let ((bar-number (ly:context-property context 'currentBarNumber)))
             (set! (ly:grob-property text 'text) 
                   (markup (number->string bar-number)))))))))

#(define (use-my-text text-list) 
   (lambda (grob)
         (let* ((orig (ly:grob-original grob))
                (siblings (if (ly:grob? orig)
                              (ly:spanner-broken-into orig)
                              '()))
                (text-list (cons "" text-list)))
           (let loop ((sibs siblings) (text text-list))
             (if (or (null? sibs) (null? text))
                 '()
                 (begin
                  (ly:grob-set-property! (car sibs) 'text (car text))
                  (loop (cdr sibs) (cdr text))))))))


music = \repeat unfold 20 {
  c4 d e f
}

%%%%% Engraver %%%%%
\score {
  \new PianoStaff \with { instrumentName = "" } <<
    \new Staff {
      \relative c'' {
        \music
      }
    }
    \new Staff {
      \clef bass
      \music
    }
  >>
  \layout {
    \context {
      \Score
      \consists #barLineAtSystemBeginning
      \remove "Bar_number_engraver"
    }
  }
}

%%%%%%%% WORKS BUT CAN'T BE AUTOMATED

\score {
  \new PianoStaff \with { instrumentName = "" } <<
    \new Staff {
      \relative c'' {
        \music
      }
    }
    \new Staff {
      \clef bass
      \music
    }
  >>
  \layout {
    \context {
      \Score
      \override InstrumentName.after-line-breaking = #(use-my-text '("7" "14"))
      \remove "Bar_number_engraver"
    }
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to