我需要读取音频样本值。我正在使用该 audioQueue 回调(来自 Apple SpeakHere 示例):
UInt32 samplesCount = inCompleteAQBuffer->mAudioDataBytesCapacity / 2;
UInt16 *samples = (UInt16 *)inCompleteAQBuffer->mAudioData;
for (int i=0; i < samplesCount; i++)
{
printf("%i\n", samples[i]);
}
返回值,但是当我将它们与大胆的图表进行比较时,它们似乎是错误的:
Audacity 值从 1 (65535) 到 -1 (0)。所以逻辑上第一个样本值应该是 32767,第二个应该是 ~50 000 ...
但我收到其他结果:
value - position
65535 - 0
29501 - 1
26086 - 2
63656 - 3
28477 - 4
65407 - 5
36802 - 6
36546 - 7
18244 - 8
17220 - 9
player settings:
(Float64) mSampleRate = 44100
(UInt32) mBytesPerPacket = 2
(UInt32) mFramesPerPacket = 1
(UInt32) mBytesPerFrame = 2
(UInt32) mChannelsPerFrame = 1
(UInt32) mBitsPerChannel = 16
(UInt32) mReserved = 0
问题 - 为什么从 mAudioData 返回的样本值是错误的?