iPhone AudioQueue - 读取传入的音频数据以确定 BPM
我正在尝试使用声能从麦克风确定每分钟节拍数 (BPM),我想我已经找到了确定 BPM 的部分,但在获取原始数据时遇到了一些麻烦。
该示例基于 Apples SpeakHere 应用程序 - 基于我正在使用的 AudioQueue 回调函数:
SInt16 *buffer = (SInt16*)inBuffer->mAudioData;
for (int i = 0; i < (inBuffer->mAudioDataByteSize)/sizeof(SInt16); i++)
{
printf("before modification %d\n", (int)*buffer);
buffer++;
}
但我得到了一些有趣的值 - 任何机会有人可以指出我出错的正确方向并让我知道什么我应该返回的范围。
音频格式设置:
mRecordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
mRecordFormat.mBitsPerChannel = 16;
mRecordFormat.mBytesPerPacket = mRecordFormat.mBytesPerFrame = (mRecordFormat.mBitsPerChannel / 8) * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mFramesPerPacket = 1;
干杯,
I'm trying to determine Beats Per Minute (BPM) from the microphone using sound energy, I think I've figured out the part determining BPM but having a little trouble obtaining the RAW data.
The example is based on Apples SpeakHere app - on the AudioQueue callback function I'm using:
SInt16 *buffer = (SInt16*)inBuffer->mAudioData;
for (int i = 0; i < (inBuffer->mAudioDataByteSize)/sizeof(SInt16); i++)
{
printf("before modification %d\n", (int)*buffer);
buffer++;
}
But I'm getting some interesting values - any chance someone can point me in the right direction of where I'm going wrong and let me know what the range I should be getting back.
Audio Format Setup:
mRecordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
mRecordFormat.mBitsPerChannel = 16;
mRecordFormat.mBytesPerPacket = mRecordFormat.mBytesPerFrame = (mRecordFormat.mBitsPerChannel / 8) * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mFramesPerPacket = 1;
Cheers,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已解决...
音频格式设置:
现在迭代它:
Solved...
Audio Format Setup:
And now to iterate through it:
您以什么格式(AudioStreamBasicDescription:字节序、每通道位数、每帧通道等)配置音频队列?配置可能与 SInt16 的 C 数组有很大不同。
In what format (AudioStreamBasicDescription: endianess, bits per channel, channel per frame, etc.) did you configure your Audio Queue? It's possible for the configuration to be very different from a C array of SInt16.