key-change-event listener in 2.20

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

key-change-event listener in 2.20

Maurits Lamers-2
Hi all,

I just noticed that in Lilypond 2.20 the key signature listener in my braille system doesn't get called anymore, where under 2.18.2 it does.
I added a code sample below where I show how I attach the listeners. All the other events seem to be called in the normal way. Did anything change in the mean time?

thanks

Maurits

====

\layout {
  \context {
    \Voice
    \consists #(list
         (cons 'listeners
               (list
                (cons 'tempo-change-event format-tempo)
                (cons 'rest-event format-rest)
                (cons 'note-event format-note)
                (cons 'tie-event format-tie)
                (cons 'articulation-event format-articulation)
                (cons 'text-script-event format-text)
                (cons 'slur-event format-slur)
                (cons 'phrasing-slur-event format-phrasing-slur)
                (cons 'breathing-event format-breathe)
                (cons 'key-change-event format-key-change)
                ;(cons 'dynamic-event format-dynamic)
                ;(cons 'crescendo-event format-cresc)
                ;(cons 'decrescendo-event format-decresc)
                ;(cons 'text-span-event format-textspan)
                ))
         )
  }
  \context {
    \Lyrics
    \consists #(list
      (cons 'listeners
        (list
          (cons 'lyric-event format-lyric)
          (cons 'hyphen-event format-hyphen)
        )
      )
    )
  }
}


Reply | Threaded
Open this post in threaded view
|

Re: key-change-event listener in 2.20

Aaron Hill
On 2020-08-31 8:15 am, Maurits Lamers wrote:
> Hi all,
>
> I just noticed that in Lilypond 2.20 the key signature listener in my
> braille system doesn't get called anymore, where under 2.18.2 it does.
> I added a code sample below where I show how I attach the listeners.
> All the other events seem to be called in the normal way. Did anything
> change in the mean time?

Something else must be going on, because the following works in 2.18.2
and 2.20.0:

%%%%
\version "2.18.2"

#(define (format-event engraver event)
   (let ((origin (ly:prob-property event 'origin)))
     (ly:input-message origin "found event here")))

\new Voice \with {
   % Using make-engraver macro:
   \consists
   #(lambda (context)
     (make-engraver
       (listeners
         ((key-change-event engraver event)
           (format-event engraver event)))))

   % Manually constructed:
   \consists
   #(list
     (cons 'listeners
       (list
         (cons 'key-change-event format-event))))
} { \key g \major g'2 b' | \key aes \major c''2 aes' }
%%%%


-- Aaron Hill

Reply | Threaded
Open this post in threaded view
|

Re: key-change-event listener in 2.20

Maurits Lamers-2
Hi all,

I finally figured out what goes wrong here. The issue is that I get the key signature and the last key signature from the context in the following way:

(ly:context-property (ly:translator-context engraver) 'keySignature))
(ly:context-property (ly:translator-context engraver) 'lastKeySignature))

which works in 2.14 up to 2.18. In 2.20 these properties seem to have been renamed to keyAlterations and lastKeyAlterations (according to http://lilypond.org/doc/v2.20/Documentation/internals/key_005fengraver) What would be the best way to support both 2.18 and 2.20? Is there a better / more reliable method of getting this information?

Thanks in advance!

Maurits



> Op 31 aug. 2020, om 19:31 heeft Aaron Hill <[hidden email]> het volgende geschreven:
>
> On 2020-08-31 8:15 am, Maurits Lamers wrote:
>> Hi all,
>> I just noticed that in Lilypond 2.20 the key signature listener in my
>> braille system doesn't get called anymore, where under 2.18.2 it does.
>> I added a code sample below where I show how I attach the listeners.
>> All the other events seem to be called in the normal way. Did anything
>> change in the mean time?
>
> Something else must be going on, because the following works in 2.18.2 and 2.20.0:
>
> %%%%
> \version "2.18.2"
>
> #(define (format-event engraver event)
>  (let ((origin (ly:prob-property event 'origin)))
>    (ly:input-message origin "found event here")))
>
> \new Voice \with {
>  % Using make-engraver macro:
>  \consists
>  #(lambda (context)
>    (make-engraver
>      (listeners
>        ((key-change-event engraver event)
>          (format-event engraver event)))))
>
>  % Manually constructed:
>  \consists
>  #(list
>    (cons 'listeners
>      (list
>        (cons 'key-change-event format-event))))
> } { \key g \major g'2 b' | \key aes \major c''2 aes' }
> %%%%
>
>
> -- Aaron Hill
>


Reply | Threaded
Open this post in threaded view
|

Re: key-change-event listener in 2.20

Aaron Hill
On 2020-09-03 5:03 am, Maurits Lamers wrote:

> Hi all,
>
> I finally figured out what goes wrong here. The issue is that I get
> the key signature and the last key signature from the context in the
> following way:
>
> (ly:context-property (ly:translator-context engraver) 'keySignature))
> (ly:context-property (ly:translator-context engraver)
> 'lastKeySignature))
>
> which works in 2.14 up to 2.18. In 2.20 these properties seem to have
> been renamed to keyAlterations and lastKeyAlterations (according to
> http://lilypond.org/doc/v2.20/Documentation/internals/key_005fengraver)
> What would be the best way to support both 2.18 and 2.20? Is there a
> better / more reliable method of getting this information?

You could check to see which symbol exists as a translator property:

;;;;
(define (translator-property? symbol)
   (memq symbol all-translation-properties))

;; ...

(ly:context-property
   (ly:translator-context engraver)
   (car (filter translator-property? '(keyAlterations keySignature)))
   '())
;;;;


-- Aaron Hill

Reply | Threaded
Open this post in threaded view
|

Re: key-change-event listener in 2.20

Maurits Lamers-2
From your answer I gather that getting this information this way is fine.
The other, more implicit question: has this change been overlooked when creating the changes documentation (http://lilypond.org/doc/v2.20/Documentation/changes-big-page.html)?

cheers

Maurits


> Op 3 sep. 2020, om 21:07 heeft Aaron Hill <[hidden email]> het volgende geschreven:
>
> On 2020-09-03 5:03 am, Maurits Lamers wrote:
>> Hi all,
>> I finally figured out what goes wrong here. The issue is that I get
>> the key signature and the last key signature from the context in the
>> following way:
>> (ly:context-property (ly:translator-context engraver) 'keySignature))
>> (ly:context-property (ly:translator-context engraver) 'lastKeySignature))
>> which works in 2.14 up to 2.18. In 2.20 these properties seem to have
>> been renamed to keyAlterations and lastKeyAlterations (according to
>> http://lilypond.org/doc/v2.20/Documentation/internals/key_005fengraver)
>> What would be the best way to support both 2.18 and 2.20? Is there a
>> better / more reliable method of getting this information?
>
> You could check to see which symbol exists as a translator property:
>
> ;;;;
> (define (translator-property? symbol)
>  (memq symbol all-translation-properties))
>
> ;; ...
>
> (ly:context-property
>  (ly:translator-context engraver)
>  (car (filter translator-property? '(keyAlterations keySignature)))
>  '())
> ;;;;
>
>
> -- Aaron Hill
>