lilypond-user
[Top][All Lists]
Advanced

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

Re: Guitar Barre'


From: Nicolas Sceaux
Subject: Re: Guitar Barre'
Date: Thu, 28 Apr 2005 11:26:15 +0200
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Nicolas Sceaux <address@hidden> writes:

> Maurizio Monge <address@hidden> writes:
>
>> Thanx, i am now triying to write a macro to realize barre 
>> comfortably. I also found the following code in an older
>> port, but i doesn't compile (2.5.20). What's wrong?
>> I really would like to end up with a function like:
>>    \barre #"IV" { c d e }
>> or at least
>>    \barre #"IV"  c \startTextSpan d e  \stopTextSpan
>> Any suggestion?
>> Thanks

For the first one, a solution that might work:

\version "2.5.20"
barre = #(def-music-function (barre location str music) (string? ly:music?)
           (let ((spanned-music 
                   (let ((first-element #f)
                         (last-element #f)
                         (first-found? #f))
                     (music-map (lambda (m)
                                  (if (eqv? (ly:music-property m 'name) 
'EventChord)
                                      (begin
                                        (if (not first-found?) 
                                            (begin
                                              (set! first-found? #t)
                                              (set! first-element m)))
                                        (set! last-element m)))
                                  m)
                                music)
                     (if first-found?
                         (begin
                           (set! (ly:music-property first-element 'elements)
                                 (cons (make-music 'TextSpanEvent 
'span-direction -1)
                                       (ly:music-property first-element 
'elements)))
                           (set! (ly:music-property last-element 'elements)
                                 (cons (make-music 'TextSpanEvent 
'span-direction 1)
                                       (ly:music-property last-element 
'elements)))))
                     music)))
             (make-music 'SequentialMusic
               'origin location
               'elements (list #{
                           \once \override Voice . TextSpanner #'edge-text = 
                             #$(cons (format "C ~a" str) "")
                           \once \override Voice . TextSpanner #'direction = #1
                           \once \override Voice . TextSpanner #'edge-height = 
#'(0 . 0.5)
                           \once \override Voice . TextSpanner #'padding = #1 
                           \once \override Voice . TextSpanner #'enclose-bounds 
= #1
                           #}
                           spanned-music))))
               
{ c'' \barre #"IV"  { a' b' } c'' }

nicolas




reply via email to

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