将AVAudioRecorder输入转换为浮点缓冲区

Max*_*olf 6 objective-c core-audio ios

对于这个问题的喧嚣提前道歉,这是我对iOS编程音频方面的第一次探索.

我正在使用AVAudioRecorder类通过麦克风录制输入,使用以下设置字典.

NSMutableDictionary *settings = [[NSMutableDictionary alloc] init];
[settings setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[settings setValue:[NSNumber numberWithFloat:11025.0] forKey:AVSampleRateKey];
[settings setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
[settings setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但是当我尝试使用echonest-codegen库来生成指纹以识别播放的音乐时,问题就出现了.

别担心,如果你以前从未使用它,基本上我必须运行这个功能:

Codegen * pCodegen = new Codegen(const float* pcm[], int number_of_samples, int samples_offset);
Run Code Online (Sandbox Code Playgroud)

const float*pcm []是样本的缓冲区.我需要将我的输入转换为"浮动缓冲区".我一直被指向ExtAudioFile文档,但它们没有多大意义.有人能指出我正确的方向吗?我完全失去了!

非常感谢!

Han*_*eTV 1

您可以使用音频队列服务轻松获取音频样本 我在这里看到的最大问题是音频缓冲区(我相信)是 char* (字节)类型,我不知道为什么您需要 float*