David Kastrup <[email protected]> writes:

> creates a post-event rather than a full music event.  So here is quite a
> bit of potential for creating a smoother experience.  Now of course one
> can streamline the user interface a bit by making individual commands
> for individual letters:
>
> \version "2.15.36"
>
> #(define (fingering-event? m) (and (ly:music? m)
>                                  (music-is-of-type? m 'fingering-event)))
>
> letter =
> #(define-event-function (parser location l fingering)
>     (string? fingering-event?)
>   (let* ((finger (ly:music-property fingering 'digit))
>        (n (number->string finger)))
>    #{
>      -\tweak #'text
>      \markup \concat \fontsize #6 \normal-text { #l #n }
>      #fingering
>    #}))
>
> defineletter =
> #(define-scheme-function (parser location l) (string?)
>   (define-event-function (parser location fingering) (fingering-event?)
>    #{ -\letter #l #fingering #}))
>
> X = \defineletter x
> Y = \defineletter y
> Z = \defineletter z
>
> \relative c' {
>         <a\X-1
>          cis\Y-2
>          e\Z-3>
> }
>
> As I said: it is not like things have gotten significantly easier.  But
> you get a _lot_ more of power and expressivity without programming
> complexity spiraling out of control.

One should actually replace the two occurences of "string?" above with
"markup?".  Everything else can stay identical.  But it means that one
can then also write things like

H = \defineletter \markup \raise #0.5 \smaller \natural

at no additional cost:

\version "2.15.36"

#(define (fingering-event? m) (and (ly:music? m)
                                   (music-is-of-type? m 'fingering-event)))

letter =
#(define-event-function (parser location l fingering)
    (markup? fingering-event?)
  (let* ((finger (ly:music-property fingering 'digit))
         (n (number->string finger)))
   #{
     -\tweak #'text
     \markup \concat \fontsize #6 \normal-text { #l #n }
     #fingering
   #}))

defineletter =
#(define-scheme-function (parser location l) (markup?)
  (define-event-function (parser location fingering) (fingering-event?)
   #{ -\letter #l #fingering #}))

X = \defineletter x
Y = \defineletter y
Z = \defineletter z
H = \defineletter \markup \raise #0.5 \smaller \natural

\relative c' {
        <a\X-1
         cis\Y-2
         e\Z-3
         g\H-4>
}

-- 
David Kastrup


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to