# Auto Set Manipulation (... Retrograde, Inversion, etc.)

• Nov 14, 2010 - 04:42

Would it be possible to add a set of functions in MuseScore that can do tasks such as retrograde and inversion very quickly? If done well, this could make MuseScore far more advanced (though many would of course consider such functions merely gimmicks).

I'm sorry this may not sound very clear... I've been experimenting with retrograde and inversion a lot lately, but it's a real pain to do by hand. I think if it were easier, it would be extremely popular again. You can do amazing things with these.

Could you give examples of how you would like this feature to work? Like step by step instructions and what the result should be ?

I would be interested in this feature too! "Inversion" means the following:
1) arbitrarily choose a note;
2) turn ascending intervals into descending ones and vice versa.
By a mathematical point of view this corresponds to the function x->K-x, where K corresponds to the choice of the arbitrary note.
For example, "Frère Jacques" melody is C D E C C D E C E F G E F G ....
Once "inverted" with respect to C it would be: C Bb Ab C C Bb Ab C Ab G F Ab G F .....
In this case: C=0, D=2, E=4, F=5, G=7 (tempered semitones) in the original melody, whereas
C=0, Bb=-2, Ab=-4 G=-5, F=-7 tempered semitones in the "transposed" melody.

"Retrograde", instead, means "played backwards", from the last note to the first one, as in the illustration.

All the above would be quite useful for contrapunctal music.
Thank you very much.
Best wishes,

I wish I could code that well. I'm going to school for it soon, I think. Then I'll be able to help that well.

Edit: I can read code and interpret it enough to change it if that's any use. I tend to be extremely buggy though. I've never received training in any language other than html. This is my last year of highschool though, and I'll have a lot more time to explore coding, even if I choose some other major (US or Canadian school system)

The current plugin framework can't modify or remove existing notes, so it would be hard to have this kind of workflow. A possible way could be to create a new score from the selection and inversing/reversing before writing the score. Unfortunatly, it will not work with tuplets since the plugin framework can't handle them...

Sorry if this sounds dumb (and a waste of your time), but could you please briefly explain why it can't modify tuplets?

And what do you mean by inversing before writing the score? Wouldn't that still just be putting in notes one by one?

Would a plugin be capable of automating inversion/retrograde for simple notes?

In reply to by Calem Bendell_

For simple notes (no tuplet) and no voice, it's possible. The attached plugin works on a selection.
Select a couple of notes/ chords/rest on one staff and one voice without tuplet
Select Plugins -> retrograde selection and a new score will be created containing a retrograde of the select music.
It does not work with tie neither.

A short demo:

To install, copy the file in your plugin directory and rename to `retrograde.js`.

I agree than a special paste function would be better.

Attachment Size

Thanks! Really quick! Is this plugin difficult to adapt to inversion? I have tried to understand it, but with still no results...
(I cannot see where maths reaaly acts). Many thanks.
Best wishes,

It could be simpler for inversion (if again, you don't care about triplet, ties etc...). In the retrograde plugin, I put all the chords and rests of the selection in an array, then reverse the array and create a new score where I write the chords and rests.
For inversion, you could write the second score while browsing the selection.

After a bit of studying, I begin to understand the script. Could you please tell me how the "pitch" is considered?
To be more precise, here:
{
var note = new Note();
note.pitch = pitch;
};
I should change to something like:

{
var note = new Note();
note.pitch = K - pitch; (*)
};
I cannot figure, however, which kind of data should be "K" in "K-pitch" (*)
Many thanks,
best wishes,

I was so excited to use this until I realized it would only work for Linux. Is ther by any chance a mac version? I do know some basics of various programming languages but I'm not sure how to convert it manually. That or I'm being stupid and not using it right somehow.

In reply to by Ethan Holland 2

What works only in Linux? This is a 7 years old post...
Plugins work differently now in MuseScore 2.x, but still in general the same on all platforms. The retrograde plugin has never been posted to 2.x though.

In reply to by Ethan Holland 2

It's not Linux specific, but rather museScore version 1.x specific. This is a really old post and plugins got a new language in version 2. Since I don't know enough about the programming languages I don't know how difficult it would be to port it to version 2.

Hello,
as to me, I am afraid I am not able to write this plug-in either: I am a mathematician and a musician, but I have no programming skills at the moment.
I remain at your disposal for mathematical issues related to this problem. Many thanks.
Best wishes,

Maybe further explanation of this issue could help: the "inversion"/"retrograde" operations should be analogous to the "copy and paste" one, i.e.
1) first select a segment
2) copy it to the "clipboard"
3) invert or reverse the content of the clipboard
4) paste the result elsewhere in the score.
In fact no existing notes should be modified. This would help while writing canons.
So the "inversion" module should be analogous to the "transport" one but, instead of being based upon to operation x--> K+x should be based upon the operation x-->K-x. By default, the segment could be transposed by respect to its first note, since "transport" could be applied thereafter if needed.

Also, some kind of workaround could help too, e.g. the "clipoaboard" (containing a segment) being able to export/import notes in numeric format: in this case "inversion" or "reversion" could be performed by an electronic sheet and then imported again into musescore.
Many thanks.
Best wishes,