Created
September 26, 2015 09:52
-
-
Save Nikolozi/d001c11533e689587809 to your computer and use it in GitHub Desktop.
MusicSequence iOS 9 bug
This file contains hidden or 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
MusicTrack musicTrack1; | |
MusicTrack musicTrack2; | |
MusicTrack musicTrack3; | |
MusicTrack musicTrack4; | |
MusicSequence musicSequence; | |
MusicPlayer musicPlayer; | |
NewMusicSequence(&musicSequence); | |
NewMusicPlayer(&musicPlayer); | |
MusicPlayerSetSequence(musicPlayer, musicSequence); | |
MusicSequenceNewTrack(musicSequence, &musicTrack1); | |
MusicSequenceNewTrack(musicSequence, &musicTrack2); | |
MusicSequenceNewTrack(musicSequence, &musicTrack3); | |
MusicSequenceNewTrack(musicSequence, &musicTrack4); | |
MusicSequenceSetSequenceType(musicSequence, kMusicSequenceType_Beats); | |
MusicTimeStamp trackLength = 32; | |
UInt32 trackLengthSize = sizeof(MusicTimeStamp); | |
MusicTrackSetProperty(musicTrack1, kSequenceTrackProperty_TrackLength, &trackLength, trackLengthSize); | |
MusicTrackSetProperty(musicTrack2, kSequenceTrackProperty_TrackLength, &trackLength, trackLengthSize); | |
MusicTrackSetProperty(musicTrack3, kSequenceTrackProperty_TrackLength, &trackLength, trackLengthSize); | |
MusicTrackSetProperty(musicTrack4, kSequenceTrackProperty_TrackLength, &trackLength, trackLengthSize); | |
//Make it loop forever | |
MusicTrackLoopInfo loopInfo; | |
loopInfo.loopDuration = trackLength; | |
loopInfo.numberOfLoops = 0; | |
MusicTrackSetProperty(musicTrack1, kSequenceTrackProperty_LoopInfo, &loopInfo, sizeof(kSequenceTrackProperty_LoopInfo)); | |
MusicTrackSetProperty(musicTrack2, kSequenceTrackProperty_LoopInfo, &loopInfo, sizeof(kSequenceTrackProperty_LoopInfo)); | |
MusicTrackSetProperty(musicTrack3, kSequenceTrackProperty_LoopInfo, &loopInfo, sizeof(kSequenceTrackProperty_LoopInfo)); | |
MusicTrackSetProperty(musicTrack4, kSequenceTrackProperty_LoopInfo, &loopInfo, sizeof(kSequenceTrackProperty_LoopInfo)); | |
//Add Notes | |
for(int i = 0; i < 4; i++) { | |
MIDINoteMessage noteMessage; | |
noteMessage.channel = 0; | |
noteMessage.note = 66 + i; | |
noteMessage.velocity = 127; | |
noteMessage.releaseVelocity = 0; | |
noteMessage.duration = 3.0; | |
MusicTimeStamp timestamp = i * 4; | |
MusicTrackNewMIDINoteEvent(musicTrack1, timestamp, ¬eMessage); | |
} | |
for(int i = 0; i < 4; i++) { | |
MIDINoteMessage noteMessage; | |
noteMessage.channel = 0; | |
noteMessage.note = 72 + i; | |
noteMessage.velocity = 127; | |
noteMessage.releaseVelocity = 0; | |
noteMessage.duration = 2.0; | |
MusicTimeStamp timestamp = i * 4 + 1; | |
MusicTrackNewMIDINoteEvent(musicTrack2, timestamp, ¬eMessage); | |
} | |
for(int i = 0; i < 4; i++) { | |
MIDINoteMessage noteMessage; | |
noteMessage.channel = 0; | |
noteMessage.note = 62 + i; | |
noteMessage.velocity = 127; | |
noteMessage.releaseVelocity = 0; | |
noteMessage.duration = 3.0; | |
MusicTimeStamp timestamp = i * 4 + 1; | |
MusicTrackNewMIDINoteEvent(musicTrack3, timestamp, ¬eMessage); | |
} | |
for(int i = 0; i < 4; i++) { | |
MIDINoteMessage noteMessage; | |
noteMessage.channel = 0; | |
noteMessage.note = 42 + i; | |
noteMessage.velocity = 127; | |
noteMessage.releaseVelocity = 0; | |
noteMessage.duration = 2.0; | |
MusicTimeStamp timestamp = i * 4 + 3; | |
MusicTrackNewMIDINoteEvent(musicTrack4, timestamp, ¬eMessage); | |
} | |
// Launch any iOS Synth App in audio background mode and add the code back in. | |
// MIDIEndpointRef endpoint = MIDIGetDestination(1); | |
// MusicSequenceSetMIDIEndpoint(musicSequence, endpoint); | |
MusicPlayerPreroll(musicPlayer); | |
MusicPlayerStart(musicPlayer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment