Jump to content

Creating “real” parenthesized dynamics: 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 3: Line 3:
However, it is possible to create a similar object using the equivalent Scheme code (as described in the Notation Reference), combined with the <code>make-dynamic-script</code> function. This way, the markup will be regarded as a dynamic, and therefore will remain compatible with commands such as <code>\dynamicUp</code> or <code>\dynamicDown</code>.
However, it is possible to create a similar object using the equivalent Scheme code (as described in the Notation Reference), combined with the <code>make-dynamic-script</code> function. This way, the markup will be regarded as a dynamic, and therefore will remain compatible with commands such as <code>\dynamicUp</code> or <code>\dynamicDown</code>.


<lilypond version="2.24.0">
<lilypond version="2.24">
paren =
paren =
#(define-event-function (dyn) (ly:event?)
#(define-event-function (dyn) (ly:event?)

Revision as of 18:47, 16 November 2025

Although the easiest way to add parentheses to a dynamic mark is to use a \markup block, this method has a downside: the created objects will behave like text markups, and not like dynamics.

However, it is possible to create a similar object using the equivalent Scheme code (as described in the Notation Reference), combined with the make-dynamic-script function. This way, the markup will be regarded as a dynamic, and therefore will remain compatible with commands such as \dynamicUp or \dynamicDown.

\version "2.24"

paren =
#(define-event-function (dyn) (ly:event?)
   (make-dynamic-script
    #{ \markup \concat {
         \normal-text \italic \fontsize #2 (
	 \pad-x #0.2 #(ly:music-property dyn 'text)
	 \normal-text \italic \fontsize #2 )
       }
    #}))

\relative c'' {
  c4\paren\f c c \dynamicUp c\paren\p
}