EXEC_BAD_ACCESS(Code=1 , Address 0x0)
此代码在 Appledelegate.m 之后applicationDidFinishLaunching
。在while循环中随意随机发生(如果find事件很少,也不例外)。对不起语言,感谢任何帮助我......现在来源:
int trackindex = 14;
MusicSequenceGetIndTrack(sequence,trackindex, &track);
// Iterate throught the select track and add user event
Boolean hasNextEvent = false;
Boolean hasEvent = false;
NewMusicEventIterator(track,&iterator);
MusicEventIteratorHasCurrentEvent(iterator, &hasEvent);
MusicEventIteratorHasNextEvent(iterator, &hasNextEvent);
// loop throught track
while (hasNextEvent==true){
MusicTimeStamp timestamp = 0;
MusicEventType eventType = 0;
const void *eventData = NULL;
int note = 0;
MusicTimeStamp duration = 0;
MusicEventIteratorGetEventInfo(iterator, ×tamp, &eventType, &eventData, NULL);
if(eventType == kMusicEventType_MIDINoteMessage) {
MIDINoteMessage *noteMessage = (MIDINoteMessage *)eventData;
note = noteMessage->note;
duration = noteMessage->duration;
UserEvent event;
event.lenght = 0;
event.lenght = sizeof(UserEvent);
event.playedNote = note;
event.tStamp = timestamp;
MusicEventUserData *data = (MusicEventUserData *)&event;
MusicTrackNewUserEvent((MusicTrack)track, timestamp, data);
counter++;
printf("counter : %u\n",counter);
}
MusicEventIteratorHasNextEvent(iterator, &hasNextEvent);
MusicEventIteratorNextEvent(iterator);
}