[Top][All Lists]

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

Re: Key Signature name in Markup

From: brob2684
Subject: Re: Key Signature name in Markup
Date: Sun, 1 Apr 2018 13:25:01 -0700 (MST)

Thomas Morley-2 wrote
> 2018-03-31 22:55 GMT+02:00 brob2684 <

> bennrobertson@

> >:
>> Is it possible to extract the name of the first key signature in a piece
>> (single staff) after adjusting for any transposition to use in text
>> markup?
>> (e.g. looking to get the phrase "C major" if there is no key signature
>> before the first note (i.e. default key)).
>> I have come across, but have no
>> idea
>> where to even begin modifying it (some of the changes are obvious - I can
>> tell I don't need the rescaling bits, but I don't know enough
>> scheme/lilypond internals to work out how to change it to give me just
>> text).
> Hi,
> obviously I don't understand what you want.
> Could you explain why the lsr-snippet doesn't fit your needs?
> May be some (not working) pseude-code with the syntax you want to use
> may be helpful as well.

The snippet works insofar as it gives me the name of each key signature,
which is very close to what I want. However, I'm only interested in storing
the name of the first key in the piece in a variable to use in text later,
rather than displaying the name of each key when the key signature changes.

I can deduce that the last three lines of the snippet (below) are
responsible for printing the name of the key signature above the stave at
each key change. 

            (ly:grob-set-property! grob 'stencil
              (ly:stencil-combine-at-edge key-sig-stencil 1 1
                key-name-scaled padd))

What I would like to do is change this somehow to set a variable to the "key
signature name". 

I suspect what I need to do is remove the three lines above and replace them
with some sort of command that first tests whether the "key signature name"
variable been set; if yes then do nothing (to prevent overriding the
variable), else set the "key signature name" variable to the name of the key

At some later point in markup, I'd like to be able to reference the "key
signature variable", e.g.

melody = \relative c'' {
  \time 4/4
  c1 \key d \major d \key e \major e \key f \major f

\score {
    \new Staff { \melody }

\markup { Some text later that states that the first key in the piece is in
*\key_signature_name* }

and have the text say "Some text later that states that the first key in the
piece is in *C major*".

Sent from:

reply via email to

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