gpt4 book ai didi

iPhone AudioQueue - 读取传入的音频数据以确定 BPM

转载 作者:行者123 更新时间:2023-12-03 21:19:48 26 4
gpt4 key购买 nike

我正在尝试使用声能从麦克风确定每分钟节拍数 (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;

干杯,

最佳答案

解决了...

音频格式设置:

mRecordFormat.mFormatID = kAudioFormatLinearPCM;
mRecordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
mRecordFormat.mBitsPerChannel = 16;
mRecordFormat.mBytesPerPacket = mRecordFormat.mBytesPerFrame = (mRecordFormat.mBitsPerChannel / 8) * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mFramesPerPacket = 1;
mRecordFormat.mBytesPerPacket = 2 * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mBytesPerFrame = 2 * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mFramesPerPacket = 1;
mRecordFormat.mReserved = 0;

现在迭代它:

int sampleCount = inBuffer->mAudioDataBytesCapacity / sizeof (SInt16);
SInt16 *p = (SInt16*)inBuffer->mAudioData;
for (int i = 0; i < sampleCount; i++) {
SInt16 val = p[i];
}

关于iPhone AudioQueue - 读取传入的音频数据以确定 BPM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5901821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com