Generating inversions

• Jun 10, 2012 - 23:55

Would it be possible to have a feature that generates the inversion, retrograde, and retrograde inversion of a prime? This would save a lot of time, and avoid having to copy them in by hand.

Here is a visual explanation of what I mean:

http://my.picresize.com/GVJBUA04GD

It requires some sort of feature that can generate symmetry. Would that be possible?


Comments

There is a plugin for retrograde you can install - see Plugins in the menu at right of this page. I suspect an inversion plugin could be written on the same principle.

Thank you for your reply. :)

I have had a look at the plugins page and can't see that one yet but have downloaded another one to see if I can do the process.

I can't follow the instructions.. It says I have to "uncompress it to a specific directory." I don't know what " a directory" means. I know what uncompress means but am not sure how to do that either. (I'm a beginner Ubuntu Linux user). How do I do it, please? Can someone help?

Thank you

Posercom xx

In reply to by Resopmoc

I have no Linux expertise so I can't help you there, but if someone said "folder" instead of "directory", would that help? It's a basic computer concept - a place where related files go. Like, "/users/posercom/".

Anyhow, the plugins are listed in alphabetical order. The "Retrograde" plugin is right where it belongs, with the other R's, toward the end of the list.

I've just completed a plugin that does diatonic transposing. Some bugs are left and the gui needs polishing, but it works. I can reuse most of the code for making this inversion thing. I'd imagine that an inversion plugin could work well together with my diatonic transposer.
I guess it could work something like this. You select some bars with a melodic line that you want to invert. The plugin searches for the highest and the lowest note. Then it goes through all notes and swaps them. Highest becomes lowest and vice versa. Next to highest becomes next to lowest etc, all along the diatonic scale of the present key.
After that you may want to transpose the inverted notes diatonically.

In reply to by jotti

As I explained, one way to do the inversion would be to swap the pitches so that the highest becomes the lowest and so on. This would happen all along the diatonic scale of the present key. But would it be more useful, if the swapping would be more interval perfect. Like an upward C - E - G would become a downward C - Ab - F?
Here's an image to show how I'd make it to work. Bars 1&2 is the original melody. Bars 3&4 are same inverted (I did it by hand). The notes follow the diatonic scale of D major. Bars 5&6 are bars 3&4 transposed diatonically a 4th down (I did that with my plugin).
inversions-1.png
A smaller problem is to decide what to do with accidentals. I've met the same problems when I did the diatonic transposing plugin. So far I've just ignored them and set them back to the corresponding unaltered diatonic tone.

Attachment Size
inversions-1.png 5.64 KB

In reply to by jotti

Thank you for trying to figure it out.

I am not sure what you mean about being "interval perfect" or "what to do with accidentals." To me, it's quite simple really. Everything should become a mirror image. Everything needs to be EXACTLY the opposite way round.

It's not really relevant what the notes are; just their positions. If you get the positions right, the notes will be right as well. Reflection is the only rule required for doing it manually and visually, and that's what I do when I'm doing it by eye: I just reflect things. I am afraid I have no idea how one would instruct a program to reflect something, because I don't know anything about writing software.

When doing it by eye, to generate an inversion of a prime, you copy and reflect the prime downwards (horizonally). If you can tell the program to do that, the result will be correct. To generate a retrograde, you need to tell it to write the prime backwards (reflecting the prime vertically and to the right).The retrograde inversion is the retrograde reflected UPWARDS horizontally.

I am not sure if any of this will be any help to you, though - I'm sure you've probably already grasped these concepts, but what you're trying to figure out is how to instruct the program to do them. I'm afraid I do not know.

If no one can figure it out, it doesn't matter - I shall just keep doing it by hand.

Thank you

(Note: I have changed my username. Sorry for any confusion this may cause).

In reply to by Resopmoc

My note example didn't have an interval perfect inversion, it was a diatonic inversion.

Think of an upward melody line C D E. A diatonic inversion would be downwards C B A, following the tones in a C major scale. An interval perfect inversion would be C Bb Ab, with no respect to any key. I think both diatonic and perfect inversions could be useful as plugin functions.

I haven't taken a deeper look at the accidentals, but I know it won't be easy. Think of following sequence:
retro.png
How should the first bar get inverted? Like bar 2? Or like bar 3?
Programming plugins is a bit tricky on this point. At least the way I do it. To alter one note, I change its pitch and I alter its tonal pitch class. Altering the pitch is like saying this note be number 64 (middle E). Altering the tonal pitch class is also required, because it defines whether the note is D##, E or Fb.

Attachment Size
retro.png 6.45 KB

In reply to by jotti

I'm afraid I don't know if we're talking about the same thing.

The only kind of inversions I'm interested in doing are reflections of a melody. I do not know what the terms "interval perfect inversion" and diatonic inversion" mean, but, if one of those terms refers to a reflection, that's the kind of inversion I'm interested in. If neither of them does, then we're not talking about the same thing.

Reflecting the first bar of your example prime melody downwards would produce an inverted melody of A, Ab, G, G, Gsharp, A.

Since we're reflecting downwards, the starting A in the new, reflected line needs to be ABOVE the stave - just as the starting C in the original was below it. To put it another way: since the first note of your prime is C4, the first note of the inversion needs to be A5. (See the example I linked to in the original post).

If you're trying to do a different kind of inversion, and not a reflective kind, maybe you should start a different thread about it, to avoid the two things getting confused.

Hope this helps.

In reply to by Resopmoc

The deal is, what you call "reflecting a melody" (more properly called "inversion") can be done two different ways, both of which could colloquially be called "relfecting". It's not enough to just say the reflected line needs to be above or below - the question is, *exactly how far* above or below.

In one method, you preserve the general shape of the line but the exact intervals are *modified to stay in the key*. As a very simple example, E-F-G in the key of C could be inverted to E-D-C. Three notes stepping up become three notes stepping down, all still in the key of C. This is sometimes called a diatonic inversion.

In the other type of inversion, you would note that the original line example is actually a *half* step up followed by a *whole* step up. So E-F-G would becomes E-D#-C#. Both are valid types of inversions used by composers over the centuries. E-F-G can become either E-D-C or E-D#-C# depending on whether you are trying to invert diatonically in the key of C or whether you are trying to preserving the exact intervals (this is sometimes called "real" or "chromatic" inversion).

Se depending on which type of inversion you want to do, E-F-G might be turned into E-D-C or E-D#-C#. Both are "reflections" to use a colloquial term, but they are *different* reflections. One reflects but allows intervals to vary slightly to stay within the original key, the other preserves the exact intervals but leaves the original key.

In reply to by Marc Sabatella

And I'm going to implement both ways as a plugin. The user will be able to choose between diatonic or real inversion, and also the key. The user defined key is probably required for both ways, so the plugin will know whether to use sharps or flats for the accidentals.

In reply to by jotti

..above or below to reflect?

Answer: as far as it takes to generate a mirror image.

I don't understand what you're talking about - and you don't seem to understand what I am talking about, either.

I am not concerned with modifying keys or moving things half steps up or down. That would be tampering with the original, and it wouldn't be a true reflection any more. When inverting, I am not concerned with what it sounds like. I am doing it VISUALLY. It's dead simple. I just want to generate a visual inversion, a retrograde, and a retrograde inversion from my prime. Never mind what they sound like (yet). I'm purely concerned with what they LOOK like. It's reflective symmetry. As shown here:

http://my.picresize.com/GVJBUA04GD

I've already linked to that picture in my original post, so I don't understand why the topic appears to have spiralled off into something else.

Even if what you are working on isn't what I'm talking about, I'm sure it will be of help to others, though. It's just that what you are talking about was not the topic of this thread - which is why I feel that, to avoid two separate topics getting muddled up, perhaps you should go and talk about it in a different thread instead.

Neither of the two ways you are discussing appear to involve visual reflective symmetry.

Marc, you've said:

"E-F-G can become either E-D-C or E-D#-C# depending on whether you are trying to invert diatonically in the key of C or whether you are trying to preserving the exact intervals (this is sometimes called "real" or "chromatic" inversion)"

Neither E-D-C nor E-D#-C# are valid inversions for E-F-G when using reflective symmetry of the kind that this thread is about. I think you are placing your axis of symmetry through the centre of the first note - and that is not what I am doing at all.

Assuming the E you are referring to is E4, the prime E4-F4-G4 would actually generate a symmetrical inversion of F5-E5-D5.

It is not "colloquial" to refer to this process as reflection, Marc. Rather, it is mathematical. Reflective symmetry is a mathematical concept. Mathematics has musical applications, and vice versa.There is no need to be condescending. The term "reflection" is a perfectly correct one to use. Also, you have informed me that what I referred to as "reflecting a melody" is more properly known as inversion. I already know that. Inversion is my specialist area of interest. You will note that the word inversion is in the thread title already. I wrote it down before you did, so I don't need you to tell me what it means. I may not be as knowledgeable as you about many things, but I know exactly what I am doing when it comes to symmetrical inversion. I only fell back on using the term "reflection" when trying to further explain what I meant - because you and the other person replying to me do not seem to have understood.

Do you still not understand that a pure, untampered-with inversion of E4-F4-G4 would be F5-E5-D5?

If it helps, the axis of horizontal symmetry is on the line where we write C6 (high C) in the inversion and C4 (middle C) in the prime. It is NOT through the first note.

I hope I'm getting all the numbers right for explaining the specific notes. I am not very good at those numbers yet! I keep making lots of mistakes.

As I said, if you want to carry on discussing your other kinds of inversion, feel free. But would you mind going and doing it in another thread? This thread is supposed to be about symmetrical melodic inversion with an axis of horizontal symmetry through C4 / C6 - as shown in the image linked to in the OP.

In reply to by Resopmoc

First, let's be clear: this thread is about, to use an exact quote, "a feature that generates the inversion, retrograde, and retrograde inversion of a prime". No one ever said anything until later about limiting discussing to the specific sub-case of inversions you now seem to be focusing on. So if you now want to change the discussion to only be about one specific sub-type of inversion, that's fine, but don't accuse *me* of diverting the thread. You are the one changing the subject, from inversions in general to some specific kind that you have still not clearly defined.

So, let's try again to figure out which specific type of inversion you are now saying is the only one that interests you.

Your use of mathematical terms is not helping here, because there is no standard for how they are applied to music. So I simply have no way of knowing how you intend "reflective symmetry" to apply to music - it is just not something that there is any standard for in the musical world. And worse, I think you may be fundamentally confused about what an inversion is.

You speak of an ":axis of horizontal symmetry". But inversion has nothing to do with horizontal symmetry. It is only about *vertical* symmetry. Perhaps you are being fooled by the example you linked to, which only happens to also have horizontal symmetry because it is a scale. But that horizontal symmetry is not what defines the inversion - it is the *vertical *symmetry. Each step up in the prime becomes a step down in the inversion and vice versa. Up, down - those are *vertical* concepts, not horizontal ones. A note that is N steps *above* the vertical axis of symmetry in the prime maps to a note that is N steps *below* the vertical axis, and vice versa.

So no, I don't understand that F5-E5-D5 represents "a pure untampered with inversion of E4-F4-G4", because I still don't know what you mean *musically* by those terms. Your example doesn't explain this at all. If I look at the example, I'll tell you what I see in the inversion: vertical symmetry around middle C. A note N steps above middle C in the prime maps to a note N steps below middle C in the inversion. If you take that as your standard, then an inversion of E-F-G is either A-G-F or Ab-G-F, again depending on whether you want a diatonic or real inversion. Your example shows a real one, so I guess that's what you want. In which case, the "pure untampered with inversion of E-F-G" is Ab-G-F.

In reply to by Resopmoc

I think I may have finally figured out what you are talking about. It seems you may be inverting not the music, but the *graphical representation of the music*. That's why you expected middle C below the staff to map to A above the staff - because one is written graphically as one ledger line below the staff, the other is written graphically as one ledger line above the staff. Yes?

That's not inversion - at least, not in the usual sense musicians use, and not the sense the example you posted was meant to illustrate. However, you can probably relate the concepts. As long as you promise to only write your notes in treble clef, if
you use the note half way between mid-line B and mid-line Bb (ie, a B half-flat) as your vertical axis of symmetry, then performing a real inversion around that axis should produce the visual inversion you are referring to. This is not at all what your example shows though. It shows real inversion around middle C. It only happens to also generate a visual reflection because it also changed clef from treble to bass.

In reply to by Marc Sabatella

To me that is indeed an inversion. An inversion with an axis at B4, or the third line. Now, even if we restrict the whole concept of inversions to only this special case, I still need to know what to do with accidentals. First of all, if there are no accidentals, we have the key of C major and the notes B4 C5 D5. Should they become B4 A4 G4, which would be a visual reflection? Or should they become B4 A#4 G#4, which follow the same intervals (semi-step, whole step)? If the former is what you want, we probably have a case of diatonic inversion.

I'm working on the dialog for my plugin. So far it looks like this:
dialog.png
I just added the 6th option for doing the reflection around the 3rd staff line. This will actually make it a bit tricky, since I have to read what clef the staff uses. What I have learned baout plugins is that you don't place note heads on staff lines (or ledgers or in-between), but you define pitches and diatonic tone classes. Anyway, using the option to reflect around the 3rd staff line is pretty much what Mr. Resopmoc wants.

Attachment Size
dialog.png 26.03 KB

I attach a plugin that takes C4 (middle C) as the "reflection" line and inverts the notes around it. If this is the sort of thing that you mean then it could be used as part of a larger plugin that has user-selectable values, If it isn't what you're after then I have failed to understand the gist of this thread. Note that this concept plugin is limited to 4/4 time and to concert-pitch instruments.

Attachment Size
Invert.js_.zip 1.08 KB

I am sorry if we are not understanding one another, and I'm sorry if the picture I posted was the wrong one. I had not noticed that the bottom line was in the bass clef, Marc. Thank you for pointing that out. If you can imagine it's treble clef instead, then it represents the inversions of interest to me. Yes, you do seem to have understood the type of inversion that I like. If nobody else understands (or cares about) my type of inversion, then it doesn't matter. I still do, and I can still carry on doing it by hand. And you can still carry on writing the plug-in for the kinds that other people want.

Marc, I know you like it better if I use the proper words, so I looked it up, and the official word for where we differ is apparently "pitch axis." Your pitch axis is somewhere else. Mine is middle C.

Jotti, there is definitely an axis of horizontal reflective symmetry in the inversions I speak of. I am not being "fooled" by anything. You do not understand. My inversions are literally mirror images of one another. I know because I checked. The melodic inversion of a prime with a pitch axis of middle C can be viewed by literally placing a mirror horizontally along the middle C line of the prime's printed sheet music. Also,if you place a mirror vertically along the end of the line, you will be able to view the retrograde. Then, by placing a mirror horizontally along the high C line of the retrograde, you can view the retrograde inversion. It is very interesting. At least, it is to me. I have autism, and I like certain things. Just because nobody else seems to like these type of inversions doesn't mean they aren't equally as valid or interesting to me as the kind that you happen to like are to you. You are putting your mirrors somewhere else, that's all. Perhaps your plug-in would work for different types of inversions and keep everybody happy if you could find a way to specify and vary the pitch axis required. But I do not think I will be using it. All this fuss has escalated too much now. I do not want to be involved. I will just keep quietly doing mine by hand.

P.S. I'm not a Mr. I'm a Miss.

In reply to by Resopmoc

Yes, now that we have cleared up the misunderstanding about the clef, thongs are making more sense. Your pitch axis opis middle C only if you changw the clef like they did in the example. That's fine, but it does mean your initial descriptions were incorrect. The inversion of E-FG is not F-E-D - that would be the case only if you didn't change clefs and therefore weren't using middle C as your pitch axis but are instead using, as I said, B half-flat. Using middle C as the pitch axis, E-F-G maps to A-G-F or Ab-G-F, depending on if you want diatonic or real onversion

If I take you literally, I think you might want A-G-D - surely a mirror would not add flats to notes. So notes with no accidentals would remain notes with no accidentals, would they not?

Hiwever, if that's what you mean, again, your example actually shows something else. If you look more closely, you'll see physical accidentals are not preserved. Motes with sharps in the prime may turn into notes with flats, or notes with no accidental, in the inversion. That's why it is important for you to be more clear about how you want things handled *musically* if you wish anyone to be able to answer your questions or build a plugin that would serve your needs.

BTW, regarsing the misunderstanding about axis of symmetry: you referred to horiztonal symmetry, which is a somewhat ambiguous term, especially when applied to music, I see now that you meant a horizontal *axis* of symmetry, which in musical terms reaults on *vertical* symmetry.

Anyhow, feel free to drop out of the discussion. But you did originate the thread asking abiut inversion, which is a common musical device and worthy of a plugin. If you would like any such plugin developed to meet your needs, it will behoove you to explain your needs better.

Oh dear. Maybe I've still got my explanation wrong, then. The trouble is that I know exactly what I mean, but I do not know how to explain it in all the correct posh technical terms.

Edit: never mind. Like you said, I'll just bow out of this now.

Best of luck with the plug-in

In reply to by Resopmoc

Well, I might start a new thread for this or I might continue in this thread, because lots of interestting aspects have come up in this thread. I guess you will get the best result by doing the inversion by hand. I know that when my plugin is ready and I start to use it, I'll still be correcting accidentals here and there, because no logic can fully achieve what I want in all possible cases.

It seems that there's one point, where you could place the symmetry axis so that the intervals would be perfect: At the tone D.
A mixolydian ascending scale G A B C D E F G turns beautifully into a natural A minor descending scale A G F E D C B A, where all whole steps and half steps are in order. This way you get both a diatonic and a perfect inversion. You still need a cleff, which puts D on the third staff line: the bass cleff! So this is the ultimate case, where every requirement is met. Every sharp turns into a flat and vice versa in the inversion. Looking at a keyboard helps to understand. You see the beautiful symmetry of the black keys, when you put D as the symmetry point. Ab works as well, it just throws the inverted notes into another octave.

The bass cleff is a great thing here! I happen to be very fond of instruments playing in the bass cleff range, like the cello, the bassoon and the baryton horn.

In reply to by jotti

...as I have not thought it out completely (and, if it is correct, you may have figured it out already yourself!).

(WARNING: this post is only relevant for peoples interested in developing plugins).

Anyway, while generating exact interval inversion, inverting the tpc delta too might get your accidentals right.

Example:
prime: C4 E4 F4
C4: pitch 60, tpc 14
E4: pitch 64, tpc 18 (delta pitch: +4, delta tpc: +4)
F4: pitch 65, tpc 13 (delta pitch: +1, delta tpc: -5)

inversion:
C4: pitch 60, tpc 14
?: pitch = 60 - (+4) = 56; tpc = 14 - (+4) = 10 => Ab3
?: pitch = 56 - (+1) = 55; tpc = 10 - (-5) = 15 => G3
result: C4 Ab3 G3

then add any positive or negative delta to pitch to have symmetry on an arbitrary horizontal axis. This should always get you the right accidentals. There might a special case when crossing the -1 / 33 limits of the tpc, but it should not happen as it would required triple acidentals (tpc = -2 would be Bbbb and tpc = 34 would be F###), which are outside current music practice,

For diatonic inversion, I cannot think of anything short of making a table of the tpc's of each grade of each scale (major and minor?).

HTH,

M.

P.S.: I forgot to say: a table of tpc's used by MuseScore can be found here , but you probably know of it already.

In reply to by Resopmoc

Who ever said you should bow out? We want you to explain yourself better, not bow out. But it's not about "posh technical terms". If your explanations were clear and consistent, we would be able to understand what you mean even with incorrect terminology. But unfortunately, the fact that your posted example is showing something *entirely different* from what you say you want means there is no way for us to be sure what you want. You say one thing, but show an example of something entirely different. So this is what we are trying to resolve - what you actually mean here. Using appropriate terminology makes the job easier, but the terminology is *not* the problem here - it's the contradiction between what you say you want and what you are actually using as examples.

So, as mentioned, the change in clef in your initial example means it is not inverting around mid-line B, but rather, around middle C. So, you now say you want to invert around mid-line B so the inversion will appear to be a visual reflection when staying in treble clef. Fine. But look more closely at your posted example. It is most definitely *not* a simple visual reflection. The third note of the prime is D - written in the space just below the staff. The third note of the inversion is Bb - written in in the space just above the staff (so far so good) *but with an added flat sign*. Where did that come from? Surely not from visual reflection. No, it came from the fact that your example is showing "real" inversion. D is two half steps *above* the axis of inversion (middle C), so it maps to the note two half steps *below* - Bb. That's where the flat came - *musical* considerations (number of half steps), not *visual* ones (position on the staff). So it's not about "posh technical terms". It's about realizing that the musical concept of inversion requires use of musical terms, not just visual ones, because it is *not* a purely visual phenomenon.

If you were to do a simple visual reflection of the prime, you wouldn't have any flat signs at all, since the prime didn't have any either. The first few notes C-C#-D-D# would map to A-A#-G-G#. Meaning a line that strictly ascending has now turned into one that alternates between ascending and descending. That turns out to be not an inversion at all. So if this is what you want to see - C-C#-D-D# becoming A-A#-G-G# (the result of a purely visual reflection), then it is not any kind of inversion at all, and you can forget you ever thought it would work out that way, because it won't.

However, if you actually mean to do something different with the accidentals, so that C-C#-D-D# maps to something other than A-#-G-G#, then it may indeed still turn out to be a type of inversion. Until you explain - using whatever terminology you like, as long as it is not self-contradictory - how you actually see this working, we cannot tell if what you want is a form of inversion or not.

It's a simple question with a simple yes/no answer: either what you are wanting is a form of inversion or not. Right now, you don't know enough about inversions to answer it, and we don't know enough about what you want to answer it. I think you can explain what you want a lot more easily than we can explain what inversion actually is. So, if you want the question answered - "is what you want a form of inversion or not" - then it seems we are going to be the ones who will best be able to answer it. But we won't be able to do so until you successfully explain what you want. Actual examples of what you actually want - not examples grabbed off a web site somewhere that turn out to be rather different from what you thought they were - would help.

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