Find and read changes in key signature
Hi! I'm not sure how a plugin could identify a change in key signature within a score. I can find the key signature of a score (curScore.keysig) and process the value. But what about key changes in a piece? Thanx!
Comments
Upon a key change you would find a segment with the segmentType of KeySig
In reply to Upon a key change you would… by jeetee
Thanks! After checking the sources again I also found cursor.keySignature, very helpful.
In reply to Upon a key change you would… by jeetee
Yes, but how can one obtain the value of the key signature from a KeySig Element?
In reply to Yes, but how can one obtain… by animikatamon
.key()
https://github.com/musescore/MuseScore/blob/3.x/libmscore/keysig.h#L58In reply to .key() https://github.com… by jeetee
Thanks, but it doesn't seem to be working in a plugin.
The lines
if (el.type == Element.KEYSIG)
console.log('>>> KeySig key = ' + el.key());
return the response
112:-1: TypeError: Property 'key' of object Ms::PluginAPI::Element(0x23673140) is not a function
In reply to .key() https://github.com… by jeetee
... and using el.key without parentheses (i.e. as a property) returns as undefined
In reply to ... and using el.key without… by animikatamon
console.log('>>> cursol.key = ' + cursor.keySignature());
returned the integer number.
In reply to console.log('>>> cursol.key … by tcbnhrs
Yes, you can access it from cursor as was mentioned above already.
You used to be able to read it from the element as well, but apparently that seems to be no longer working..
In reply to Yes, you can access it from… by jeetee
Yes, thank you.
Figured this one out by looking at the C++ code.
In reply to Yes, thank you. Figured this… by animikatamon
how can this work when I loop over segments (looping over cursor only goes over ChordRests) and want to know the keySignature at segments tick when Element.KeySig is encountered?