[英]CoreAudio: the proper method of reading an AudioFileMarkerList?
快速概述:我正在開發Mac Swift桌面音頻應用程序。 我遇到了一種情況,該情況似乎要求我點擊AudioToolbox C api才能獲得AudioFileMarkerList。 在任何較新的AVStuff中似乎都沒有對此提供支持,因此似乎您仍然需要使用AudioToolbox API。
我很想聽聽有處理這些C結構的經驗的人,甚至更好的將它們與Swift鏈接的消息。 或者,如果還有另一種方法可以從我丟失的聲音文件中檢索標記,我也很想知道這一點。
這是答案,以防將來有人碰到這個問題。
// get size of markers property (dictionary)
UInt32 propSize;
UInt32 writable;
[EZAudioUtilities checkResult:AudioFileGetPropertyInfo( self.audioFileID,
kAudioFilePropertyMarkerList,
&propSize,
&writable)
operation:"Failed to get the size of the marker list"];
size_t length = NumBytesToNumAudioFileMarkers( propSize );
// allocate enough space for the markers.
AudioFileMarkerList markers[ length ];
if ( length > 0 ) {
// pull marker list
[EZAudioUtilities checkResult:AudioFileGetProperty( self.audioFileID,
kAudioFilePropertyMarkerList,
&propSize,
&markers)
operation:"Failed to get the markers list"];
} else {
return NULL;
}
//NSLog(@"# of markers: %d\n", markers->mNumberMarkers );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.