New Retrograde plugin does not handle tpc (tonal pitch class)

• Jul 23, 2022 - 18:14
leading to potential sharp/flat errors.
Note: (I'm pretty sure that) tpc of chord notes needs to be set after addNote
EDIT: See: [#28530 Plugins cannot add chords and can add notes only in very limited ways ]


the plug in also resets the string data of Guitars etc ( if a note was on an higher fret on the 2. string the retrograde resets it to the 1. string)

Hey, all! The developer here...

I have updated the plugin to include TPC values. Accidentals should behave properly now when running the retrograde on a selection.

Let me know if it's still being weird. Hopefully it's fixed, though.


In reply to by ellejohara

The new plugin has issues with chords esp. in the lower staff. See attached.
If I select the top staff or both staves of measure 1 I get results in measures 2-3. Note no change in the bottom staff.
If I select the bottom staff of measure 1 I get results in measures 4 & a TypeError
EDIT: these problems stem in part from your changes in the 30/5/21 version. See Oldretrotest attached.
Bottom staff not changed when both selected also an issue there, but top staff is correct, and selecting the bottom staff only gives a tpc problem
EDIT2: another minor issue, but probably easy to fix, is that your code only looks at notes in voice 1, and thus leaves notes in other voices in place
EDIT3: Found the main bug affecting chords. See Lines 99,118,123 in attached. Dealing with multiple staves & voices I leave up to you.
EDIT4: found yet another bug: if the selection starts with a triplet the retro is wrong. In tripletbug attached measure 2 is the plugin applied to measure 1 content -> error; measure 4 is the plugin applied to the measure 3 content -> correct
EDIT5: another bug: if the selection is the last measure of a score the plugin says: "Nothing selected". See my comment at for an explanation and a cure.

Attachment Size
CorrectedRetrograde.qml 5.05 KB

In reply to by elsewhere

Your bugfix works to correct chord retrogrades (retrotest.mscz) and I didn't get any type errors or tpc errors with the corrected code, so I'll include that change and a credit to you in the release notes. It's still being weird with the last measure, so I'll look into that. I'll also work on fixing the triplet bug. Multiple staves and voices I'll save for later, and just make a new note in the readme that people will have to retro one voice/staff at a time.

I'll try to get a new version out before the end of the year.

In reply to by ellejohara

I notice that the notenames.qml plugin does not have the "nothing selected" problem if you select the last measure. You might find inspiration there.
EDIT: For the triplet bug , a fun fact to know might be:
"no cursor segment in tuplets"
but I don't remember where I picked this up...
EDIT2: The previous CorrectedRetrograde still has problems. In a score without chords (see test.mscz) there is one too many. Taking out line 105 & 107 solves it (see attached qml)
test.mscz (Select c-a in the right hand)
EDIT3: putting effort in allowing selection of multiple staves and voices might not be worth it, since you can select 1 stave and also 1 voice (with the F6 selection filter), and that works

Attachment Size
CorrectedRetrograde.qml 5.05 KB

Version 2.0 of New Retrograde is now available on my GitHub page. Now it can properly retrograde tuplets, multiple staves, and multiple voices. It also seems to work in MuseScore 4, though I haven't done extensive testing.

In reply to by elsewhere

There is still something wrong:
1. Run NewRetrograde on test.mscz with everything selected: left hand is not reversed.
2. Run MyRetrograde (containing the suggested fixes (if(cursor.tick == 0) cursor.rewind(1)) on test.mscz with everything selected: everything looks fine.
3. Select measures 2-4 (both staves): left hand is not reversed with NewRetrograde
4. Select measures 2-4 (both staves): left hand is reversed with MyRetrograde, but there are changes in measure 1!! (even though not selected)

Attachment Size
test.mscz 6.09 KB
MyRetrograde.qml 10.53 KB

In reply to by elsewhere

I don't remember exactly the logic behind the way I did chords. I know I've seen that newElement(Element.NOTE) somewhere on the internet. Why I didn't use it, I don't know. But since it works much better, I'll happily include your changes in the code. I'll have a look at it with fresher eyes tomorrow with my version 3 and 4 MuseScore installs, and get it updated on my GitHub page. Thanks!

In reply to by ellejohara

1. I like your approach with active tracks better than dealing with staff & voices.
2. In colornotes3.qml I found the correct approach to select-all from within the plugin. It looks weird but it works. No selection now defaults to select all (as in most plugins).
3. I implemented the notename loop inside the tracks loop.

Attachment Size
colornotes3.qml 3.46 KB
MyRetrograde3.qml 9.22 KB

Do you still have an unanswered question? Please log in first to post your question.