export midi with sound fonts on iOS

China☆狼群 提交于 2019-12-05 20:14:29

MIKMIDI doesn't include the ability to do this without implementing most of it yourself. That said, it is possible. In essence, you need to create your own Core Audio graph including a MIDI synthesizer unit. Then, in the render callback for the instrument unit, you pull events out of the MIKMIDISequence based on timestamps calculated using the AudioTimeStamp and number of frames passed into the render callback. You play these out to the instrument unit using MusicDeviceMIDIEvent().

You also need some way to get the synthesized output. You can do this by adding a generic output to the AU graph, adding a render callback to it, then in that render callback, taking the passed in AudioBufferList and writing it out to a file (e.g. using ExtAudioFileWrite()).

I do have a small project that does this and uses MIKMIDI, but it contains code that I can't release publicly. I'll see if I can clean it up and make it publicly releasable as example code at some point. EDIT: The project I mention here has been cleaned up and is now included as an example project with MIKMIDI. See here.

You might also consider filing a request for API or enhancements to better support this in MIKMIDI.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!