gpt4 book ai didi

ios - 枚举 AudioBuffer 的样本?

转载 作者:行者123 更新时间:2023-12-03 02:12:01 24 4
gpt4 key购买 nike

我有一个 AudioBuffer来自 AVCaptureSession CMSampleBuffer , 像:

Sample Rate:              44100 
Format ID: lpcm
Format Flags: C
Bytes per Packet: 2
Frames per Packet: 1
Bytes per Frame: 2
Channels per Frame: 1
Bits per Channel: 16

kAudioFormatFlagIsSignedInteger
kAudioFormatFlagIsPacked
kLinearPCMFormatFlagIsSignedInteger
kLinearPCMFormatFlagIsPacked
kLinearPCMFormatFlagsSampleFractionShift
kAppleLosslessFormatFlag_32BitSourceData

如何正确转换/枚举样本? (做一些处理)
我应该转换成什么类型​​ mData有了上面的配置?

我是否完全正确地解析了格式标志?上面的输出是由 https://gist.github.com/eppz/11272305 制作的

最佳答案

一旦我解析了上面的标志,kAudioFormatFlagIsSignedInteger似乎是答案,每个 channel 有 16 位。

到目前为止,它是这样的:

// Enumerate audio buffers (probably faceing a sole buffer handling mono PCM anyway).
for (int audioBufferIndex = 0; audioBufferIndex <= audioBufferList.mNumberBuffers; audioBufferIndex++)
{
AudioBuffer eachAudioBuffer = audioBufferList.mBuffers[audioBufferIndex];

// Enumerate samples.
SInt16 *samples;
samples = (SInt16*)eachAudioBuffer.mData;
for (int sampleIndex = 0; sampleIndex <= sampleCount; sampleIndex++)
{
SInt16 eachSample = samples[sampleIndex];
printf("%i \n", eachSample);
}
}

关于ios - 枚举 AudioBuffer 的样本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23281081/

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