How to play MIDI on iPhone?

As far as I know, there is no built-in or third-party library for iPhone MIDI playback. But there seem to be quite a few apps that do just that. What do they use? Any clues?

+7
iphone midi
source share
5 answers

I found this library available for licensing. Hope this helps someone else.

http://www.crimsontech.jp/eng/softsynth/

-2
source share

I wrote a tutorial on how to play MIDI using CoreMIDI via AUGraph here .

+8
source share

FYI for those who follow this road: AVMIDIPlayer was introduced in iOS 8. It seems to work well on the device, sim is not so much.

+4
source share

Check out the MusicPlayer class. Combined with the AUSampler audio device available with iOS 5.0, you can easily create a MIDI player. (The link is OS X, but it also applies to iOS)

https://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/CoreAudioOverview/ARoadmaptoCommonTasks/ARoadmaptoCommonTasks.html#//apple_ref/doc/uid/TP40003577-CH6-SW13

For an audio sampler, see: Simple Embedded MidiSynth for iOS?

+1
source share

This worked for me to play the midi file on the iPhone:

import AVFoundation class MidiPlayer: NSObject { static let shared = MidiPlayer() var musicPlayer: MusicPlayer? var sequence: MusicSequence? func play(file: String) { guard let midiFile = Bundle.main.url(forResource: file, withExtension: "mid") else { return } NewMusicPlayer(&musicPlayer) NewMusicSequence(&sequence) if let musicPlayer = musicPlayer, let sequence = sequence { MusicSequenceFileLoad(sequence, midiFile as CFURL, .midiType, MusicSequenceLoadFlags()) MusicPlayerSetSequence(musicPlayer, sequence) MusicPlayerStart(musicPlayer) } } func stop() { if let musicPlayer = musicPlayer { MusicPlayerStop(musicPlayer) } } } 

and then MidiPlayer.shared.play(file: "midifile")

0
source share

All Articles