show key signature but also alterations

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

show key signature but also alterations

Frédéric
Hi,
I'm writing a scale book. I would like to have the key signature but
also an accidentals in front of each note. For example, in d \major, I
would like to print f# c# as key signature and a # in front of each f
and c.
I see 2 possibilities:
1. define a custom Key_engraver which just prints the key and do not
set the alterations.
2. define a special accidental rule that considers that the key
signature is blank

However, I was not able to do any of those.

Any idea?

Thanks,

F

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

David Kastrup
Frédéric <[hidden email]> writes:

> Hi,
> I'm writing a scale book. I would like to have the key signature but
> also an accidentals in front of each note. For example, in d \major, I
> would like to print f# c# as key signature and a # in front of each f
> and c.
> I see 2 possibilities:
> 1. define a custom Key_engraver which just prints the key and do not
> set the alterations.
> 2. define a special accidental rule that considers that the key
> signature is blank
>
> However, I was not able to do any of those.
>
> Any idea?

\fixed c'
{ \key d\major \accidentalStyle dodecaphonic
  c' d' e' f'
  cis' dis' eis' fis'
  ces' des' es' fes'
}

--
David Kastrup

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
Hi David,

> \fixed c'
> { \key d\major \accidentalStyle dodecaphonic
>   c' d' e' f'
>   cis' dis' eis' fis'
>   ces' des' es' fes'
> }


I tested that one already but I do not want the natural signs.
Thanks

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Schneidy
Hi Frédéric,
If you want to get a custom style, see Simon's here:

Otherwise you could do:

\version "2.20.0"

\fixed c' {
  \accidentalStyle dodecaphonic
  \key d\major
  c' d' e' f'
  cis' dis' eis' fis'
  ces' des' es' fes'
}

\layout {
  \context {
    \Voice
    \override Accidental.stencil =
      #(lambda (grob)
          (let ((glyph (ly:grob-property grob 'glyph-name)))
           (cond
            ((equal? glyph "accidentals.natural")
               (ly:stencil? #f))
               (else (ly:accidental-interface::print grob)))))
  }
}

HTH, Cheers,
Pierre

Le jeu. 21 mai 2020 à 11:06, Frédéric <[hidden email]> a écrit :
Hi David,

> \fixed c'
> { \key d\major \accidentalStyle dodecaphonic
>   c' d' e' f'
>   cis' dis' eis' fis'
>   ces' des' es' fes'
> }


I tested that one already but I do not want the natural signs.
Thanks

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

David Kastrup
Pierre Perol-Schneider <[hidden email]> writes:

> Hi Frédéric,
> If you want to get a custom style, see Simon's here:
> http://lilypond.1069038.n5.nabble.com/Custom-accidental-styles-td190776.html#a190788
>
> Otherwise you could do:
>
> \version "2.20.0"
>
> \fixed c' {
>   \accidentalStyle dodecaphonic
>   \key d\major
>   c' d' e' f'
>   cis' dis' eis' fis'
>   ces' des' es' fes'
> }
>
> \layout {
>   \context {
>     \Voice
>     \override Accidental.stencil =
>       #(lambda (grob)
>           (let ((glyph (ly:grob-property grob 'glyph-name)))
>            (cond
>             ((equal? glyph "accidentals.natural")
>                (ly:stencil? #f))
>                (else (ly:accidental-interface::print grob)))))
>   }
> }

Seems easier to just do

\key d\major
\set Staff.keyAlterations = #'()
\accidentalStyle dodecaphonic

Namely lie about the printed key signature.

--
David Kastrup

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

David Kastrup
David Kastrup <[hidden email]> writes:

> Pierre Perol-Schneider <[hidden email]> writes:
>
>> Hi Frédéric,
>> If you want to get a custom style, see Simon's here:
>> http://lilypond.1069038.n5.nabble.com/Custom-accidental-styles-td190776.html#a190788
>>
>> Otherwise you could do:
>>
>> \version "2.20.0"
>>
>> \fixed c' {
>>   \accidentalStyle dodecaphonic
>>   \key d\major
>>   c' d' e' f'
>>   cis' dis' eis' fis'
>>   ces' des' es' fes'
>> }
>>
>> \layout {
>>   \context {
>>     \Voice
>>     \override Accidental.stencil =
>>       #(lambda (grob)
>>           (let ((glyph (ly:grob-property grob 'glyph-name)))
>>            (cond
>>             ((equal? glyph "accidentals.natural")
>>                (ly:stencil? #f))
>>                (else (ly:accidental-interface::print grob)))))
>>   }
>> }
>
> Seems easier to just do
>
> \key d\major
> \set Staff.keyAlterations = #'()
> \accidentalStyle dodecaphonic
>
> Namely lie about the printed key signature.

Obviously not \accidentalStyle dodecaphonic though.
\accidentalStyle forget I think?

--
David Kastrup

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
> > \key d\major
> > \set Staff.keyAlterations = #'()
> > \accidentalStyle dodecaphonic
>
> Obviously not \accidentalStyle dodecaphonic though.
> \accidentalStyle forget I think?

apparently, this doesn't work:
\version "2.19.0"
\language "english"
{
  \key d \major
  \set Staff.keyAlterations = #'()
  \accidentalStyle forget
  d' e' fs' g' a' b' cs'' d''
}

The effect of \set Staff.keyAlterations = #'() seems to be the same as
\key c \major, it removes the key signature.
I would like to write my own accidental style in scheme but I'm a bit
lost about where to start.

F

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

antlists
In reply to this post by Frédéric
n 21/05/2020 07:35, Frédéric wrote:

> Hi,
> I'm writing a scale book. I would like to have the key signature but
> also an accidentals in front of each note. For example, in d \major, I
> would like to print f# c# as key signature and a # in front of each f
> and c.
> I see 2 possibilities:
> 1. define a custom Key_engraver which just prints the key and do not
> set the alterations.
> 2. define a special accidental rule that considers that the key
> signature is blank
>
> However, I was not able to do any of those.
>
> Any idea?
>
Not quite what you asked for, but pretty much what you want?

\score {
    \key bf \major
    bf? c d ef? f g a bf?
}

Is that any good?

Cheers,
Wol

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Timothy Lanfear
In reply to this post by Frédéric
On 21/05/2020 19:38, Frédéric wrote:

>>> \key d\major
>>> \set Staff.keyAlterations = #'()
>>> \accidentalStyle dodecaphonic
>> Obviously not \accidentalStyle dodecaphonic though.
>> \accidentalStyle forget I think?
> apparently, this doesn't work:
> \version "2.19.0"
> \language "english"
> {
>    \key d \major
>    \set Staff.keyAlterations = #'()
>    \accidentalStyle forget
>    d' e' fs' g' a' b' cs'' d''
> }
>
> The effect of \set Staff.keyAlterations = #'() seems to be the same as
> \key c \major, it removes the key signature.
> I would like to write my own accidental style in scheme but I'm a bit
> lost about where to start.
>
> F

\accidentalStyle teaching is close but parenthesises the accidental, so
switch off the parentheses.

\version "2.20.0"

{
   \override AccidentalCautionary.parenthesized=##f
   \accidentalStyle teaching
   \key d\major
   d'4 e' fis' g' a' b' cis'' d''
}



--
Timothy Lanfear, Bristol, UK.


Timothy Lanfear, Bristol, UK.
Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
> \accidentalStyle teaching is close but parenthesises the accidental, so
> switch off the parentheses.
>
> {
>    \override AccidentalCautionary.parenthesized=##f
>    \accidentalStyle teaching
>    \key d\major
>    d'4 e' fis' g' a' b' cis'' d''
> }

This is really good and so simple!
Thanks a lot all of you for your help.

F

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
> > {
> >    \override AccidentalCautionary.parenthesized=##f
> >    \accidentalStyle teaching
> >    \key d\major
> >    d'4 e' fis' g' a' b' cis'' d''
> > }
>
> This is really good and so simple!
> Thanks a lot all of you for your help.

Halas, my web server is under raspberry pi which has only lilypond
2.18.2. But 2.18.2 does not give a suitable output (too many natural
signs).
Try that:
\version "2.18.2"
{
  \override AccidentalCautionary.parenthesized = ##f
  \accidentalStyle teaching
  \key d \major
  d'4 fis' d' fis' d'4 fis' d' fis'
}
and you'll get a natural sign on second, third and fourth d. But it's
perfectly fine on 2.19.84.

Any possibility to install a more recent version of lilypond on
raspberry or to make it work on 2.18.2?

Thanks

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Timothy Lanfear
On 24/05/2020 20:35, Frédéric wrote:

>
> Halas, my web server is under raspberry pi which has only lilypond
> 2.18.2. But 2.18.2 does not give a suitable output (too many natural
> signs).
> Try that:
> \version "2.18.2"
> {
>    \override AccidentalCautionary.parenthesized = ##f
>    \accidentalStyle teaching
>    \key d \major
>    d'4 fis' d' fis' d'4 fis' d' fis'
> }
> and you'll get a natural sign on second, third and fourth d. But it's
> perfectly fine on 2.19.84.
>
> Any possibility to install a more recent version of lilypond on
> raspberry or to make it work on 2.18.2?
>
You could try the attached, which is the 2.20.0 source code for the
teaching accidental style (+some helper functions) with one change to
accommodate 2.18 syntax, i.e. the key signature is obtained from the
localKeySignature context property instead of localAlterations. Thus the
code does not work with Lilypond 2.20.0. Also note the override is no
longer necessary.

--
Timothy Lanfear, Bristol, UK.


teaching.ly (1K) Download Attachment
Timothy Lanfear, Bristol, UK.
Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Ignacio Lois
Maybe the simplest way to achieve this is the good old "!"

\language "english"
{
  \key d \major
  d' e' fs'! g' a' b' cs''! d''
}



On Sun, May 24, 2020 at 6:50 PM Timothy Lanfear <[hidden email]> wrote:
On 24/05/2020 20:35, Frédéric wrote:
>
> Halas, my web server is under raspberry pi which has only lilypond
> 2.18.2. But 2.18.2 does not give a suitable output (too many natural
> signs).
> Try that:
> \version "2.18.2"
> {
>    \override AccidentalCautionary.parenthesized = ##f
>    \accidentalStyle teaching
>    \key d \major
>    d'4 fis' d' fis' d'4 fis' d' fis'
> }
> and you'll get a natural sign on second, third and fourth d. But it's
> perfectly fine on 2.19.84.
>
> Any possibility to install a more recent version of lilypond on
> raspberry or to make it work on 2.18.2?
>

You could try the attached, which is the 2.20.0 source code for the
teaching accidental style (+some helper functions) with one change to
accommodate 2.18 syntax, i.e. the key signature is obtained from the
localKeySignature context property instead of localAlterations. Thus the
code does not work with Lilypond 2.20.0. Also note the override is no
longer necessary.

--
Timothy Lanfear, Bristol, UK.

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
In reply to this post by Timothy Lanfear
> You could try the attached, which is the 2.20.0 source code for the
> teaching accidental style (+some helper functions) with one change to
> accommodate 2.18 syntax, i.e. the key signature is obtained from the
> localKeySignature context property instead of localAlterations.

That's very close to what I need but look at the attached sample, the
first dis has no sharp sign!

F

teaching.ly (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
In reply to this post by Ignacio Lois
> Maybe the simplest way to achieve this is the good old "!"

You're right, that may be the easiest, in particular because I
auto-generate the score so it should be easy to add !

Reply | Threaded
Open this post in threaded view
|

Re: show key signature but also alterations

Frédéric
> > Maybe the simplest way to achieve this is the good old "!"
>
> You're right, that may be the easiest, in particular because I
> auto-generate the score so it should be easy to add !

it worked with "!". Was the easiest in the end.

Thanks to all of you.

F