Last active
August 8, 2017 02:25
-
-
Save atomicink/7e12e7c851f7d6814b57 to your computer and use it in GitHub Desktop.
Midi Music Player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AudioToolbox/AudioToolbox.h> | |
@interface MidiPlayer : UIView { | |
MusicPlayer player; | |
MusicSequence sequence; | |
} | |
- (void)playMidi:(NSString *)path { | |
NSURL *midiUrl = [NSURL URLWithString:path]; | |
player = NULL; | |
NewMusicPlayer(&player); | |
sequence = NULL; | |
NewMusicSequence(&sequence); | |
MusicSequenceFileLoad(sequence, (__bridge CFURLRef)midiUrl, 0, 0); | |
MusicPlayerSetSequence(player, sequence); | |
MusicPlayerPreroll(player); | |
MusicPlayerStart(player); | |
} | |
- (void)stopMidi { | |
MusicPlayerStop(player); | |
DisposeMusicSequence(sequence); | |
DisposeMusicPlayer(player); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iOS midi player