# How to make MIDI files to trigger Fmod instrument?

**URL:** <https://qa.fmod.com/t/how-to-make-midi-files-to-trigger-fmod-instrument/19204>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [August 29, 2022, 3:30pm UTC](https://qa.fmod.com/t/how-to-make-midi-files-to-trigger-fmod-instrument/19204 "2022-08-29T15:30:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redsheep](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@redsheep](https://qa.fmod.com/u/redsheep)\
**Post date:** [August 29, 2022, 3:30pm UTC](https://qa.fmod.com/t/how-to-make-midi-files-to-trigger-fmod-instrument/19204/1 "2022-08-29T15:30:56Z")

</div>

Hi,  
I’m currently working on a music game and just contact with Fmod for a few days. As I know, there’s no proper way for Fmod to read and use midi file information to trigger its instruments like DAW or Wwise.  
Let’s say I’m trying to create a sampler in Fmod event and the midi which is loaded in Unity will trigger the event. What should I do to make the resulting sound in the right pitch, time, velocity, and other information such as pitch bend, glide, etc… that the midi file has?  
Many thanks.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [September 5, 2022, 5:46am UTC](https://qa.fmod.com/t/how-to-make-midi-files-to-trigger-fmod-instrument/19204/2 "2022-09-05T05:46:29Z")

</div>

Just to confirm, are you trying to playback a midi file in FMOD or are you wanting to read real-time midi data and use that to play events that have been setup in FMOD Studio?  
If you want to playback a midi file in FMOD, FMOD can just playback a midi file using System.createSound and System.playSound and that will playback a midi file using general midi sounds.  
If you want to read a midi file and use that to playback events in FMOD, assuming you have a midi parser already that is going to give you midi messages at appropriate times, you could then read the values of the midi message and use that to trigger a FMOD events. Here is a list of possible operations you could perform based on midi messages:

| MIDI Message | FMOD Operation |
| --- | --- |
| Note On | EventInstance.start |
| Note Off | EventInstance.stop |
| CC 1 Modulation / Pitch Bend | EventInstance.setPitch |
| CC 7 Volume | EventInstance.setVolume |
| CC 10 Pan | EventInstance.set3DAttributes |
| Any other CC | EventInstance.setParameter and setup a corresponding parameter in FMOD Studio |

The subject of parsing real-time midi data itself is non-trivial and beyond the scope of this forum, but it looks like there are a couple of [open source projects](https://github.com/melanchall/drywetmidi) around that can achieve this.
