[Top][All Lists]

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

Re: get current bar number

From: Kevin Barry
Subject: Re: get current bar number
Date: Sat, 24 Mar 2018 23:04:53 +0000

Hi Jan/Wols,

Thank you for responding. I have tinkered with \applyContext and
cannot get the property out of it to do anything useful with it. Since
it always returns music I can't feed it to a markup command or convert
it to markup or set it as the value for a property (using a callback
or something like that). I have tried using it to set! another
property and print that, but it doesn't work.

I tried looking at the code for the rehearsal mark engraver, but it's
in C++ and I don't understand it (and I suspect context objects are in
the #included contexts.hh). I also looked at the code for the
Measure_counter_engraver, which is in scheme, but it takes a context
object as its parameter, which doesn't seem to get me any closer.

I must be misunderstanding something. My best attempt is below. Any
further help would be appreciated.

#(define-markup-command (print-bar-number layout props) ()
  (define barnum 0)
  (let* ((setbarnum (lambda (context)
                       (set! barnum
                             (ly:context-property context 'currentBarNumber)))))
    (make-apply-context setbarnum)
    (interpret-markup layout props
      (markup (number->string barnum)))))

\repeat unfold 3 { b1^\markup \print-bar-number }


reply via email to

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