現在、ユーザー入力に基づいて MusicSequence を作成する必要があるアプリを開発しており、現在 MusicSequenceFileCreate() で -1 エラーが発生しています。-1 は MusicSequence リファレンスのエラーとしてリストされていません - OSStatus を出力するために間違った形式を使用していますか?
どんな助けでも大歓迎です!MusicSequence を .mid ファイルに保存するための参照をオンラインで見つけることができませんでした...
最後にエラーが発生します。
OSStatus status = 0;
MusicSequence newSeq;
status = NewMusicSequence(&newSeq);
if(status){
printf("Error new sequence: %ld\n", status);
status = 0;
} else {
MusicSequenceSetSequenceType(newSeq, kMusicSequenceType_Seconds);
}
MusicTrack tempoTrack;
status = MusicSequenceGetTempoTrack(newSeq, &tempoTrack);
if(status){
printf("Error getting tempo track: %ld\n", status);
status = 0;
}
status = MusicTrackNewExtendedTempoEvent(tempoTrack, 0, 120);
if(status){
printf("Error adding tempo to track: %ld\n", status);
status = 0;
}
MusicTrack thisTrack;
status = MusicSequenceNewTrack(newSeq, &thisTrack);
if(status){
printf("Error adding main track: %ld\n", status);
status = 0;
}
for(int i = 0; i<convertThis.melodyPoints.count; i++) {
MIDINoteMessage thisMessage;
thisMessage.note = thisNote.midiNoteNumber;
thisMessage.duration = thisNote.duration;
thisMessage.velocity = 120;
thisMessage.releaseVelocity = 0;
thisMessage.channel = 1;
status = MusicTrackNewMIDINoteEvent(thisTrack, thisNoteBegin, &thisMessage);
if(status){
printf("Error adding midi note: %ld\n", status);
status = 0;
}
}
NSURL *thisurl = [NSURL URLWithString:[@"~/Documents" stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mid", convertThis.title]]];
status = MusicSequenceFileCreate(newSeq, (__bridge CFURLRef) thisurl, kMusicSequenceFile_MIDIType, kMusicSequenceFileFlags_EraseFile, 0);
if(status != noErr){
printf("Error on create: %ld\n", status);
status = 0;
}