Jump to content

Moving dynamics horizontally: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
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



Revision as of 18:51, 16 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
}