Skip to content

Instantly share code, notes, and snippets.

@atomicink
Last active August 8, 2017 02:25
Show Gist options
  • Save atomicink/7e12e7c851f7d6814b57 to your computer and use it in GitHub Desktop.
Save atomicink/7e12e7c851f7d6814b57 to your computer and use it in GitHub Desktop.
Midi Music Player
#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);
}
@atomicink
Copy link
Author

iOS midi player

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment