Thanks for the suggestion, Kieren! However, the chord is still "anchored" to the left.
I've managed to find a hack/workaround - centering the chord on fourth eight-note ( s4. c4 s4. ). It gets the job done... but is not the "beautiful code" I thought I'd have. At least I'm only using two overrides and not altering any context with regards to the ChordNames; the OneStaff also solves a bit of hassle. I'll attach a blues sheet I've managed to create that satisfies my initial question; still, I'd greatly appreciate any code changes so as not to rely on this hack. Em sex., 19 de dez. de 2025 às 18:57, Kieren MacMillan < [email protected]> escreveu: > Hi Lucas, > > > Is there a way to center chords in the middle automatically? > > Maybe this will give you a place to start? > > %%% SNIPPET BEGINS > \version "2.24.4" > > \score { > << > \new ChordNames { > \chordmode { > \repeat volta 2 { > c1 c \break f1 g c > \alternative { > \volta 1 { c } > \volta 2 { g \break } > } % end alternative > } % end ritornelo > \repeat unfold 4 { c1 } > } % end chordmode > } % end ChordNames > \new Staff { > \repeat volta 2 { > s1*5 > \alternative { > \volta 1 { s1 } > \volta 2 { s1 } > } > } > s1*4 > } > >> > > \layout { > \context { > \Score { > \override VoltaBracket.vertical-skylines = ##f > \override VoltaBracket.Y-offset = #3 > } > } > \context { > \ChordNames > \override ChordName.horizontal-skylines = ##f > \override ChordName.extra-spacing-width = #empty-interval > \override ChordName.vertical-skylines = ##f > \override ChordName.extra-spacing-height = #empty-interval > \override ChordName.Y-offset = #-2 > } > } > } % end score > %%% SNIPPET ENDS > > Hope that helps! > Kieren. > __________________________________________________ > > My work day may look different than your work day. Please do not feel > obligated to read or respond to this email outside of your normal working > hours. > >
\version "2.24.4"
%%
cNote = #(define-music-function
(nota) (ly:music?)
#{
\tag #'layout {s4. { \shiftDurations 2 0 $nota } s4.}
\tag #'midi { $nota }
#})
cRest = #(define-music-function
(nota) (ly:music?)
#{
\tag #'layout { s4. r4 s4. }
\tag #'midi { $nota }
#})
makePercent =
#(define-music-function (note) (ly:music?)
"Make a percent repeat the same length as NOTE."
#{
\tag #'layout { #(make-music 'PercentEvent 'length (ly:music-length note)) }
\tag #'midi {}
#}
)
%%
repeatSlash = \markup {
\hspace #-1.5 \raise #1 \score {
\new Staff { \stopStaff \makePercent s1 }
\layout {
\context { \Score \omit TimeSignature \omit Clef }
} % fim layout
} % fim score
} % fim markup
paragraph = #(define-music-function () ()
#{\markup {\center-column {\null}} #} )
%%
\layout {
indent = 0
\context {
\Score
\omit TimeSignature
\omit Clef
\omit BarNumber
proportionalNotationDuration = #(ly:make-moment 1/4)
}
}
\header {
title = "12 Bar Blues"
tagline = \markup \magnify #0.75 "Lucas Pinke. 2025. CC 4.0 BY-SA-NC."
} % end header
\paper { ragged-last-bottom = ##f }
%%
harmony = {
\chordmode {
\set noChordSymbol = \repeatSlash
\repeat volta 4 {
\cNote c1 {\repeat unfold 3 {\cRest c }} \break
\cNote f1 \cRest f \cNote c \cRest c \break
\cNote g1 \cNote f \cNote c
\alternative {
\volta 1,3 {\cNote c}
\volta 2,4 {\cNote g \break}
}
}
}
}
%
grid = {
<<
\new StaffGroup {
\override Score.SystemStartBar.collapse-height = 1
\new OneStaff {
\new Staff {
\new ChordNames
\with {
\override ChordName.Y-offset = #-1
\override ChordName.X-offset = #0
} % fim with
{ % start ChordNames
\harmony
} % fim ChordNames
} % fim staff
} % fim OneStaff
} % fim StaffGroup
>>
}
%
\book {
\markup \vspace #3
\score { \removeWithTag #'midi \grid }
\score { \transpose c f \removeWithTag #'midi \grid }
\score { \transpose c bes, \removeWithTag #'midi \grid }
\markup \null
\score { \unfoldRepeats {\removeWithTag #'layout \harmony} \midi {\tempo 4 = 120} }
\score { \unfoldRepeats {\transpose c f {\removeWithTag #'layout \harmony} } \midi {\tempo 4 = 120} }
\score { \unfoldRepeats {\transpose c bes, {\removeWithTag #'layout \harmony} } \midi {\tempo 4 = 120} }
} % fim book
Blues.pdf
Description: Adobe PDF document
