On Wed, 6 Jul 2022 at 08:07, Lukas-Fabian Moser <l...@gmx.de> wrote: > > Am 05.07.22 um 23:39 schrieb Lukas-Fabian Moser: > > Hi Viktor, > Am 05.07.22 um 20:17 schrieb Viktor Mastoridis: > > For educational purposes, I would like to see whether it's possible to add > a small note head after the key signature? > Like a single Ambitus note, really. > > > Why would I do it? > For example, I would like to add a (small) D note to a G-Major key > signature, suggesting that, despite the F# key indicating G-major or > E-minor scale, this piece is in D-Myxolydian mode. > > Maybe something like this? > > ... probably cleaner not to re-define key, but record the current tonic in > the KeySignature grob using an engraver. > \version "2.23.10" > > tonic_notehead_engraver = # > (lambda (ctx) > (make-engraver > (acknowledgers > ((key-signature-interface engraver grob source-engraver) > (if (eq? (grob::name grob) 'KeySignature) > (ly:grob-set-nested-property! > grob '(details tonic) (ly:context-property ctx 'tonic))))))) > > notehead_key_signature = # > (lambda (grob) > (let* > ((key-sig (ly:key-signature-interface::print grob)) > (notehead > (grob-interpret-markup grob > (markup #:tiny #:musicglyph "noteheads.s2"))) > (notehead-parens (parenthesize-stencil notehead 0.1 0.3 0 0.1)) > (tonic (assq-ref (ly:grob-property grob 'details) 'tonic)) > (tonic-position (+ (ly:pitch-steps tonic) > (ly:grob-property grob 'c0-position))) > (adjusted-tonic-position > (- (modulo (+ tonic-position 3) 7) 3))) > > (ly:stencil-combine-at-edge > key-sig X RIGHT > (ly:stencil-translate-axis notehead-parens > (/ adjusted-tonic-position 2) Y) > 0.5))) > > > \layout { > \context { > \Staff > \consists #tonic_notehead_engraver > \override KeySignature.stencil = #notehead_key_signature > } > } > > { > \key d \mixolydian > a'1 > \key a \mixolydian > 1 > \key g \mixolydian > 1 > \key g \dorian > 1 > \key c \minor > 1 > \clef bass > d1 > \break > 1 > } >
Thank you very much, Lukas-Fabian. This is precisely what I am after! Please forgive my ignorance, I have two follow-up questions: 1. How do I change the pitch of the 'root' note? I tried playing with the three numbers from "(+ tonic-position 3) 7) 3)))". But I can't understand their logic. 2. How can I remove the parenthesis? I tried but continuously broke the code:-)