[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding text to chord names or note names
From: |
Jean Abou Samra |
Subject: |
Re: Adding text to chord names or note names |
Date: |
Mon, 28 Nov 2022 01:22:04 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 |
Le 28/11/2022 à
01:01, Jean Abou Samra a écrit :
Le 28/11/2022 à 00:41, Koen van Walstijn a
écrit :
Hi Robin,
Thanks a lot! I read over that bar lines snippet indeed.
Adding the text engraver and tweaking it a bit, I managed to
print the markup above the chord symbol, so that definitely
helped me along and it will do for the moment.
After reading the documentation and Scheme source a bit more,
I think the cleanest solution would be to define a custom
context with a custom engraver, where it takes the markup from
a text script event and passes it to the suffix of the chord,
using the code that is already there to put it after the chord
symbol and before the optional bass note.
I discovered that with the latest development version, this
should actually not be that hard: the Chord_name_engraver
previously written in C++ has been replaced by
Chord_name_engraver and Current_chord_text_engraver written in
Scheme, with the latter handling the logic of producing the
chord symbol. Basically I'd need to cut away all the logic for
determining the chord, and tell it to listen to text script
events.
I'll let you know how it goes; would be happy to contribute
the result if it succeeds.
You can always cut away all the logic with
\version "2.22.2"
myChordNames = {
\once \override ChordName.text = \markup { C \super "6-9" }
<c e g a d'>1
}
<<
\new ChordNames \myChordNames
\new Staff \myChordNames
>>
Sorry, I was starting to forget about the "transposing" bit.
Well, how about
\version "2.22.2"
t =
#(define-music-function (text) (markup?)
#{
\once \set chordNameFunction =
#(lambda (sorted-pitches bass inversion context)
(let* ((root (first sorted-pitches))
(root-namer
(ly:context-property context 'chordRootNamer))
(root-markup (root-namer root #f))
(bass-markup
(if (ly:pitch? bass)
#{ \markup { / #(root-namer bass #f) } #}
"")))
#{ \markup { #root-markup \super #text #bass-markup }
#}))
#})
bass = \withMusicProperty bass ##t \etc
myChordNames =
\relative {
\t "6-9" c1
\t "6-9" << c \bass g >>
}
<<
\new ChordNames \myChordNames
\new ChordNames \transpose c d \myChordNames
>>
Jean
OpenPGP_signature
Description: OpenPGP digital signature
Re: Adding text to chord names or note names, Flaming Hakama by Elaine, 2022/11/29