Jump to content

Moving dynamics horizontally: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m New category
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Here are two functions to move dynamics easily. The first one moves the dynamics horizontally and drops / raises it closer to the staff if there's room. With the second one you can move the dynamics also vertically.
Here are two functions to move dynamics easily. The first one moves the dynamics horizontally and drops / raises it closer to the staff if there's room. With the second one you can move the dynamics also vertically.


<lilypond version="2.24.0">
<lilypond version="2.24">
%% http://lsr.di.unimi.it/LSR/Item?id=469
%% http://lsr.di.unimi.it/LSR/Item?id=469


Line 28: Line 28:
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Workaround]]
[[Category:Workaround]]
[[Category:Snippet]]

Latest revision as of 23:31, 21 November 2025

Here are two functions to move dynamics easily. The first one moves the dynamics horizontally and drops / raises it closer to the staff if there's room. With the second one you can move the dynamics also vertically.

\version "2.24"

%% http://lsr.di.unimi.it/LSR/Item?id=469

%LSR This snippet was contributed by Risto Vääräniemi

dynamicsX = 
#(define-music-function (offset)(number?)
  #{
     \once \override DynamicText.X-offset = $offset
     \once \override DynamicLineSpanner.Y-offset = #0
  #})

dynamicsXY = 
#(define-music-function (offsetX offsetY)(number? number?)
  #{
     \once \override DynamicText.X-offset = $offsetX
     \once \override DynamicLineSpanner.Y-offset = $offsetY
  #})

{
   b'2\f \dynamicsX #-3 b'2\f \dynamicsXY #-3 #-6 b'2\f
}