Jump to content

Dynamics spanner with custom text: 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:
Postfix functions for custom crescendo text spanners. The spanners should start on the first note of the measure. One has to use <code>-\mycresc</code>, otherwise the spanner start will rather be assigned to the next note.
Postfix functions for custom crescendo text spanners. The spanners should start on the first note of the measure. One has to use <code>-\mycresc</code>, otherwise the spanner start will rather be assigned to the next note.


<lilypond version="2.24.0">
<lilypond version="2.24">
% Two functions for (de)crescendo spanners where you can explicitly
% Two functions for (de)crescendo spanners where you can explicitly
% give the spanner text.
% give the spanner text.

Revision as of 18:57, 16 November 2025

Postfix functions for custom crescendo text spanners. The spanners should start on the first note of the measure. One has to use -\mycresc, otherwise the spanner start will rather be assigned to the next note.

\version "2.24"

% Two functions for (de)crescendo spanners where you can explicitly
% give the spanner text.
mycresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'CrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))
mydecresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'DecrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))

\relative c' {
  c4-\mycresc "custom cresc" c4 c4 c4 |
  c4 c4 c4 c4 |
  c4-\mydecresc "custom decresc" c4 c4 c4 |
  c4 c4\! c4 c4
}