lilypond-user
[Top][All Lists]
Advanced

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

Re: Adding a root note next to the key signature (like a single note Amb


From: Lukas-Fabian Moser
Subject: Re: Adding a root note next to the key signature (like a single note Ambitus)
Date: Wed, 6 Jul 2022 09:07:08 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1


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
}

reply via email to

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