lilypond-user
[Top][All Lists]
Advanced

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

Re: Overwrite key signature with numbers


From: Robert Mengual
Subject: Re: Overwrite key signature with numbers
Date: Tue, 3 Oct 2023 12:55:21 +0200

Thanks a lot Valentin, that's simply perfect!

However, after reading a lot of the documentation I think I would have never been able to find any solution close to yours. I am very confused with a few things, and I can't find the answers in the documentation. Let me ask you a few questions in hope that I will be able to solve problems on my own next time.
Thank you again,
Robert

El lun, 2 oct 2023 a las 15:00, Valentin Petzel (<valentin@petzel.at>) escribió:
Hi Robert,

you could do it like this:

\version "2.23.6"

\layout {
  \context {
    \Staff
    \override KeySignature.text =
    #(lambda (grob)
       (let* ((alt (ly:grob-property grob 'alteration-alist))
              (alts (map cdr alt))
              (tot (* 2 (apply + alts)))
              (acc (cond ((= tot 0) (markup #:musicglyph
"accidentals.natural"))
                         ((> tot 0) (markup #:musicglyph "accidentals.sharp"))
                         (else (markup #:vcenter #:musicglyph
"accidentals.flat")))))
         (markup #:vcenter #:number (number->string (abs tot)) acc)))
    \override KeySignature.stencil = #ly:text-interface::print
    printKeyCancellation = ##f
  }
}

expt = { \key c \major c d e f }

{
  \clef bass
  \expt
  \transpose c cis \expt
  \transpose c des \expt
  \transpose c d \expt
  \transpose c dis \expt
  \transpose c es \expt
  \transpose c e \expt
  \transpose c f \expt
  \transpose c fis \expt
  \transpose c ges \expt
  \transpose c g \expt
  \transpose c gis \expt
  \transpose c as \expt
  \transpose c a \expt
  \transpose c ais \expt
  \transpose c bes \expt
  \transpose c b \expt
}

Cheers,
Valentin

Am Montag, 2. Oktober 2023, 14:21:37 CEST schrieb Robert Mengual:
> Hi, I am trying to overwrite the key signature for my custom music notation
> so that instead of displaying the sharp and flat icons, it shows a given
> number and the alteration. So, for example, E Major would show 4# instead
> of ####.
>
> I have been able to get the desired output by hardcodeing it using the
> markup function. However, I am not finding a way to conditionally render
> the number and alteration depending on the key. Could somebody help me?
>
> Here is my tiny hardcoded example, with a screenshot:
>
> [image: image.png]
>
> \version "2.23.6"
>
> \layout {
> \context {
> \Staff
> \override KeySignature.stencil = #ly:text-interface::print
> \override KeySignature.text = \markup {
> \combine
> \halign #-1 \lower #1 \musicglyph "four"
> \halign #-5 \musicglyph "accidentals.sharp"
> }
> }
> }
>
> \relative {
> \clef bass
> \key e \major
> cis dis e
> }


reply via email to

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