[Top][All Lists]

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

Re: keyAlterationOrder

From: Jean Abou Samra
Subject: Re: keyAlterationOrder
Date: Tue, 29 Dec 2020 09:56:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0


I know that the alist cannot be read with assoc, at least in its simple

Why not?

assoc would read the first key of a given value none of the others keys of
the same value would be read in the chain.
It is at best a stretch to call this property an association list to begin with. An alist is a list of key-value pairs; but this property is a list of step-alteration pairs with no associative semantics. To use this list, you need only filter it to the items you are interested in, and the resulting list will have the items in the desired order. Consider this contrived example:
\version "2.20.0"

\new Voice {
  #(lambda (context)
    (let ((keyAlterationOrder
           (ly:context-property context 'keyAlterationOrder))
          (pitches #{ \fixed c' { cis dis ees fis gis aes bes } #}))
     (set! pitches (map (lambda (pitch)
                         (cons (ly:pitch-steps pitch)
                               (ly:pitch-alteration pitch)))
                        (music-pitches pitches)))
     (format #t "\n  Unordered: ~s" pitches)
     (format #t "\n    Ordered: ~s"
       (lambda (elem) (member elem pitches))
Interpreting music...
Unordered: ((0 . 1/2) (1 . 1/2) (2 . -1/2) (3 . 1/2) (4 . 1/2) (5 . -1/2) (6 . -1/2)) Ordered: ((6 . -1/2) (2 . -1/2) (5 . -1/2) (3 . 1/2) (0 . 1/2) (4 . 1/2) (1 . 1/2))

Converted from (step . alteration) back to pitch, the final order is: Bb Eb Ab F# C# G# D#. This should make sense given the standard convention of how flats and sharps are arranged.

You are right indeed, it cannot really be called an alist
and assoc is of little use. Thanks for the example.

I think you misunderstood Carl. The order of the alist is the
critical piece of information. This property controls the order
in which alterations are printed in the key. For example:

I originally thought it did; but i can not see the logic by studying the two examples above

Aaron's reply should answer that.

One question though,   Does the key signature affect the midi output?
Yes, Key_performer generates a key signature meta event (FF 59).

Absolutely. Note that in MIDI, key signatures are limited to
a number of flats or sharps and a boolean representing major
or minor scale [1]. So the MIDI output is unaffected by



reply via email to

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