0
有沒有一種方法在OS X上使用Core Audio將一組AIFF文件中的幀提取到適合執行FFT的32位浮點數組中?使用Core Audio從AIFF中提取花車
有沒有一種方法在OS X上使用Core Audio將一組AIFF文件中的幀提取到適合執行FFT的32位浮點數組中?使用Core Audio從AIFF中提取花車
是的。最簡單的方法就是使用ExtAudioFile API。 Apple的ConvertFile示例代碼中有一個很好的例子。看看UseExtAF.cpp。
對於44.1kHz的採樣率,32位浮點LPCM的AudioStreamBasicDescription看起來像這樣:
AudioStreamBasicDescription fmt;
fmt.mSampleRate = 44100;
fmt.mFormatID = kAudioFormatLinearPCM;
fmt.mFormatFlags = kLinearPCMFormatFlagIsFloat;
fmt.mBitsPerChannel = sizeof(Float32) * 8;
fmt.mChannelsPerFrame = 1; // set this to 2 for stereo
fmt.mBytesPerFrame = fmt.mChannelsPerFrame * sizeof(Float32);
fmt.mFramesPerPacket = 1;
fmt.mBytesPerPacket = fmt.mFramesPerPacket * fmt.mBytesPerFrame;