问题
Does anyone know if there is a free/cheap MIDI player/synthesizer library that I can incorporate into my iPhone application?
As I understand it the iPhone doesn't have native support for MIDI playback.
To work around this limitation I've created a bank of .caf sound samples that I playback myself but I'd really like to improve the implementation and use MIDI if possible.
Any advice would be greatly appreciated.
回答1:
Since 10 october of 2011, that is since iOS5, Apple has started delivering basic API for midi files playback. The API is called MusicPlayer along with MusicSequence Check this out :
https://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/MusicPlayerServices_Reference/Reference/reference.html#//apple_ref/doc/uid/TP40009301-CH1-SW1
By setting up an appropriate Audio Unit Processing Graph you can output the sound you like.
回答2:
Look at TiMidity++; it looks like something that should be portable to the iPhone platform.
TiMidity++ is a software synthesizer. It can play MIDI files by converting them into PCM waveform data; give it a MIDI data along with digital instrument data files, then it synthesizes them in real-time, and plays. It can not only play sounds, but also can save the generated waveforms into hard disks as various audio file formats. TiMidity++ is a free software, distributed under the terms of GNU general public license.
Many people have ported TiMidity++ into various platforms; FreeBSD, NetBSD, many Linux distributions, Windows (and/or Cygwin environment), and Mac OS are known to have their own versions.
回答3:
There is a commercial library available from Crimson Technology
Crimson Technology Library
I have never used it so I can't vouch for it's quality.
回答4:
This is a library I've used for MIDI synthesis in Android: https://code.google.com/p/android-midi-lib/
Although it can't be used for iOS, I think you(and anyone who's interested) can still take a look at the implementation of the MIDI file format(i.e. how bytes are written to a .mid file) and possibly implement a MIDI library yourself.
来源:https://stackoverflow.com/questions/449057/midi-player-synthesizer-library-for-the-iphone