lilypond-user
[Top][All Lists]
Advanced

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

Re: #(make-dynamic-script) [TIP/TRICK/FUNCTION]


From: Kieren MacMillan
Subject: Re: #(make-dynamic-script) [TIP/TRICK/FUNCTION]
Date: Mon, 5 Jun 2006 18:18:26 -0400

Hi, everyone!

Graham offered:
Seriously, I don't know how to do this, but a set of tips on how to produce easily-used and beautiful "sub p" / "f espr" / etc signs would be of great value to many people (including me). Please consider figuring this out, and if necessary adding patches to lilypond to enable this.

This really isn't worthy of becoming a "patch" yet -- I'm too busy finishing up my opera to really double-check the code, never mind make it more flexible -- but the two functions included in the example below work pretty nicely as a hack for now. [Many thanks to Nicolas for all the Scheme help.]

Hope this helps someone else!
Kieren.

________________________________

\version "2.9.7"

addDynText =
#(define-music-function (parser location dyn text event-chord)
                        (string? string? ly:music?)
   ;; add the AbsoluteDynamicEvent to the EventChord
   (set! (ly:music-property event-chord 'elements)
         (cons (make-music 'AbsoluteDynamicEvent
                           'text (markup #:dynamic dyn
                                         #:normal-text #:italic text))
                 (ly:music-property event-chord 'elements)))
   ;; return a SequentialMusic with a ContextSpeccedMusic
   ;; and the modified EventChord
   (make-music 'SequentialMusic
     'elements
     (list (make-music 'ContextSpeccedMusic
             'property-operations '()
             'context-type 'Bottom
             'element (make-music 'OverrideProperty
                        'once #t
                        'grob-property-path (list 'X-offset)
                        'grob-value -1.5
                        'symbol 'DynamicText
                        'pop-first #t))
           event-chord)))

addTextDyn =
#(define-music-function (parser location text dyn event-chord)
                        (string? string? ly:music?)
   ;; add the AbsoluteDynamicEvent to the EventChord
   (set! (ly:music-property event-chord 'elements)
         (cons (make-music 'AbsoluteDynamicEvent
                           'text (markup #:normal-text #:italic text
                                         #:hspace 0 #:dynamic dyn))
                 (ly:music-property event-chord 'elements)))
   ;; return a SequentialMusic with a ContextSpeccedMusic
   ;; and the modified EventChord
   (make-music 'SequentialMusic
     'elements
     (list (make-music 'ContextSpeccedMusic
             'property-operations '()
             'context-type 'Bottom
             'element (make-music 'OverrideProperty
                        'once #t
                        'grob-property-path (list 'X-offset)
                        'grob-value -1.5
                        'symbol 'DynamicText
                        'pop-first #t))
           event-chord)))

\relative c'
{
        \addDynText "fff" "always" <c d e>4\<
        \addTextDyn "always" "fff" <c d e>4\> c\!
}




reply via email to

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