Note jumps and skips intervals when moved with up/down arrow keys
Reported version
3.5
Type
Plugins
Frequency
Once
Severity
S3 - Major
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project
Also: "Note pitch cannot be changed correctly by QML plugin"
The bug shows up after I run a plugin that changes a note's pitch using the pitch property. The attached animated GIF shows what happens when I select the note and press the up arrow keys. At some points, the note jumps up by a certain interval. Later in the animation, I press the down key and there are jumps as well.
What my plugin does:
onRun: {
curScore.startCmd()
applyToChordsInSelection(chord => {
let note = chord.notes[0]
let pitch = note.pitch + 2
console.log(`Changing ${note.pitch} to ${pitch}`)
console.log(`Before: tpc1 = ${note.tpc1}, tpc2 = ${note.tpc2}, pitch = ${note.pitch}`)
note.pitch = pitch
console.log(`After: tpc1 = ${note.tpc1}, tpc2 = ${note.tpc2}, pitch = ${note.pitch}`)
console.log("--------------------------------")
})
curScore.endCmd()
}
The applyToChordsInSelection
function is adopted from the colornotes sample plugin.
Steps to reproduce:
- Type a single note in MuseScore.
- Open the attached plugin in the plugin editor.
- Select the measure containing the note.
- Run the plugin.
- Confirm that the note is jumping when it is selected and the up/down arrow keys are used.
Also, the attached plugin does not reliably changes a note pitch. Changing line
or tpc*
has no effect. Changing pitch
has weird effects.
Remarks:
- The MIDI sound on moving the note up/down is correct (always in semitone steps), no matter whether the note jumps or moves correctly in semitone steps.
tpc
,tpc1
, andtpc2
are different from thepitch
, e.g. 14 instead of 60- When I save and re-open the .mscz file, the wrong behaviour is gone.
- Documentation: https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
Attachment | Size |
---|---|
Peek 2020-12-27 00-04.gif | 61.97 KB |
test.qml | 2.84 KB |
Comments
When you change pitch, you generally need to change tpc as well. Results are undefined if they are not in agreement (eg, a pitch of 60 needs a tpc of either C, B#, or Dbb).
So as far as I know there is no bug here, other than perhaps the documentation could stand to be clearer on this point?
pitch
andtpc*
are not in agreement before I run my plugin:Debug: Before: tpc = 17, tpc1 = 17, tpc2 = 17, pitch = 69
I changed my plugin to set
pitch
andtpc*
all to the same MIDI pitch value 71:The console output here is:
Yes, a more clear documentation would help. Forum posts on the topic tell that I have to change some
tpc*
but that doesn't really help.Unless I'm doing something substantially wrong in the plugin code, there are apparently some related bugs.
TPC is not supposed to the same as pitch, it's supposed to be in agreement with it. As I said, for a pitch of 60, you need to set the TPC values to either C, B#, or Dbb (probably accessed in plugins as enums, not sure how the framework exposes these). See the documentation on TPC to understand how those values work. But 60 is surely a meaningless value for TPC, as is 71.
Thank you Marc, now I understand. I overlooked the link in the documentation to the Tonal Pitch Classes: https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/tpc.h…
As far as I understand the documentation, I have to assign a number to
tpc*
. That at least works.The reason for the crash/freeze was probably that the assigned number was out of range.