[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Harp Pedal Spanner

From: Jean Abou Samra
Subject: Re: Harp Pedal Spanner
Date: Thu, 02 Mar 2023 21:34:22 +0100
User-agent: Evolution 3.46.4 (3.46.4-1.fc37)

Le jeudi 02 mars 2023 à 12:11 -0700, Alexandre Loomis a écrit :


I'm having trouble defining a harp pedal spanner. I'd like to be able to write code like

\relative c' { f4 _\startPedal "F♮" g fes \endPedal "♭" }

and get as output the notes, with F♮ below the f natural, ♭ below the f flat, and a line connecting the markups. So far the closest I've been able to get is

\relative c' { \startPedal "F♮" \endPedal "♭" f4 _\startTextSpan g fes \stopTextSpan }

where startPedal and endPedal are defined as

startPed =
    \once \override TextSpanner.dash-fraction = #1.0
    \once \override TextSpanner.bound-details.left.text = #text
    \once \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
    \once \override TextSpanner.font-shape = #'upright

endPed =
    \once \override TextSpanner.bound-details.right.text = #text
    \once \override TextSpanner.bound-details.right.stencil-align-dir-y = #CENTER
This produces the correct output, but needing to call all four of startPed, endPed, startTextSpan, and stopTextSpan is inconveniently verbose.

With \override, you need to put the command before the note, but LilyPond also has \tweak, which attaches to the event itself, so you can do

\version "2.24.1"

startPed =
#(define-music-function (start-text end-text) (markup? markup?)
    \tweak dash-fraction #1.0
    \tweak bound-details.left.text #start-text
    \tweak bound-details.left.stencil-align-dir-y #CENTER
    \tweak font-shape #'upright
    \tweak bound-details.right.text #end-text
    \tweak bound-details.right.stencil-align-dir-y #CENTER

endPed = \stopTextSpan

\relative c' { f4 _\startPed "F♮" "♭" g fes \endPed }

Note that this isn't exactly your wished syntax because the end text is given to \startPed, not to \endPed. There are no built-in ways to override the properties of a spanner at a later point than the moment it has been created in, so it would require custom Scheme code to make your original syntax work. Unless you really want that, I suggest you just use this syntax, which isn't more verbose than yours.



Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]