lilypond-user
[Top][All Lists]
Advanced

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

Re: dynamic alignment


From: Jan-Peter Voigt
Subject: Re: dynamic alignment
Date: Thu, 16 Dec 2010 10:16:10 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7

Thank you Neil,

so I applied this to my little script and will post this to LSR :-)
The question of Ralph Palmer ("Unexpected \markup behavior") made me think of this. So my next step is to build this with a whiteout-option.
Simple whiteout is trivial, but with padding, there has to more calculating.

If you use this, there is one thing to mention: 'X-offset is now tweaked, so overriding it ([\once] \override DynamicText #'X-offset) will have no effect on this dynamic signs anymore!

Regards,
Jan-Peter

--snip--
\version "2.12.3"

% calculate x-alignment based on attribute text + dynamic text
% this has to be a markup-command to get stencil-extent based on (interpret-markup layout props ...) #(define-markup-command (center-dyn layout props atr-text dyn)(markup? string?)
  "x-align on center of dynamic"
  (let* (
          (text (string-append atr-text " "))
(atr-stencil (interpret-markup layout props (markup #:normal-text #:italic text))) (dyn-stencil (interpret-markup layout props (markup #:dynamic dyn)))
          (atr-x-ext (ly:stencil-extent atr-stencil X))
          (dyn-x-ext (ly:stencil-extent dyn-stencil X))
          (atr-x (- (cdr atr-x-ext)(car atr-x-ext)))
          (dyn-x (- (cdr dyn-x-ext)(car dyn-x-ext)))
          (x-align
            (* (-
                 (/ (+ atr-x (/ dyn-x 2)) (+ atr-x dyn-x) )
                 0.5) 2)
          )
        )
(interpret-markup layout props (markup #:halign x-align #:concat (#:normal-text #:italic text #:dynamic dyn)))
))
% define a 'new' attributed dynamic script
#(define (make-atr-dynamic-script atr dyn)
(let ((dynamic (make-dynamic-script (markup #:center-dyn atr dyn)))) (ly:music-set-property! dynamic 'tweaks (acons 'X-offset 0 (ly:music-property dynamic 'tweaks)))
             dynamic))

% define some attributed dynamics
pocof = #(make-atr-dynamic-script "poco" "f")
menof = #(make-atr-dynamic-script "meno" "f")
subp = #(make-atr-dynamic-script "subito" "p")

\paper {
  #(set-paper-size "a5" 'landscape)
  ragged-last = ##f
}
\score {
<<
    \new Staff <<
      \relative c'' {
        \dynamicUp
        r4 c\pocof d e | d\ff d cis eis ~ | eis1\subp | r4 b\menof c\f r4
      }
>>
>>
  \layout {
  }
}
--snip--


On 16.12.2010 01:16, Neil Puttock wrote:
On 13 December 2010 11:21, Jan-Peter Voigt<address@hidden>  wrote:

Is it possible to set that value inside the make-dynamic-script or align it
some other way, so that I can simply use my defined \pocof (etc.) without
switching X-offset on and off?
Sure, by overriding X-offset as a tweak:

pocof =
#(let ((dynamic (make-dynamic-script (markup #:center-dyn "poco" "f"))))
     (set! (ly:music-property dynamic 'tweaks)
            (acons 'X-offset 0 (ly:music-property dynamic 'tweaks)))
    dynamic)

Cheers,
Neil





reply via email to

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