Re: Key Signature name in Markup

2018-04-03 Thread brob2684
Hi Harm,

Thanks very much - what you've done is amazing!

Looks like it will be perfect for what I need.

Thanks for the help,
brob2684



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Key Signature name in Markup

2018-04-02 Thread Jacques Menu Muzhic
Hello Harm, 

Great, as usual!

Thanks!

JM

> Le 2 avr. 2018 à 16:48, Thomas Morley  a écrit :
> 
> Hi,
> 
> 2018-04-02 6:32 GMT+02:00 brob2684 :
>> Hi Harm,
>> 
>> I hadn't really thought about no key signature as being an issue, but I can
>> certainly see how it can cause confusion.
>> 
>> I think you are correct in suggesting "no key signature present" would be
>> the appropriate output, although I'll admit I'm unlikely to ever come across
>> such a case in my use of lilypond.
> 
> Well, even your first musical example has no (initial) KeySignature ;)
> 
 melody = \relative c'' {
  \time 4/4
  c1 \key d \major d \key e \major e \key f \major f
 }
> 
> For the arbitrary reuse of a variable, this variable needs to be
> defined at toplevel.
> It's possible to update such a toplevel-variable by using an engraver,
> though if you clear that variable in the engraver the value(s)/entries
> are only available _in_ the score where the engraver works.
> For multiple scores in the same file this means: if you don't clear it
> then the values will accumulate (or override themselves).
> Additionally the engraver updates it too late to have direct access to
> the new values for other toplevel-markups.
> 
> So I decided to let the key-sig-names accumulate in a toplevel-list,
> numbering them. Also, I wrote a markup-command where you need to
> select the correct entry by using a number. A markup-command is
> processed late enough.
> 
> Code attached, note the comments.
> 
> HTH,
>  Harm
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Key Signature name in Markup

2018-04-02 Thread Thomas Morley
Hi,

2018-04-02 6:32 GMT+02:00 brob2684 :
> Hi Harm,
>
> I hadn't really thought about no key signature as being an issue, but I can
> certainly see how it can cause confusion.
>
> I think you are correct in suggesting "no key signature present" would be
> the appropriate output, although I'll admit I'm unlikely to ever come across
> such a case in my use of lilypond.

Well, even your first musical example has no (initial) KeySignature ;)

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

For the arbitrary reuse of a variable, this variable needs to be
defined at toplevel.
It's possible to update such a toplevel-variable by using an engraver,
though if you clear that variable in the engraver the value(s)/entries
are only available _in_ the score where the engraver works.
For multiple scores in the same file this means: if you don't clear it
then the values will accumulate (or override themselves).
Additionally the engraver updates it too late to have direct access to
the new values for other toplevel-markups.

So I decided to let the key-sig-names accumulate in a toplevel-list,
numbering them. Also, I wrote a markup-command where you need to
select the correct entry by using a number. A markup-command is
processed late enough.

Code attached, note the comments.

HTH,
  Harm

\version "2.19.81"


 After:

 http://lsr.di.unimi.it/LSR/Item?id=856
 see also lists.gnu.org/archive/html/lilypond-user/2013-12/msg00828.html
 by Paul Morris

%% tonic-num: number of the tonic note 0-6, C=0, B=6
%% acc-type: the accidental sign type, 1/2=sharp, -1/2=flat
%% acc-count: the number and type of accidentals in the key signature
%%  values are: -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7
%%  (negative = flats, positive = sharps)
%% tonic-acc: #f if the tonic note is not sharp or flat, otherwise a pair
%% maj-num: number of the tonic note 0-6, if the key sig were major
%% mode-num: number of the mode 0-6
%% txt-size: size of key name text
%% mult: for correct resizing when the staff is resized

%% This list will be filled by the engraver and 
%% 'replace-key-sig-name'-markup-command accesses it
#(define key-signature-list '())

#(define update-key-signature-list
;; Update `key-signature-list' by a pair containing a number and `entry'
;; The numbers increase.
  (lambda (entry)
(set! key-signature-list
  (cons 
(cons (1+ (length key-signature-list)) entry)
key-signature-list

#(define (initial-moment? ctx)
  "Is current-moment the @code{ZERO-MOMENT} or before?"
  (not
(ly:momentstring arg) "key-signature-name")
(make-line-markup (assoc-get which key-signature-list (list "??")))
arg)))

\layout {
  \context {
\Staff
\consists \Store_initial_key_engraver
  }
}

%
%% EXAMPLES
%

txt =
\markuplist {
  Some text later that states that the above piece starts in key-signature-name 
  key
}

lazySpacer =
\markup \column { \vspace #1 \draw-hline }

\new Staff \relative f'' {
  \key cis \minor
  c1 d
  \key b \minor
  a1
}

\markup \replace-key-sig-name #1 \txt
\lazySpacer

\new Staff \relative f'' {
  \key gis \minor
  c1 d
  \key d \major
  a1
}

\markup \replace-key-sig-name #2 \txt
\lazySpacer

\new Staff \relative f'' {
  c1 d
  a1
}

\markup \replace-key-sig-name #3 \txt
\lazySpacer

\new Staff \relative f'' {
  \key c \major
  c1 d
  a1
}

\markup \replace-key-sig-name #4 \txt
\lazySpacer

\new Staff \relative f'' {
  \key as \major
  c1 d
  \key d \major
  a1
}

\markup \replace-key-sig-name #5 \txt
\lazySpacer
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Key Signature name in Markup

2018-04-01 Thread brob2684
Hi Harm,

I hadn't really thought about no key signature as being an issue, but I can
certainly see how it can cause confusion.

I think you are correct in suggesting "no key signature present" would be
the appropriate output, although I'll admit I'm unlikely to ever come across
such a case in my use of lilypond.

Regards,
brob


Thomas Morley-2 wrote
> 2018-04-01 22:25 GMT+02:00 brob2684 <

> bennrobertson@

> >:
>> 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 http://lsr.di.unimi.it/LSR/Item?id=856, 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
>> signature.
>>
>> 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*".
> 
> 
> 
> Hi,
> 
> thanks for clarification.
> 
> I thought a bit about it and I think it might be possible to store the
> initial key-signature-name and let TextScript get this name under
> certain conditions.
> Though, what to do if _no_ KeySignature is present?
> Could be c-major or a-minor or e-phrygian or maybe nothing of it but
> rather dodecaphonism or ...
> How to decide?
> 
> Best would be to output something like "no KeySignature present", imho.
> 
> What do you think?
> 
> 
> Cheers,
>   Harm
> 
> ___
> lilypond-user mailing list

> lilypond-user@

> https://lists.gnu.org/mailman/listinfo/lilypond-user





--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Key Signature name in Markup

2018-04-01 Thread Thomas Morley
2018-04-01 22:25 GMT+02:00 brob2684 :
> 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 http://lsr.di.unimi.it/LSR/Item?id=856, 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
> signature.
>
> 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*".



Hi,

thanks for clarification.

I thought a bit about it and I think it might be possible to store the
initial key-signature-name and let TextScript get this name under
certain conditions.
Though, what to do if _no_ KeySignature is present?
Could be c-major or a-minor or e-phrygian or maybe nothing of it but
rather dodecaphonism or ...
How to decide?

Best would be to output something like "no KeySignature present", imho.

What do you think?


Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Key Signature name in Markup

2018-04-01 Thread brob2684
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 http://lsr.di.unimi.it/LSR/Item?id=856, 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
signature.

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: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Key Signature name in Markup

2018-04-01 Thread Thomas Morley
2018-03-31 22:55 GMT+02:00 brob2684 :
> Hi,
>
> Just wondering if the following is possible or not, and am happy to be told
> it's way too complex and not to bother.
>
> 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 http://lsr.di.unimi.it/LSR/Item?id=856, 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).
>
> If anyone has some pointers, they'd be much appreciated. If I'm trying to do
> something a bit too foolish, let me know and I'll give up on that.
>
> Thanks,
> brob



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.

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Key Signature name in Markup

2018-04-01 Thread brob2684
Hi,

Just wondering if the following is possible or not, and am happy to be told
it's way too complex and not to bother.

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 http://lsr.di.unimi.it/LSR/Item?id=856, 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).

If anyone has some pointers, they'd be much appreciated. If I'm trying to do
something a bit too foolish, let me know and I'll give up on that.

Thanks,
brob



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user