Following up with more information. I found that the culprit is 
MusicSequenceNewTrack. What happens is, the code below is not an accurate 
representation of what I’m actually doing, I tried to simplify the example and 
end up oversimplifying. 

The problem seems to be that MusicSequenceNewTrack returns immediately and if 
you try to call MusicSequenceFileCreate right after it, the track will not be 
added to the file. If, instead you wait, let’s say 1 second and then call it, 
the track will be added to the file. Now, what’s strange is that calling CAShow 
on the sequence actually shows the track, even if you do it right after adding 
it. So, the track is there and it’s accessible, I can’t see why, 
MusicSequenceFileCreate doesn’t work.

Does anybody have any idea on how I can handle this, except for waiting for a 
certain amount of time before calling the create file function?


> On 12 Dec 2014, at 03:07, Valentin Radu <[email protected]> wrote:
> 
> Hi everybody,
> 
> 
> I’m trying to save a sequence to disk but it seems MusicSequenceFileCreate 
> doesn’t work for some reason. In the code below, there is no error thrown, 
> however, when doing a CAShow on the testSequence, I can see it's not the same 
> as the old sequence,  all the tracks are missing. The only, let’s say odd, 
> thing about the tracks is that they have a user event with some data at 
> timestamp 0. Did anyone encountered issue this before? Any pointers on why 
> this is happening? Is is a bug? 
> 
> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
>                                                              
> NSUserDomainMask, YES);
>         NSString *documentsDirectory = [paths objectAtIndex:0];
>         NSString *midiPath = [documentsDirectory
>                               stringByAppendingPathComponent:@"test.mid"];
>         NSURL* url = [[NSURL alloc] initFileURLWithPath:midiPath];
>         
>         VRC(MusicSequenceFileCreate(sequence, (__bridge CFURLRef)url, 
> kMusicSequenceFile_MIDIType, kMusicSequenceFileFlags_EraseFile, 0));
>         
>         MusicSequence testSequence;
>         VRC(NewMusicSequence(&testSequence));
>         VRC(MusicSequenceFileLoad(testSequence, (__bridge CFURLRef)url, 
> kMusicSequenceFile_MIDIType, 0));
> 
> 
> Valentin Radu
> codewisesystems.com <http://codewisesystems.com/>
> cocoaexposed.com <http://cocoaexposed.com/>
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/coreaudio-api/radu.v.valentin%40me.com
> 
> This email sent to [email protected]

Valentin Radu
codewisesystems.com <http://codewisesystems.com/>
cocoaexposed.com <http://cocoaexposed.com/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to