2009-12-27 13 views

Répondre

3

Oui. La façon la plus simple de le faire est d'utiliser l'API ExtAudioFile. Il y a un bon exemple dans l'exemple de code ConvertFile d'Apple. Jetez un oeil à UseExtAF.cpp.

Pour un taux d'échantillonnage de 44,1 kHz, la AudioStreamBasicDescription pour LPCM à virgule flottante 32 bits ressemblerait à ceci:

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;