Discussion:
Parenthesized second key signature
Tyler Mitchell
2018-11-29 08:56:00 UTC
Permalink
I'm trying to figure out how to add a "parenthesized" second key
signature to my music, something like this:

Loading Image...

I experimented with adding two \key commands one after the other,
but I get the error:

foo.ly:5:9: warning: Two simultaneous key-change events, junking this one

The following comes somewhat close, though there's a bit of an
undesirable gap between the two key signatures; and I can't figure
out how to increase the size of the parentheses; and I have to use
the 'second' key signature throughout to avoid a lot of unneeded
accidentals; and I wouldn't be able to use a time signature, as it
would be stuck between these two key signatures.

\version "2.18.2"

\relative c'' {
\key a \major
\once\override NoteHead.stencil = ##f
\once\override Stem.stencil = ##f
a4
% Doesn't seem to have any effect:
\override ParenthesesItem.font-size = #5
\parenthesize
\key aes \major
aes4
}

\layout { \context { \Staff printKeyCancellation = ##f \remove Time_signature_engraver } }

Any suggestions for how I should approach this?

A "stretch goal" would be to have accidentals handled automatically
in the same way, eg:

Loading Image...

But this seems a bit more involved (and unneeded, at least
initially).

Many thanks,
Tyler
Andrew Bernard
2018-11-29 13:32:34 UTC
Permalink
Hi Tyler,

Pardon my appalling kindergarten level ignorance, but what does this even
mean, to have two key sigs. together? I realise I am making a fool of
myself here!

Andrew
Post by Tyler Mitchell
I'm trying to figure out how to add a "parenthesized" second key
Mark Stephen Mrotek
2018-11-29 15:51:02 UTC
Permalink
Andrew,



Perhaps the purpose is to indicate the possibility of singing in two difference keys. Here D major and Db major.



Mark



From: lilypond-user [mailto:lilypond-user-bounces+carsonmark=***@gnu.org] On Behalf Of Andrew Bernard
Sent: Thursday, November 29, 2018 5:33 AM
To: lilypond-user Mailinglist <lilypond-***@gnu.org>
Subject: Re: Parenthesized second key signature



Hi Tyler,



Pardon my appalling kindergarten level ignorance, but what does this even mean, to have two key sigs. together? I realise I am making a fool of myself here!



Andrew





On Thu, 29 Nov 2018 at 21:57, Tyler Mitchell <***@ldx.ca <mailto:***@ldx.ca> > wrote:

I'm trying to figure out how to add a "parenthesized" second key
signature to my music, something like this:
Andrew Bernard
2018-11-30 07:14:20 UTC
Permalink
HI Mark,

Yes I note in both examples the key sigs are a semitone apart. Is this some
convention in some church music? OP, help us out. I don't even know what to
google for!

Andrew
Post by Mark Stephen Mrotek
Perhaps the purpose is to indicate the possibility of singing in two
difference keys. Here D major and Db major.
b***@centrum.is
2018-11-30 07:40:35 UTC
Permalink
Alternative key signatures like this are also used to save space in a book of musical exercises. Rather than print out the exact same think in a key a half-step away, both keys are indicated.



----- Original Message -----
Sent: Friday, November 30, 2018 7:14:20 AM
Subject: Re: Parenthesized second key signature
HI Mark,
Yes I note in both examples the key sigs are a semitone apart. Is this some
convention in some church music? OP, help us out. I don't even know what to
google for!
Andrew
On Fri, 30 Nov 2018 at 02:55, Mark Stephen Mrotek < [
Perhaps the purpose is to indicate the possibility of singing in two difference
keys. Here D major and Db major.
_______________________________________________
lilypond-user mailing list
https://lists.gnu.org/mailman/listinfo/lilypond-user
Tyler Mitchell
2018-11-30 09:30:56 UTC
Permalink
Post by Andrew Bernard
HI Mark,
Yes I note in both examples the key sigs are a semitone apart. Is this some
convention in some church music? OP, help us out. I don't even know what to
google for!
Andrew
Yes, Mark and David have it right -- it's more or less a 'hint' to
the accompanist that the piece can be played in either key. I say
'hint' because this is true whether the parenthetical key signature
is printed or not.

In my personal experience, I have only seen this in chant
accompaniments, though others here have mentioned other
possibilities.

I've often thought that the idea is to make it easier for the
singer (lower pitch) and/or the accompanist (fewer sharps or
flats), but sometimes it does neither (eg Bb Maj -> B Maj). I
suppose for some singers, higher is actually better.

The second example I gave is from here (in case you want to see
more):

http://www.ccwatershed.org/blog/2013/mar/19/1947-bragers-graduale-organ/

I don't know what the 'rules' are for when it's printed or not;
there are a number of chant accompaniments with an Eb Major key
signature which seem playable in E Major, but there was no
secondary key signature given.

(* And yes, I know chant isn't in, eg, "E Major", I'm just writing
it this way for the sake of simplicity.)

Cheers
Tyler
Tyler Mitchell
2018-11-30 09:37:23 UTC
Permalink
By the way, I don't know what this is called, properly -- I've been
using words like 'parenthesized' or 'parenthetical' or 'second' or
'secondary' key signature, but if there is a proper name for it
(and while I'm wishing, the rules for when to print it or not), I'd
like to know, too.

Tyler
David Wright
2018-12-01 22:38:29 UTC
Permalink
Post by Andrew Bernard
HI Mark,
Yes I note in both examples the key sigs are a semitone apart. Is this some
convention in some church music? OP, help us out. I don't even know what to
google for!
In my experience, the convention in church music in Britain is that
organists can transpose, to varying standards of expertise, along with
talents like playing counterpoint written on individual staves,
extemporising on Anglican chants, etc. Things that are sorely missed
over here.

Cheers,
David.
Andrew Bernard
2018-12-02 03:13:52 UTC
Permalink
Hi David,

We have a similar tradition in Australia (British colony?) in organ
playing. That's why I thought the other key sig. is redundant.

Andrew
Post by David Wright
In my experience, the convention in church music in Britain is that
organists can transpose, to varying standards of expertise, along with
talents like playing counterpoint written on individual staves,
extemporising on Anglican chants, etc. Things that are sorely missed
over here.
Shane Brandes
2018-12-02 03:30:16 UTC
Permalink
A.G.O, American guild of organists has sight transposition tests for
their certification program, but I think they only go a third from the
printed key.

regards,
Shane
Post by Andrew Bernard
Hi David,
We have a similar tradition in Australia (British colony?) in organ playing. That's why I thought the other key sig. is redundant.
Andrew
Post by David Wright
In my experience, the convention in church music in Britain is that
organists can transpose, to varying standards of expertise, along with
talents like playing counterpoint written on individual staves,
extemporising on Anglican chants, etc. Things that are sorely missed
over here.
_______________________________________________
lilypond-user mailing list
https://lists.gnu.org/mailman/listinfo/lilypond-user
David Wright
2018-11-29 16:11:30 UTC
Permalink
Post by Andrew Bernard
Hi Tyler,
Pardon my appalling kindergarten level ignorance, but what does this even
mean, to have two key sigs. together? I realise I am making a fool of
myself here!
It gives you instant transposition of a semitone. And if you're a
keyboard player who doesn't like playing in five flats, you can cheat
and pretend the piece is in two sharps (but don't tell the singers!).
Post by Andrew Bernard
Post by Tyler Mitchell
I'm trying to figure out how to add a "parenthesized" second key
Cheers,
David.
Thomas Morley
2018-11-29 21:10:16 UTC
Permalink
Post by Tyler Mitchell
I'm trying to figure out how to add a "parenthesized" second key
https://www.ldx.ca/tmp/paren-key-1.png
I experimented with adding two \key commands one after the other,
foo.ly:5:9: warning: Two simultaneous key-change events, junking this one
The following comes somewhat close, though there's a bit of an
undesirable gap between the two key signatures; and I can't figure
out how to increase the size of the parentheses; and I have to use
the 'second' key signature throughout to avoid a lot of unneeded
accidentals; and I wouldn't be able to use a time signature, as it
would be stuck between these two key signatures.
\version "2.18.2"
\relative c'' {
\key a \major
\once\override NoteHead.stencil = ##f
\once\override Stem.stencil = ##f
a4
\override ParenthesesItem.font-size = #5
\parenthesize
\key aes \major
aes4
}
\layout { \context { \Staff printKeyCancellation = ##f \remove Time_signature_engraver } }
Any suggestions for how I should approach this?
A "stretch goal" would be to have accidentals handled automatically
https://www.ldx.ca/tmp/paren-key-2.png
But this seems a bit more involved (and unneeded, at least
initially).
Many thanks,
Tyler
Hi,

I once made below (here a little lifted up):

\version "2.19.82"

alternativeKey =
#(define-music-function (p-1 p-2 scale-def)
(ly:pitch? ly:pitch? number-pair-list?)
#{
\override Staff.KeySignature.stencil =
#(lambda (grob)
(let* ((staff-space (ly:staff-symbol-staff-space grob))
(line-thickness (ly:staff-symbol-line-thickness grob))
(th line-thickness)
(default-stil (ly:key-signature-interface::print grob))
;; To avoid programming error @code{(markup #:null)} is returned if
;; the scale would not result in a printed KeySignature.
;; TODO: add the other scales: ionian, locrian etc
(stil-to-add
(grob-interpret-markup grob
(if (or (and (= (ly:pitch-notename p-2) 5)
(= (ly:pitch-alteration p-2) 0)
(eq? scale-def minor))
(and (= (ly:pitch-notename p-2) 0)
(= (ly:pitch-alteration p-2) 0)
(eq? scale-def major)))
(markup #:null)
#{
\markup
\score {
{ \key $p-2 $scale-def }
\layout {
\override Staff.TimeSignature #'stencil = ##f
\override Staff.Clef #'stencil = ##f
\override Staff.StaffSymbol #'line-count = #0
indent = 0
}
}
#})
))
(stil-to-add-x-ext (ly:stencil-extent stil-to-add X))
(stil-to-add-y-ext (ly:stencil-extent stil-to-add Y)))
(if (< 0 (interval-length stil-to-add-x-ext))
(if (or (and (= (ly:pitch-notename p-1) 5)
(= (ly:pitch-alteration p-1) 0)
(eq? scale-def minor))
(and (= (ly:pitch-notename p-1) 0)
(= (ly:pitch-alteration p-1) 0)
(eq? scale-def major)))
(bracketify-stencil
(ly:make-stencil
(ly:stencil-expr stil-to-add)
;; left bracket is to far away
;; trimmed a little
(cons
(+ (car stil-to-add-x-ext) (* 0.7 staff-space) )
(cdr stil-to-add-x-ext))
;; adjusting the top and bottom ending of the bracket
(cons
(+ (car stil-to-add-y-ext) (* 0.2 staff-space))
(- (cdr stil-to-add-y-ext) (* 0.5 staff-space))))
Y th (* 2.5 th) th)
(ly:stencil-combine-at-edge
default-stil
X
RIGHT
(bracketify-stencil
(ly:make-stencil
(ly:stencil-expr stil-to-add)
;; left bracket is to far away
;; trimmed a little
(cons
(+ (car stil-to-add-x-ext) (* 0.7 staff-space) )
(cdr stil-to-add-x-ext))
;; adjusting the top and bottom ending of the bracket
(cons
(+ (car stil-to-add-y-ext) (* 0.2 staff-space))
(- (cdr stil-to-add-y-ext) (* 0.5 staff-space))))
Y th (* 2.5 th) th)
1))
default-stil)))

\key $p-1 $scale-def
#})

%%%%%%%%%%%%%%
% EXAMPLES
%%%%%%%%%%%%%%
%%{
\relative c' {
\alternativeKey c f \major
c1
\alternativeKey b c \major
c
\alternativeKey e ees \major
c
\alternativeKey a aes \major
c
\alternativeKey d des \major
c
\alternativeKey g ges \major
c
\alternativeKey c ces \major
c
\alternativeKey ges g \major
c1
\alternativeKey des d \major
c
\alternativeKey aes a \major
c
\alternativeKey ees e \major
c
\alternativeKey bes b \major
c
\alternativeKey f fis \major
c
\alternativeKey ces cis \major
c
}

Current limitation: both keys need to use the same scale, i.e.
supported is neither something like a \minor a \major or other scales
like \dorian etc


HTH,
Harm
Tyler Mitchell
2018-11-30 08:19:41 UTC
Permalink
Hi,
[...snip...]
HTH,
Harm
Thanks, Harm, I'll give it a try, but it looks like I'll need to
get on the -devel branch first. (I quickly attempted it on 2.18.2
but it didn't work.)

I can see the general method you're using -- interesting. Hope you
won't mind if I ask some follow-up questions, once I figure out a
bit more how this works. :-)

Many thanks,
Tyler
Thomas Morley
2018-11-30 10:09:52 UTC
Permalink
Post by Tyler Mitchell
Hi,
[...snip...]
HTH,
Harm
Thanks, Harm, I'll give it a try, but it looks like I'll need to
get on the -devel branch first. (I quickly attempted it on 2.18.2
but it didn't work.)
Probably it's enough to use the music-function-default-arguments,
which can be omitted with newer versions, i.e.:

alternativeKey =
#(define-music-function (parser location p-1 p-2 scale-def)
(ly:pitch? ly:pitch? number-pair-list?)
...

Cheers,
Harm
Tyler Mitchell
2018-11-30 11:02:26 UTC
Permalink
Post by Thomas Morley
Probably it's enough to use the music-function-default-arguments,
alternativeKey =
#(define-music-function (parser location p-1 p-2 scale-def)
(ly:pitch? ly:pitch? number-pair-list?)
...
Cheers,
Harm
Thanks, that worked perfectly!

Tyler
Thomas Morley
2018-12-01 12:54:38 UTC
Permalink
Post by Tyler Mitchell
Post by Thomas Morley
Probably it's enough to use the music-function-default-arguments,
alternativeKey =
#(define-music-function (parser location p-1 p-2 scale-def)
(ly:pitch? ly:pitch? number-pair-list?)
...
Cheers,
Harm
Thanks, that worked perfectly!
Tyler
I've put a revised snippet in the LSR.
Available here:
http://lsr.di.unimi.it/LSR/Item?u=1&id=1075


Cheers,
Harm
Loading...