Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS9 Beta and MusicTrackLoopInfo

Tags:

loops

midi

ios8

Has anyone been able to loop a MIDI file without problems on IOS9 Beta? As soon as I try to loop by setting numberOfLoops to 0 in MusicTrackLoopInfo, it locks up the app by sending random MIDI to the player. I've reported it, but am wondering if anyone has found a work around. The same code works perfectly under all other iOS versions.

MusicTrackLoopInfo loopInfo;
loopInfo.loopDuration = loopLength;
loopInfo.numberOfLoops = 0;
like image 765
Aron Nelson Avatar asked Sep 27 '22 22:09

Aron Nelson


2 Answers

OK I just heard iOS9 will ship with this bug in it. Terrible.

Here is a work around.

Don't set numberOfLoops at all, OR set numberOfLoops = 1; // means loop once Now make a variable (i.e. myVariableToKeepTrackOfAddedCopies) that keeps track of the number of times you will actually perform the following:

In your MIDIReadProc at some point BEFORE the track has finished playing, do the following:

// Copy the track to itself - effectively doubling the length
MusicTrack theTrack=nil;
MusicTrackGetProperty(theTrack, kSequenceTrackProperty_TrackLength,         &trackLen, &trackLenLen);
trackLen = 4.0; //<-- this is your real track length
MusicTrackCopyInsert(theTrack, 0, trackLen, theTrack, 0);
myVariableToKeepTrackOfAddedCopies++;

So now your track is twice as long before it ends and the track will continue. This will work the same as looping except you are taking up more memory since you are making the track length longer after each iteration.

When you stop the sequence/track, cut the track back to the original size.

MusicTrackCut(theTrack, 4.0, 4.0 +     (4.0*myVariableToKeepTrackOfAddedCopies));
MusicTrackGetProperty(theTrack, kSequenceTrackProperty_TrackLength,     &trackLen, &trackLenLen);

Irritating, but it works. I just verified on iOS9 beta 5. Hope it helps.

like image 127
Aron Nelson Avatar answered Oct 03 '22 14:10

Aron Nelson


This is fixed as of iOS release 9.2

like image 29
CJ Hanson Avatar answered Oct 03 '22 13:10

CJ Hanson