Pregunta

¿Hay alguna manera usando Core Audio en Mac OS X para extraer un conjunto de fotogramas en un archivo AIFF en una matriz de 32 bits flotadores adecuado para realizar una FFT sobre?

¿Fue útil?

Solución

Sí. La forma más sencilla de hacerlo es utilizar la API ExtAudioFile. Hay un gran ejemplo en ConvertFile código de ejemplo de Apple. Echar un vistazo a UseExtAF.cpp.

Para una frecuencia de muestreo de 44,1 kHz, el AudioStreamBasicDescription de 32 bits LPCM punto flotante se vería así:

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;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top