カスタム強弱記号を水平方向に揃える ("sempre pp" "piu f" "subito p" など)

強弱記号の中には追加のテキストを伴うもの (例えば “sempre pp”) があります。強弱記号は通常音符の下に中央揃えされるため、\pp の部分が音符に揃えられる必要があります。

“sempre pp” を水平方向に正しく揃えるためには、あたかも \pp のみが存在するかのように揃える必要があります。いくつかのアプローチがあります:

* 強弱記号が適用される音符の前に \once\override DynamicText.X-offset = #-9.2 を設定し、手動で正しい位置にシフトします。欠点: この強弱記号を使用する際に毎回手動でシフトを行う必要があります。

* カスタム強弱記号の定義にいくらかのパディング (#:hspace 7.1) を追加して、それを中央揃えさせます。欠点: パディングは実際にスペースを占有するため、その位置に他のマークアップや強弱記号は配置されません。

* 強弱記号のスクリプトを \once\override ... .X-offset = .. でシフトします。欠点: \once \override が毎回必要です!

* 追加されるテキストの寸法を (#:with-dimensions '(0 . 0) '(0 . 0) を用いて) 0 にします。欠点: LilyPond にとっては “sempre” のサイズが 0 になるため、他のオブジェクトと衝突する可能性があります (衝突判定が行われないということです!)。また、いくつかのスペースは占有されているようであり、テキストが存在しない場合に比べて配置が多少ずれます。

* dynamic-script の Scheme 関数内で、直接明示的にシフトを設定します。

* dynamic-script の内部で明示的に揃え位置を設定します。デフォルトでは、これは何の効果も現れませんが、X-offset を指定した際にのみ有効となります! 欠点: DynamicText.X-offset をセットする必要があり、それは全ての強弱記号に影響します! また、揃え位置は pp の中央ではなく、追加したテキストの右端となります。

\paper {
  ragged-right = ##f
  indent = 2.5\cm
  tagline = ##f
}

% Solution 1: Using a simple markup with a particular halign value
% Drawback: It's a markup, not a dynamic command, so \dynamicDown
%           etc. will have no effect
semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }

% Solution 2: Using a dynamic script & shifting with
%             \once \override ...X-offset = ..
% Drawback: \once \override needed for every invocation
semppK =
#(make-dynamic-script
  (markup #:line
          (#:normal-text
           #:italic "sempre"
           #:dynamic "pp")))

% Solution 3: Padding the dynamic script so the center-alignment
%             puts it at the correct position
% Drawback: the padding really reserves the space, nothing else can be there
semppT =
#(make-dynamic-script
  (markup #:line
          (#:normal-text
           #:italic "sempre"
           #:dynamic "pp"
           #:hspace 7.1)))

% Solution 4: Dynamic, setting the dimensions of the additional text to 0
% Drawback: To lilypond "sempre" has no extent, so it might put
%           other stuff there => collisions
% Drawback: Also, there seems to be some spacing, so it's not exactly the
%           same alignment as without the additional text
semppM =
#(make-dynamic-script
  (markup #:line
          (#:with-dimensions '(0 . 0) '(0 . 0)
                             #:right-align
                             #:normal-text
                             #:italic "sempre"
                             #:dynamic "pp")))

% Solution 5: Dynamic with explicit shifting inside the scheme function
semppG =
#(make-dynamic-script
  (markup #:hspace 0
          #:translate '(-18.85 . 0)
          #:line (#:normal-text
                  #:italic "sempre"
                  #:dynamic "pp")))

% Solution 6: Dynamic with explicit alignment. This has only effect
%             if one sets X-offset!
% Drawback: One needs to set DynamicText.X-offset!
% Drawback: Aligned at the right edge of the additional text,
%           not at the center of pp
semppMII =
#(make-dynamic-script
  (markup #:line (#:right-align
                  #:normal-text
                  #:italic "sempre"
                  #:dynamic "pp")))

\new StaffGroup <<
  \new Staff = "s" \with { instrumentName = \markup \column { Normal } }
  <<
    \relative c'' {
      \key es \major
      c4\pp c\p c c | c\ff c c\pp c
    }
  >>
  \new Staff = "sMarkup" \with {
    instrumentName = \markup \column { Normal markup }
  }
  <<
    \relative c'' {
      \key es \major
      c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c
    }
  >>
  \new Staff = "sK" \with {
    instrumentName = \markup \column { Explicit shifting }
  }
  <<
    \relative c'' {
      \key es \major
      \once \override DynamicText.X-offset = #-9.2
      c4\semppK c\p c c
      c4\ff c
      \once \override DynamicText.X-offset = #-9.2
      c4\semppK c
    }
  >>
  \new Staff = "sT" \with {
    instrumentName = \markup \column { Right padding }
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppT c\p c c | c\ff c c\semppT c
    }
  >>
  \new Staff = "sM" \with {
    instrumentName = \markup \column { Set dimension "to zero" }
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppM c\p c c | c\ff c c\semppM c
    }
  >>
  \new Staff = "sG" \with {
    instrumentName = \markup \column { Shift inside dynamics}
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppG c\p c c | c\ff c c\semppG c
    }
  >>
  \new Staff = "sMII" \with {
    instrumentName = \markup \column { Alignment inside dynamics }
  }
  <<
    \relative c'' {
      \key es \major
      % Setting to ##f (false) gives the same result
      \override DynamicText.X-offset = #0
      c4\semppMII c\p c c | c\ff c c\semppMII c
    }
  >>
>>

\layout { \override Staff.InstrumentName.self-alignment-X = #LEFT }

[image of music]


LilyPond snippets v2.25.15 (開発版).