"I called the function \tempoTextSpan" should be "I named the function
\tempoTextSpan" to avoid confusion with programming jargon ;-).

Am Fr., 18. Sept. 2020 um 11:01 Uhr schrieb Martín Rincón Botero <
martinrinconbot...@gmail.com>:

> Dear Aaron,
>
> thanks again for that script! I could successfully adapt part of your
> script to most of what I wanted. I called the function \tempoTextSpan for
> use in constructions like rit. _ _ _ _ $new tempo with \startTextSpan
> \stopTextSpan, and it accepts a left text (e.g. "rit."), a tempo definition
> (metronome mark), and left and right \halign values. Since this is my
> second day of ever trying to make a Scheme function at all, there is still
> a lot I don't know how to do. The thing I couldn't adapt from your script
> is the Text part, when the user writes a new tempo with a construction like
> \tempo "Allegro". I suppose I have to somehow put my \once \override
> TextSpanner #'(bound-details right text) in some sort of conditional so
> that when the user puts a text, it displays a text, when it's a metronome,
> a metronome :-), but I couldn't figure out how to adapt what you already
> had. I also wasn't successful in adding \once \omit Score.MetronomeMark
> \tempo #tempo-unit = #metronome-count, so that the MIDI can pick up the new
> tempo mark, if a metronome is given (probably because the new tempo is
> converted to a markup and can't be used as a "real" tempo definition
> anymore?). Anyways, with those two features still missing, I'm quite happy
> with using the syntax shown in the example after the script:
>
> \version "2.20.0"
>
> #(define (tempo? arg)
>    (and (ly:music? arg)
>         (not (null? (extract-typed-music arg 'tempo-change-event)))))
>
> tempoTextSpan =
> #(define-scheme-function
>    (leftmarkup tempo lefthalign righthalign)
>    (markup? tempo? number? number?)
>    (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))
>          )
>      (set! tempo-unit
>        (if (ly:duration? tempo-unit)
>            #{ \markup {
>              \note #(ly:duration->string tempo-unit) #UP
>                } #} ))
>      (set! metronome-count
>        (cond ((number-pair? metronome-count)
>               #{ \markup {
>                  #(format #f "~d" (car metronome-count)) -
>                  #(format #f "~d" (cdr metronome-count)) } #})
>              ((number? metronome-count)
>               #{ \markup {
>                  #(format #f "~d" metronome-count) } #})
>              ))
>      #{
> \once \override TextSpanner.bound-details.left-broken.text = ##f
> \once \override TextSpanner.bound-details.right-broken.text = ##f
> \once \override TextSpanner #'(bound-details left text) =  \markup \halign
> #lefthalign { \abs-fontsize #11 #leftmarkup }
> \once \override TextSpanner #'(bound-details right text) = \markup \halign
> #righthalign { \abs-fontsize #10 \general-align #Y #DOWN #tempo-unit
> \abs-fontsize #11 \upright {"=" #metronome-count } }
>      #}))
>
> {
> \tempoTextSpan "accel." \tempo 4 = 50 #0 #2
> c'1\startTextSpan
> c'1
> c'1\stopTextSpan
> }
>
> Thank you Aaron! Perhaps you or someone else can point me in the right
> direction for adding the two missing features to the script.
>
> Best regards,
> Martín.
>
> Am Do., 17. Sept. 2020 um 13:11 Uhr schrieb Aaron Hill <
> lilyp...@hillvisions.com>:
>
>> 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
>
>
>
> --
> www.martinrinconbotero.com
>


-- 
www.martinrinconbotero.com

Reply via email to