That works perfectly, thanks! Alex
On Thu, Mar 2, 2023 at 1:34 PM Jean Abou Samra <j...@abou-samra.fr> wrote: > Le jeudi 02 mars 2023 à 12:11 -0700, Alexandre Loomis a écrit : > > Hi, > > 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 = > #(define-music-function > (text) > (markup?) > #{ > \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 = > #(define-music-function > (text) > (markup?) > #{ > \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 > \startTextSpan > #}) > > 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. > > HTH, > > Jean >