MIDI File Import Assistant

Started by Bavi_H, April 01, 2012, 18:59:07

Previous topic - Next topic

Bavi_H

Note: This tool is no longer required as of OpenMPT 1.27.

I made a tool that helps you import MIDI files so that notes align to rows like you want.

When opening a MIDI file, OpenMPT focuses on fitting an even number of MIDI file ticks into one module tick based on their durations in microseconds. If you want to align MIDI file notes to module rows, you have carefully plan the size of the MIDI file ticks in microseconds yourself.

The OpenMPT MIDI File Import Assistant is focused on letting you choose what MIDI file note value the module row represents. When you set the MIDI file tempo and OpenMPT MIDI file import Speed to the indicated values, the imported MIDI file notes will align to rows as you specified. The Assistant also helps you set the beat, measure, and pattern sizes to useful values, and helps you reset the module tempo to play notes at the same speed as the original MIDI file.

The OpenMPT MIDI File Import Assistant has the following requirements:
  • The MIDI file uses PPQN resolution, and you can find out the exact resolution value it uses.
  • The MIDI file notes are aligned to note values (quarter notes, eighth notes, and so on).
  • The MIDI file uses exactly one Tempo event at the very beginning, and you are able to change it to a different value to help the import process work correctly.
  • The Assistant is an HTML file that runs in your web browser.

Update Version 1.1, 2012-04-29: Added sections and headings to clarify which values are from the MIDI file and which values you choose. Added Next/Back buttons to show the calculated steps on a separate "page".

Saga Musix

Looks interesting for sure! Now if OpenMPT just had better MIDI support... :D
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Harbinger

Okay, i gave it a good try, using Anvil as my MIDI import/export application...

I've never used a web-based app before so this was brand new to me, and i wasn't sure what it would do. From your description i thought it would prepare a MIDI track for importation by MPT, but not so -- i hafta do all the work! >:(   Oh, well... :P

Once i figured where to find the info the little program needed, i followed its instructions and altered the MIDI, saved it*, and then imported it into MPT, which, for those who don't know, will transmogrify the MIDI data (not the MIDI file itself, so that's safe) into an IT-compat track. *Word to the wise: once you make your changes suggested by this MIDI Helper to the MIDI file you want to bring over to MPT, be sure to save it as another file, as you will often hafta change the tempo setting for import, meaning the MIDI file will have a new tempo.

I tried a couple of my own MIDI files assembled on a Mac with Master Tracks Pro-4, as well as third party .mid files that came from various sources. The tracks composed on Pro-4 did not retain MIDI instruments (or else Anvil couldn't read them), so i often had to fix that.

But anywho, following the instructions DID lead to a better import into MPT. There should be clearer instructions as to the "Row units" as in, "Which note length should one row in MPT represent? Enter its Units amount." or some such. But i did figure it out eventually (i'll be the first to admit i overthink things) and when i followed the instructions it seemed to always work. It is after all only a helper, and what it's helping you do is modify the tempo of the original track, then fixing MPT's MIDI Import options so it'll delineate it properly into your patterns.

So all in all, it does what it's supposed to do, and makes MIDI import 100 times easier, as it does all the calculations for you. But it is a bit clunky and with this wonderful technology, it should somehow be incorporated into MPT's GUI.

Excellent work, Bavi! ;D  We thank you!! 8)

Bavi_H

I started this project because I was frustrated that when OpenMPT opened a MIDI file, the notes didn't align to rows in any predictable way. When I searched online I couldn't find any explanation of how OpenMPT aligns MIDI file notes to rows, and only found suggestions to play around with the MIDI file import settings.

So I dug into the OpenMPT code to figure out how the the MIDI file import converts MIDI file durations into module rows. Once I understood how it works, I determined you could select a specific MIDI file tempo and import Speed setting to control what note value is assigned to a row. So I started to make an HTML file JavaScript calculator to help you choose the correct values. But I kept thinking of other things you would want to set: You want to make sure the pattern size is useful, and the measure size, and the beat size. And since you usually have to change the MIDI file tempo as part of this process, wouldn't it be helpful if you could change the module tempo back to match the original MIDI file tempo? So I added those calculations too, but this made it a bit more complicated to use. I think I'll expand the readme file with more instructions this weekend.


If OpenMPT's MIDI file import is ever eventually revised, perhaps the concept of fitting MIDI file ticks into module ticks could be abandoned. (I don't understand if that is ever useful?) In the MIDI file import settings, perhaps the Speed setting could be removed and replaced with a setting for how many MIDI file ticks to put into a row, or how many rows to put into a MIDI file quarter note.


P.S. For editing MIDI files, have you heard of Sekaiju? It has a few drawbacks (difficult to enter time signature, doesn't play notes well if you switch to another application, limited notation view), but it is better looking and more organized than Anvil Studio. (If you download Sekaiju, be sure to change the Language setting in the ini file to English.)

P.P.S. For MIDI file notation view, I like Notation Player. (The download link is at the bottom of the comparison table.)


Saga Musix

The MIDI loader will eventually be rewritten - when that is going to be, I have no idea, though. I have the MIDI import code of BeRoTracker lying around here (which allegedly works better than OpenMPT's), but it's in Delphi, so I'll have a *very* hard time translating this (if someone's both fluent with Delphi and C++... hint hint).
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Bavi_H

Quote from: Harbinger on April 05, 2012, 13:56:42There should be clearer instructions as to the "Row units" as in, "Which note length should one row in MPT represent? Enter its Units amount." or some such.

I reorganized the input boxes into sections with headings to make it more clear which values are from the MIDI file and which values you choose. You can download the updated attachment from the first post.

Rakib

I just looked at Sekaiju's page now and saw that the author have also written some libraries for midi, these are written in c++, maybe it is usable for modplug tracker?

http://openmidiproject.sourceforge.jp/index_en.html
^^

Saga Musix

Quote from: Bavi_H on April 29, 2012, 20:06:38
I reorganized the input boxes into sections with headings to make it more clear which values are from the MIDI file and which values you choose. You can download the updated attachment from the first post.
That looks a lot more intuitive and easy to use indeed.

Quote from: Rakib on April 29, 2012, 20:16:56
I just looked at Sekaiju's page now and saw that the author have also written some libraries for midi, these are written in c++, maybe it is usable for modplug tracker?
I don't really see how a few classes for processing MIDI events should help with MIDI file format support. It's not like reading the MIDI events was the tricky part of reading a MIDI file.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Saga Musix

#8
Starting from OpenMPT 1.27, this workaround will finally no longer be required.
For testing of the new MIDI import, you can download r6841 from https://buildbot.openmpt.org/builds/ (within the next few hours). Be sure to check out the new quantization options in the MIDI settings.

What has changed:
- Accurate timing by translating PPQN to module tempo.
- Support for variable tempo.
- Pitch bends are still a bit wonky but will hopefully be fixed later.
- MIDI files are imported as MPTMs to take advantage of modern tempo mode and Delay-Cut notes.
- Due to modern tempo mode being used, any other ticks/row setting than 6 will currently sound a bit weird because soundfont envelope lengths are not adjusted accordingly. This will probably be fixed later.
- OpenMPT tries to allocate up to seven channels for each MIDI channel. Sometimes this is obviously not enough, so notes may overflow into neighbouring channels. But it's still more tidy than before, I'd say. Unused channels are cleaned up after the conversion.
- Many other changes, essentially the whole loader has been rewritten and pretty much no part of the old loader has been kept.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

FreezeFlame(Alchemy)

The MIDI import is FAR better with this test build.
I loaded my old MIDI files from PianoRollComposer, and it imported them spot on.
Only thing bothering me are the missplaced note offs.
Blue Flames of the Night.

Was known as Alchemy before(with an Dialga picture).

Saga Musix

What do you mean by "misplaced"? Note-Offs are just as precisely placed as Note-Ons. If you didn't place them carefully, of course they will just show up somewhere in the pattern, which is of course more obvious with OpenMPT's rather crude default MIDI bank but less obvious with a proper MIDI synthesizer.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

FreezeFlame(Alchemy)

#11
QuoteWhat do you mean by "misplaced"?
It looks and sounds to me, as if the instruments get cut off to soon.

QuoteNote-Offs are just as precisely placed as Note-Ons. If you didn't place them carefully, of course they will just show up somewhere in the pattern, which is of course more obvious with OpenMPT's rather crude default MIDI bank but less obvious with a proper MIDI synthesizer.
Might be the case.
Blue Flames of the Night.

Was known as Alchemy before(with an Dialga picture).

Saga Musix

QuoteIt looks and sounds to me, as if the instruments gets cut off to soon.
It is the case then.
Once again I'd like to highlight here that MIDI import is not thought of as a way to listen to MIDI files. It's just thought as a first step for porting MIDI-based projects (or remix stems) to OpenMPT for further editing. MIDI import does not generate a listenable, final product.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

monsterovich

Good work. I used MIDI->Renoise->xrns2xm->OpenMPT before. :P

Saga Musix

r6847 contains a bunch of more fixes, in particular pitch bends are more accurate now. They still don't sound perfect, which again is not the goal of the importer.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.