Feedback for plugin: Pitch and Rhythm transformer

• Sep 27, 2023 - 17:23

You can apply different transformations to pitches only, rhythm only, or both.

Transformations included:

  • Rotation forward or backward by selected step.
  • retrogradation
  • Inversion: both chromatic and diatonic, choose specific pivot or invert using outermost pitches.

I think this is better than the current new retrograde that ships with MS4, as this plugin transforms correctly any subdivision of tuplets, as well as adding the option to retrograde only pitches or only rhythm.

The inversion transform adapts the pivot note to the pitch display mode (concert pitch or score pitch) and correctly updates the tpc values for the other mode accordingly, something that the current "Mirror Notes" plugin fails to do and where it would mess up the notes in the other pitch mode.

Option for diatonic inversion is also added.

Negative harmony (which really is just an inversion type) should be added soon.

What do you guys think about the following?

  • While having all 3 transformations in a single plugin is useful if you need to test different transformations, should they be separated in 3 different plugins?
  • When applying a diatonic inversion, non-diatonic notes are mapped using there base note disregarding the accidental. ex: in key of C, D# and Db are both mapped to D and then diatonically inverted to B. Not sure if there is a better way to handle non-diatonic notes in diatonic inversion, but in any case something has to give.

Unlike pitch transformations, rhythm transformations require notes to be rewritten and thus losing any previous articulations added. If someone knows an easy fix for that and for keeping ties, please let me know. (cloning notes and adding them corrupts the score when undoing. I assume there is a bug in the api? Also i wish you could simply change the note's duration values just like you can change the tpc values. As far as i can tell note.duration is read only property)

Also, did my best to get the UI to look like MS4.

will be posting the code very soon.

Any feedback is appreciated.



In reply to by .ash86

Thank you for the upcoming exciting composing tool! The rhythm/pitch separation and the inversion options are wonderful, offering new quick ways to explore melody diatonically.

> What do you guys think about the following?
Hotkey capability's definitely useful, but I think single plugin'd be convenient enough in this case coz of the explorative nature.
The question on diatonic inversion logic is interesting, I think musicians will accept incorrect results that need further tweaking, would it good to provide option to highlight non-diatonic noteheads with color? I guess from the demo, tonality is currently determined by the first note, isn't it? Would it good to provide separate controls for pivot pitch, and tonality (scale/mode)?
Type 1: focus on tonalities, handles some commonly expected scale notes only. Melodic minor options, though seem messy coz not converted 1:1, may be more useful for the purpose of inversion. Coding all the options such as Dorian, Phrygian, double harmonic minor ... could be very tedious.
Type 2 and Type 3 show two possible logic so that all altered diatonic notes are handled.
Type 2 seems "more intuitive" aurally, I haven't think carefully about a optional quality conversion dim->aug yet.
Type 3 could be an incomplete version of Type 4 essentially? It's constructed from number+quality logic using major and minor scale notes.
... more than eat the eyes, autobots wage their battle, to destroy the ear for forces of the decepticons ...

Attachment Size
inversions1.mscz 19.4 KB

In reply to by msfp

Hi msfp. thanks for your input!

I'm adding keyboard navigation like tab, esc. tested with MS3 but not sure why this is not working with MS4. I'll search more for a solution. Did you have a specific hotkey in mind?

As for the diatonic mode, the tonality is determined by the key signature (i assume the example i posted might have given the impression that it was determined by the first note since the pivot note i chose was also the tonic). but you could choose any pivot note. Being determined by the key signature you basically don't need to map other major modes. for harmonic and melodic minor, however, would need a different mapping.

I didn't quite get what you mean in some examples but here are my thoughts:
type1: natural minor is not a problem since the tonality is calculated from the key sig. (relative keys are not a problem since they share the diatonic notes)
Did not get the melodic Up down examples.
type 2: To me it looks like a diatonic inversion about C + transpose octave up. or simply diatonic inversion about the tritone F#
type 3: chromatic inversion about C + octave transpose. or chromatic inversion about tritone F#

type 4: simply chromatic inversion about c.

For the dilemma i faced when writing the plugin is the following:
key C maj.
melody: C D D# E.
invert diatonically about C.
D#-- B# ? Bb? or simply B?
E--- A

In reply to by .ash86

edit1: changed 2,4,5 red note pitches to better depict the invalid conversion scenario, typos

> keyboard navigation

IIRC there's a musescore 4 specific bug related to keyboard navigation key handling in plugins.

> I didn't quite get what you mean

For the dilemma of non-diatonic notes in "diatonic" inversion, you summed up "but in any case something has to give" definitely a spot-on! Your solution for the dilemma (get rid of accidentals) is simple and perfect - I like to tweak them afterwards rather than remembering the plugin changed the notes according to some obscure inversion rules.
My previous post tried to explore different solutions that seems reasonable, by detouring from a coder's perspective and contemplating what musicians with theory knowledge might expect. By providing more options for users to choose from, it is possible to have more than one reasonable outcomes. Need to boarden "diatonic"(meaning Major only), and utilize tonality reasonings(includes Majors/minors/modes) however.

Example melody: C D D# E (the first C is C5)

  1. using "inversion, type 1, C Major" setting
    C B B(red) A
    because D# is not a scale note of C major, colored red for easier spotting and tweaking later on. Pretty perfect solution.

  2. using "inversion, type 1, C melodic minor UP to DOWN" setting
    C Bb Ab Ab(red)
    because D# = Eb enharmonically, which is a scale note of C melodic minor; E however is not

  3. using "inversion, type 1, C melodic minor DOWN to UP" setting
    C B A A(red)
    same as above, by offering two different settings 2 and 3, the burden of understanding the context (choosing ascending or descending) is shifted from coder to the enduser.

  4. using "inversion, type 1, C harmonic minor" setting
    C B Ab Ab(red)

  5. using "inversion, type 1, C natural minor" setting
    C Bb Ab Ab(red)

The 4 and 5 seems more logical from a coder's perspective, but the 1,2, and 3 arguably make more sense to musician working on tonal melody, after all he clicked on a "diatonic" button.
The 1-5 may not "solve" the dilemma at all, as it is not possible to create fully automatic 1:1 conversions using these logics. (I think 1 is perfectly fine, a really smart bot could also be a really dumb bot)
The 6 and 7 try to tackle 1:1, by conjuring up some kind of rules, rule obscurity (such as why is it up one octave?) is involved inevitably, output'd be doubtfully musical to a tonal ear, but they are basically the commonest reasoning.

  1. using "inversion, type 2, C Major, octave C5-6" setting, possibilty 1
    C B B# A
    because C5 D5 D#5 E5 = unison Major2nd Augmented2nd Major3rd from C5
    using conversion 1<>8 etc (numbers only) => Perfect8 Major7th Augmented7th Major6th from C5
    output => C6 B5 B#5 A5
    Note pretty weird B# = C
    This logic convert numbers only, and does not concern whether the note is in scale or non scale

  2. using "inversion, type 2, C Major, octave C5-6" setting, possibilty 2
    C B Bb A
    differ from 6: also use quality conversion for non scale note Augmented2nd => Diminished7nd
    Possible weird results using 6 and 7 such as C C# D => C Cb B

  3. using "inversion, type 3, C (combined), octave C5-6" setting
    C Bb A Ab
    because firstly, C D E = unison M2 M3 (C Major),
    using conversion 1<>8, P<>P, m<>M etc (numbers and quality) => P8 m7 m6,
    output => C6 Bb5 Ab5
    secondly, the D# = Eb = m3 (C minor)
    using conversion => M6
    output => A5
    finally combine them

the 8 utilize intervals but the result is essentially the same as chromatic inversion

In reply to by msfp

Oh i see, by Up down you meant the descending melodic minor, right? essentially just natural minor. I prefer to treat melodic minor as a full blown scale in itself (m3 M6 M7) like jazz musicians do: no distinction between ascending and descending. The result here is of course the same, as the classical descending scale is just natural minor, so invert using natural minor, which in turn is just diatonic.

> boarden "diatonic"(meaning Major only), and utilize tonality reasonings(includes Majors/minors/modes)

Major modes are already included here. The plugin lets you specify pivot notes only and not the key, which is calculated from the key sig. So if you are writing in C dorian , key sig is bb, same as Bb and the effect of inversion delivers the same result (for the same pivot note) . however that is not the case for melodic and harmonic minor as you well know. i think the mapping can be tweaked to allow for those scales.

Items 6 and 7 are exactly the dilemma i described earlier and you are absolutely right, they indeed end up with strange results, hence why i opted to just ignore the accidental. Coloring these notes is an interesting idea. I think i can add a toggle button for that . thanks :)

In reply to by .ash86

Yes it makes sense, jazzists call the two by one name.
Just a little note though - the way I see modes is that they use the same key sig (the symbol after time sig) as the Major. For example C Dorian etc use same key sig C Major (Eb Bb are notated with accidentals next to E, B note) so that one could tell it's not Bb Major at a glance, I reckon your code's definitely capable of handling the pitch transformations.

Here is the link to the project:

  • Option to color non diatonic notes in diatonic inversion is yet to be added.
  • an option to automatically get enharmonic notes might be added ( In chromatic inversion, depending on the pivot note you might get double sharps or flats. simply press J to cycle over different enharmonic versions)
  • known bug: diatonic inversion crashes only if first measure is selected. Please confirm.
  • inversion over 1-5 axis ( negative harmony) will be added in future upgrades.

Please let me know of any bugs and/or further suggestions.

In reply to by parkingb

I already have a version for 3.6. Ill upload it now. I did not know that many people still prefer 3.6 :)

The only difference in the 3x version is the Qt design part (and some javascript built in array methods that only work in 4. minor adaptation, which ill do right now) . But the code should be the same.
Please feel free to make further PRs if you find bugs, or any other adaptation you would like to add/change for 3.6

Hi. Seems your retrograde plugin ignores internal voices. But not ignoring them can cause many hassles: see the New Retrograde plugin.
EDIT: what you call inversion should be called transposition, I think. An inversion of c e g = e g c etc

In reply to by elsewhere

Hi elsewhere and thanks for checking out the plugin and having the time to send feedback.

Internal voices? I think you mean voices 2,3,4?
The plugin indeed currently works for voice 1 and ignores voices 2, 3 and 4. newRetrograde has the same limitation as well, apart from also messing up tuplets which this plugin does right. That being said, i will try to add support for other voices soon.

the word "Inversion" has many meanings and uses in music. chord inversions, like the example you mentioned is one of them. Another would be in the context of dodecaphonic tone row transformations like this plugin does (also sometimes called vertical reflection). Transposition, however, is a parallel transformation of notes by a certain interval; not what is happening here.

I'm posting an update very soon with new options and a fix for a bug that had escaped me until fairly recently; handling inversions of transposed instruments other than Bb ones!
Be sure to try it out:) i would appreciate your feedback.


New scale mapping section added with many scales and modes. Choose tonality and scale unto which selection is mapped. Mapping considers closest pitch and tpc. for example: A# is considered "closer" to A than to B, Hence more likely to achieve better mapping.

Try it out and please send me your suggestions and/or if you find any bug or question.

  • Bug fixed: Inversions with some transposed instruments were giving the wrong mapping. Fixed!
  • plugin now adapts to Mu color theme in MU4

here is a snapshot of the new Map function:
Screenshot 2023-11-01 141225.jpg

Also, could some one help me out on how to get the menu to flow over and outside the plugin dialog when open. I had to position the menu so it is confined within the dialog area, otherwise it would get clipped off.



  • now supports multiple voices and staves
  • New Map Pitch section, for mapping specific pitches. you can specify octave or all octaves, enharmonic equivalents, map to pitch at specific octave or closest pitch up or down. You can also filter/select the pitches for further manipulation (delete or change voice)


In reply to by .ash86

Hi Ash! I Love your plugin!
I was wondering if I could add custom scales in the Map Scale section.
I was taking a look at the Transformer.qml where you define the scales, but I couldn't figure out what is "tcp1" and I suppose it is important for scale mapping.

In reply to by Michele Chiusi

Thanks Michele!
Check this out for detailed explanation on tcp, tcp1, and tcp2.
Let me know if there is anything unclear in the article.

The plugin automatically calculates tcp2 from tcp1 and the instrument selected, so you don't have to worry about it.
Oh, And here is the the tcp table that youll need to define your scale…


In reply to by .ash86

Thank you! I managed to add custom scales just fine... almost!
I could add a custom scale, but then I tried to implent implement another scale mapping, with a scale used by Šostakovič, but there's something unexpected in the result.

What am I missing?

Šostakovič scale.png

(For Copy/Paste):
pitch: [-12,-10,-9,-8,-5,-3,-2],
tpc1: [14,16,11,6,15,17,12],
tpc2: null

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