Creating "retrograde" versions of existing MIDI files

Tablabroke

New member
Hi

I'm new to this forum, and have a question about manipulating existing MIDI files to create what I'm calling "retrograde" versions. All my files are solo piano, but I want to use these as material for my compositions. What I want is a version of a MIDI file that "flips" all the piano notes in the file so that they effectively play from the end to the beginning. There are two different versions of this sort of retrograde file I want to create:

1. With the Note On position of each note remaining the Note On position in the retrograde version.

2. With the Note Off position of each note becoming the Note On position in the retrograde version.

The first version will therefore preserve the attacks of each chord or series of notes in the same relative position to each other as in the original, except that the Note On point of the very last note/chord of the piece will become the Note On point for the first note/chord of the retrograde version.

The second version will create new relationships between the notes and chords that reflect when the original notes/chords were released.

Does anyone have an idea of what I'm talking about here? Can anyone suggest a creative way of doing this, without having to do it all by hand? (Is there a program or coding language in which this would be relatively easy to write a routine to convert a MIDI file automatically?

Many thanks for any suggestions!

cheers
 
You can import a midi file into Reaper. You can open this in the midi editor, then call up an action "reverse all events".

That, at least, is a start.
 
Thanks for your quick and useful reply gecko zzed. As it happens I'd recently downloaded Reaper for a trial, so after installing it, it only took me 10 minutes or so to figure out how to do what you suggested. You're right -- it's a great start!

From what I can tell by listening to the result, the Reverse function must treat the original (relative) Note Off positions as the new Note On positions, and vice versa, which is one of the things I was trying to do. But I'm also interested in another possibility, where Note On positions are held constant (relative to each other), so that notes that were originally played as chords still start at the same time, and end after the same duration as previously, but just in reverse order. I think that this should give the result a more "natural" polyphonic feel. Also, I'm not sure what Reaper did with my pedalling (perhaps it just ignored any non-note events?). In any case, if anyone has any thoughts about how to tinker further with MIDI event reversal, I'd be really glad to hear them.
 
Hello,

I don't know if you're still looking for 'solutions' to this, but anyway...

For my own purposes, I've written a program that translates a midi file into my own format, this is initially for playing, but later to allow various sorts of manipulation.

My process does not presently do anything like you are looking for, but it soon could.

At present, my file stores the note on info, and the length of the note (calculated from the note off event). I could store the note off midi time event as well. Then, my process could re-create the midi file, but starting from the end of the file and working backwards. Something could be worked out regarding those midi events that are near the start of the note, such that they could be re-applied to the end and upon 'translation' then applied as at the new beginning. Possible.

But, I'd need to know/understand quite a bit more about just what you're trying to achieve.

There may be other problems too, for example, many midi files would set things for each channel at the start, say patch, volume, and I would expect such settings would need to be at the start of the translated file (i.e. moved to the end, now beginning). Similarly, some commands might be placed just before the note events that they refer to, for example the pedal commands referred to by OP, and thee too would need to be moved to the end of the notes they refer to so that they could be at the beginning of the new file??

Geoff
 
Hi Geoff

Thanks for your reply. What I'm trying to do is experiment with harmonic/chordal and melodic sequences of notes that are in "reverse order" compared to what our ears are used to hearing in both tonal and non-tonal pieces, but where the notes and chords nevertheless connect with each other in similar ways to the original -- e.g., with legato overlaps that sound as natural in reverse order as the original notes did, staccato passages, etc. But instead of ending on (say) a ii7-V7-I progression, the piece would *begin* with the reverse of that progression (I-V7-ii7), and would then work through exactly the same sequence of notes/chords of the original piece, only in reverse order. Rhythmic patterns would therefore also be reversed.

One tricky thing would be the timing of attacks and releases of notes, as there would be no guarantee that the original release points of each note would make "good" attack points for those notes, and vice versa, in relation to creating natural-sounding phrasing (legato vs. staccato, etc.).

I have many MIDI files that capture my improvisations (both tonal and atonal and much in between), and I'm looking for new ways of using this as raw material for "MIDI composition" (i.e., where the "score" is a MIDI file that has been arrived at by a mixture of improvisation and judicious editing -- including, where musically appropriate, some of the retrograde patterns that would result from the sort of manipulation I've described.

Simply playing an audio realisation of my MIDI files backwards wouldn't do the trick, because all the attacks and decays would be in the wrong places, even though the shifts from one note or chord to the next would be approximately in the order I want.

What you've said in your reply makes sense -- most of the initial MIDI settings would need to remain the same, and pedal commands would ideally need to be shifted so they were at the same "distance" before the new attack points or notes and chords as they were before the original attack points of those notes/chords. I may not be making perfect sense here, as I'm only working with an idea so far, so the application of my thoughts might not produce the sort of musically interesting results I'm hoping for.

Any further thoughts on this would be most welcome.

Thanks
Jim
 
Jim,

Hold your horses there...

Just to clarify..

A substantial part of what you're mentioning there is nothing to do with MIDI, and cannot be controlled by MIDI. Most of the implementation of 'attack' and 'decay' is handled by the device (keyboard, sound module, whatever) that is being controlled by midi. There are some midi 'controls' that might modify (slightly) just how these things actually sound, but I'd say it's 'slightly' and nothing like what you're talking about.

As far as midi is concerned, if we turn the note off event into a note on, and the note on into the note off, then the sound made by the device will sound just the same, with the same attach/decay, unless something like 'expression' or whatever had previously been set, and was not moved to the new start.

On the basis of your last message above, I think I understand what you're getting at - seems like you're thinking along the lines of doing with midi what you might otherwise do with playing a tape recording backwards? Only midi doesn't work like that. As noted, it merely controls the device that actually makes the sounds, and that will not change!

Are you taking that into consideration?

That aside, I'd be happy to help with some sort of experiment.

The process which I already have processes a midi file into my own data file, which is a standard .DBF (dBase/Clipper). The file is indexed on the basis of the midi time. It could be easily indexed in descending order rather than ascending. And played back as such. As the data is being stored, the detail could be slightly modified to move other items around, but it would need a bit of experimentation, and would be better to start with simple files (not like some of the large, multi-part thinks like I've been playing with, i.e. complete J.M. Jarre tracks in all their synth glory!!).

Geoff
 
Hi Geoff

Thanks again for trying to grapple with what I'm suggesting. I probably expressed myself poorly in my last post. The only similarity between what I have in mind and playing a recording backwards is that the piece would start with notes that were originally at the end of the piece, and vice versa.

Perhaps the easiest thing to try first (if it's possible) would be just to turn every note event that is initially an attack into a release, and vice versa, and turn every "pedal on" event into a "pedal off" event, and vice versa (if that's possible). The only likely problem with that is that (speaking as a pianist) the times at which notes (and the sustain pedal) are released are typically less important musically than the times at which they are attacked, which means that the new chords and melodies generated by these changes won't necessarily "flow" very musically -- e.g., notes of a chord that were originally struck simultaneously but released separately (depending on which notes are being held down to create legato and which are being released to move to the next melody notes) will now have attacks that don't line up as a chord, and they will release simultaneously, which means that there won't necessarily be any legato effect where it would make musical sense. But who knows? It might still be interesting to see what it sounds like, and it might give me new ideas for ways of putting notes together that don't follow our "normal" expectations about melody and legato...

I hope I haven't made this even more confusing by my attempt to clarify things -- and thanks again for persevering with my ideas!

Jim
 
Hello Jim,

All fascinating, but also somewhat tangled.

We are in great danger of confusing each other.

You seem to be a musician/pianist, and you may well know little about midi and synthesisers. I meanwhile am a programmer with a lot of interest in midi and synths, who knows little about music (apart from listening to it) and cannot in fact play anything.

So when you talk about 'attack', you're talking about what I think of as 'note on' in midi, whereas to my mind 'attack' is part and parcel of the ADRS (Attack, Decay, Sustain, Release) - the sonic envelope of a sound within music, and within synthesis. Release and sustain probably ditto.

Further complication, you've not said anything about the instrument you're using. I suspect this may be a fairly sophisticated synth/piano, and it's midi facilities may well include some midi controllers that are not usually present in the sort of devices I'm used to.

In view of this, I'd be interested to know what your instrument is, so that I can search for it's Midi Implementation Chart. This will tell me a lot. Also, if your instrument is capable of saving a midi file (which I assume it is) I'd love to see one, so that I can check what's in there (
 
Sorry Jim,

Messed up there.

My reply was much longer, but forum seems to log me out if I take too long, and this loses part of my message.

Maybe need to go to private email??

Geoff
 
Hi Geoff

I've sent you my email address via private forum message (I hope). Meanwhile...

I've got several hours of MIDI files that I recorded on my Roland RD-500 digital piano several years ago (recorded via MIDI out into a Roland SoundCanvas SD-35 (which had a built-in 3.5 inch floppy drive for this purpose). These files are exactly as originally recorded, but I now play them back via a physically modelled digital piano called Pianoteq (https://www.pianoteq.com/). I haven't done any serious editing of the MIDI files so far, but will most likely use either Reaper or Logic Pro X when I get up to speed on one or the other of these DAWs.

You're right in thinking that my use of "attack" and "release" is a sloppy way of talking about "note on" and "note off" events -- sorry again for the confusion.

I don't seem to be able to attach .mid files here (it's not an approved file type apparently), but if we continue this discussion via email I can send you a couple of examples for you to have a look at. Please let me know if you don't get my email address via private message.

thanks
Jim
 
Back
Top