lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme predicative types


From: Aaron Hill
Subject: Re: Scheme predicative types
Date: Thu, 17 Sep 2020 04:11:11 -0700
User-agent: Roundcube Webmail/1.4.2

On 2020-09-17 4:01 am, Martín Rincón Botero wrote:
Dear Aaron,

thank you very much for your help! After using ly:duration->string for the
tempo-unit, I'm still missing a way to have the new string tempo-unit
string in "", so that I can display it as a \note in a \markup. How can I
achieve that? Sorry for taking so much of your time!

Should just be as simple as: \markup \note #(ly:duration->string dur) #UP

Modifying my code once again...

%%%%
\version "2.20.0"

#(define (tempo? arg)
  (and (ly:music? arg)
       (not (null? (extract-typed-music arg 'tempo-change-event)))))

describeTempo =
#(define-scheme-function
  (tempo)
  (tempo?)
  (set! tempo (first (extract-typed-music tempo 'tempo-change-event)))
  (let ((tempo-unit (ly:prob-property tempo 'tempo-unit #f))
        (metronome-count (ly:prob-property tempo 'metronome-count #f))
        (text (ly:prob-property tempo 'text #f)))
    (format #t "\nTempo:~{\t~s=~s~^\n~}"
      (list 'tempo-unit tempo-unit
            'metronome-count metronome-count
            'text text))
    (set! tempo-unit
      (if (ly:duration? tempo-unit)
          #{ \markup \box \concat {
            \note #(ly:duration->string tempo-unit) #UP
            \hspace #1 ( #(ly:duration->string tempo-unit) ) } #}
          #{ \markup unspecified #}))
    (set! metronome-count
      (cond ((number-pair? metronome-count)
             #{ \markup { between
               \box #(format #f "~d" (car metronome-count)) and
               \box #(format #f "~d" (cdr metronome-count)) } #})
            ((number? metronome-count)
             #{ \markup { exactly
               \box #(format #f "~d" metronome-count) } #})
            (else #{ \markup unspecified #})))
    (set! text
      (if (markup? text)
          #{ \markup \box #text #}
          #{ \markup unspecified #}))
    #{
      \markup \pad-around #1 \column {
        \line { \italic tempo-unit is #tempo-unit }
        \line { \italic metronome-count is #metronome-count }
        \line { \italic text is #text }
      }
    #}))

\describeTempo \tempo 4 = 50
\describeTempo \tempo "Text" 8. = 60-70
\describeTempo \tempo \markup \bold "Text"
%%%%


-- Aaron Hill

Attachment: tempo-function.cropped.png
Description: PNG image


reply via email to

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