2016-06-07 7 views
0

빠른 개요 : 저는 Mac Swift 데스크탑 오디오 응용 프로그램을 개발 중입니다. AudioFileMarkerList를 얻으려면 AudioToolbox C API를 눌러야 할 상황이 발생했습니다. 최신 AVStuff에서는이 기능이 지원되지 않는 것 같아 AudioToolbox API로 작업해야하는 것 같습니다.CoreAudio : AudioFileMarkerList를 읽는 올바른 방법은 무엇입니까?

나는이 C 구조체를 다루는 데 경험이있는 사람으로부터 듣고 싶습니다. 스위프트와 연결하는 것이 더 좋습니다. 또는 내가 빠진 사운드 파일에서 마커를 검색 할 수있는 또 다른 방법이 있다면 그 사실을 알고 싶을 것입니다.

답변

1

누구나 나중에이 문제가 발생하는 경우를 대비하여 다음과 같이 대답합니다.

// 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); 
+0

이것을 Swift로 변환 할 수있는 방법이 있습니까? 나는 일주일 동안 모든 노력을 다 했어. https://stackoverflow.com/questions/44743239/swift-retrieve-audio-file-marker-list-from-url – MysteryPancake

+0

나는 C 코드를 C로 두는 것이 합리적이라는 것을 알았다. 하지만 신속하게 작동해야합니다. 잠시 후에 곧 당신을 위해 변환 해 드리겠습니다. –

+0

감사합니다. 행운을 빌어 요. – MysteryPancake