Hey guys,
I have an app that sends MIDI note information to other synths on the device. Everything works fine on iPhone 5, iPod Touch and iPad mini (all running iOS 7.0.2). However, on iPhone 5S it appears MIDI data is corrupted by the time it gets delivered to a synth running in the background. The synth usually ends up playing 2-3 notes then starts making glitchy sounds and sometimes even crashes.
Anyone else experiencing the same issue? I’ve provided sample code here. It’s basically 4 bar loop playing 8 notes. Again, it works on all the devices except 5S. I tried compiling 32-bit only binaries. It didn’t help. Not sure if I’m doing something wrong or if it’s a bug on iOS.
Cheers Niko
MusicTrack musicTrack; MusicSequence musicSequence; MusicPlayer musicPlayer;
NewMusicSequence(&musicSequence); NewMusicPlayer(&musicPlayer); MusicPlayerSetSequence(musicPlayer, musicSequence); MusicSequenceNewTrack(musicSequence, &musicTrack);
MusicSequenceSetSequenceType(musicSequence, kMusicSequenceType_Beats);
MusicTimeStamp trackLength = 16; UInt32 trackLengthSize = sizeof(trackLength); MusicTrackSetProperty(musicTrack, kSequenceTrackProperty_TrackLength, &trackLength, trackLengthSize);
//Make it loop forever MusicTrackLoopInfo loopInfo; loopInfo.loopDuration = trackLength; loopInfo.numberOfLoops = 0; MusicTrackSetProperty(musicTrack, kSequenceTrackProperty_LoopInfo, &loopInfo, sizeof(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(musicTrack, 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 = 3.0; MusicTimeStamp timestamp = i * 4 + 1; MusicTrackNewMIDINoteEvent(musicTrack, timestamp, ¬eMessage); }
MIDIEndpointRef endpoint = MIDIGetDestination(1);
MusicSequenceSetMIDIEndpoint(musicSequence, endpoint);
MusicPlayerPreroll(musicPlayer); MusicPlayerStart(musicPlayer); |