lilypond-user
[Top][All Lists]
Advanced

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

Re: Letters as Left hand fingering


From: David Kastrup
Subject: Re: Letters as Left hand fingering
Date: Wed, 16 May 2012 12:52:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

David Kastrup <address@hidden> 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




reply via email to

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