Hi David,

thanks for the assistance.

Am 08.05.2014 14:19, schrieb David Kastrup:
Urs Liska <u...@openlilylib.org> writes:

Hi,

I have this construct in a function that creates a combined time signature:

    (grob-interpret-markup grob
      (markup #:override '(baseline-skip . 0) #:number
        (#:line ((#:column (numOne denOne))
                 (#:column (numTwo denTwo))))))

It creates two columns from the four given arguments, but I want to be
able to create an arbitrary number of columns.

I see that #:line gets a list of (#:column ()) entries.
But I'm lost with the #: part. What does that mean?

That's the markup macro.  It is documented in the Extending Guide.  More
or less.

And how can I generate such a list with an arbitrary number of
columns?

You can't actually do it in time since the whole point of a macro is
that it operates on its elements _before_ they are evaluated.

So the Extending Guide says:

Known issues and warnings
.........................

The markup-list argument of commands such as ‘#:line’, ‘#:center’, and
‘#:column’ cannot be a variable or the result of a function call.

      (markup #:line (function-that-returns-markups))

is invalid.  One should use the ‘make-line-markup’,
‘make-center-markup’, or ‘make-column-markup’ functions instead,

      (markup (make-line-markup (function-that-returns-markups)))


That's how far I got - after writing the email ...


So let's fiddle this in another way:

That's where I did _not_ get




Of course, we can just abandon hope regarding the markup macro and do
this as

and this neither.
But I could incorporate the second solution in my function, and now it's a neat \alternatingTimeSignatures function.

Compile the attached file to see it in action.
I think this should be generally available, and if you don't think it should be included in LilyPond I'll put it in the openLilyLib snippets.

Best
Urs

\version "2.19.6"
#(define ((custom-time-signature one two) grob)
   ;; derived from
   ;; http://lilypond.1069038.n5.nabble.com/Mixed-Time-Signatures-Non-regular-alternantion-between-5-8-and-8-8-td18617.html
   (let ((numOne (number->string (car one)))
          (denOne (number->string (cdr one)))
          (numTwo (number->string (car two)))
          (denTwo (number->string (cdr two))))
   (grob-interpret-markup grob
     (markup #:override '(baseline-skip . 0) #:number
       (#:line ((#:column (numOne denOne))
                (#:column (numTwo denTwo))))))))


alternatingTimeSignatures =
#(define-music-function (parser location timesigs)
   (list?)
   (let* ((sigOne (car timesigs))
          (sigTwo (cadr timesigs)))
     #{
       \override Score.TimeSignature.stencil =
         #(custom-time-signature sigOne sigTwo)
       \time #sigOne
     #}
     ))

\relative c' {
  \alternatingTimeSignatures #'((3 . 8) (4 . 8))
  c8 d e
  \omit Score.TimeSignature
  \time 4/8
  f g a b
  \time 3/8
  c g c,
  d e f
  g a b
  \time 4/8
  c b a b
  \revert Score.TimeSignature.stencil
  \time 5/8
  c b a g f
  
}

\relative c' {
  \override TupletNumber.text = #tuplet-number::calc-fraction-text
  \alternatingTimeSignatures #'((3 . 4) (4 . 7))
  c4 d e
  \omit Score.TimeSignature
  \time 4/7
  \tupletSpan 4*16/7
  \tuplet 7/4 {
    f e f fis
    g a ais b
  }
  \time 3/4
  c4 g c,
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to