How To Import MIDI Files In Unreal Engine 5

To import MIDI Files in Unreal Engine 5, you can use the MIDI Engine Plugin.
Unreal Engine 5 doesn’t yet feature a native way to import MIDI Files so your two options are to use a plugin or write one yourself in C++. We will briefly cover what you need to do to write a MIDI File importer in Unreal Engine 5 but we recommend you try our MIDI Engine plugin.

Prerequisites

The skillsets you need to write your own MIDI importer. 

  1. Be Efficient in C++
  2. Be comfortable with UE5 C++ API.
  3. Understand Modules and Plugin Development for unreal engine.
  4. Understand UFactory
  5. Understand MIDI messages and the structure of a MIDI File.

Parse MIDI Files In C++

We don’t like to re-invent the wheel so we are going to straightaway recommend you find an existing C++ Library than can read/write MIDI files and makes it easy to work with. The MIDI Standard gets COMPLICATED. Reading/Writing MIDI files from scratch in C++ is not recommended.

 

So we used a 3rd party library to parse MIDI files for our MIDI Engine: Core plugin.

Once you have found your C++ Library, you need to read and understand what its functions do, so you’re going to have to learn how to use the library itself. This means you need to find a library with good documentation.

Convert MIDI File Data To Unreal Engine Data

Now that you can parse a MIDI file, you need to pack that information in C++ classes that unreal engine can understand. That means your classes will need to be UCLASS or USTRUCT. So basically, you read the data from the MIDI File, then store the data as variables in UCLASS.

For our plugin MIDI Engine: Core, we created 3 classes:

  • UMidiAsset
  • UMidiTrack
  • UMidiNote

The MidiNotes go inside MidiTracks, and MidiTracks are packed in a MidiAsset.

What ever structure you decide for your classes, make sure you understand it fully and it’s organised because you’re going to need to read this data and play it back like we did with our MIDI Engine: Broadcasters plugin.

Save MIDI Files as UAssets

Now that you have read the data and packed it into your special classes… you need to save that to disk. Unreal Engine does this automatically but you need to assist it by using the UFactory classes and other editor-facing classes in unreal engine. If all of this seems complicated, Please see our Plugin Development Course for UE5, we cover everything from A to Z. At the end of the course you will understand Modules, Plugins, factories and more…

Conclusion

We went through the process of creating MIDI Engine so that you don’t have to. Sometimes you may have your own reasons of wrapping your own implementation. Importing the MIDI File is just the tip of the Iceberg, you will need to playback that MIDI File somehow and that’s where most of your headaches will begin. We’ve already implemented this with MIDI Engine: Broadcasters plugin and MIDI Engine Sequencer.

Our Plugins are 100% written in C++ with all the documentation and comments you and your team will need to work with or tweak. We’ll provide stellar support to your team to understand all the classes and why they were built like that.

5/5

Gamechanger plugin for notehighway rhythm games and music visualizers

5/5

Add Text and 2D UMG widgets to Level Sequences

Consider investing in some of our plugins. They might save you some time.  Also helps supports these tutorials.

Instantly get access to our plugins like Blender Curves Importer and UMG Cinematics and more when  you support us on Patreon!

 Join Us On Discord For More Daily Tips!