Plugins cannot add chords and can add notes only in very limited ways

• Feb 28, 2019 - 10:18
Reported version
3.0
Type
Plugins
Frequency
Once
Severity
S3 - Major
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

The problem came up in #283179: (some of the) missing objects/properties in the plugin framework in this post by Bacchushlg and currently affects all 3.x versions of MuseScore.

A plugin cannot add chords (i.e. more than one note at the same time).

A plugin can currently only add notes using Cursor.addNote, which has several problems. I created a simple demonstration plugin to show these:

  1. The TPC cannot be set immediately. So adding a D flat major scale looks like this
    AddNotesNoTPC.png
  2. Using a second pass (or rewinding the cursor after addNote and advancing to where it was) can give the correct result. However, this doesn't work for transposing instruments. For a Clarinet in Bb we get this when in concert pitch view:
    AddNotesClarConcertP.png
  3. This clarinet part now has this in transposed view (concert pitch off):
    AddNotesClarTransposed.png
    The TPCs now no longer match but worse yet, the notes are just wrong (although they play back the same as the transposed view – a major second higher than shown).
Attachment Size
testAddNote.qml 1.54 KB

Comments

Hi heuchi. I was having the same problem, and your fix worked for the first note of a chord. I am using the AddChord plugin. But I can't get it to work for the other notes of the chord.
chord[i].note.tpc (and variations) is not valid: 109:-1: TypeError: Cannot read property 'note' of undefined.
Any suggestions?