Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 从图形kAudioUnitSubType_GenericOutput中提取音频数据_Macos_Core Audio - Fatal编程技术网

Macos 从图形kAudioUnitSubType_GenericOutput中提取音频数据

Macos 从图形kAudioUnitSubType_GenericOutput中提取音频数据,macos,core-audio,Macos,Core Audio,我正在构建音频图,它具有: 音频文件播放器(发电机组)->通用输出(输出机组) 基本思想是: AudioFilePlayer正在为其输出生成音频帧。通用输出将AudioFilePlayer输出中的数据作为输入。这样我就可以把数据保存到另一个缓冲区 我的问题是如何从通用输出中提取数据,以获取用于脱机渲染的数据 我对它做了一些研究,发现我必须在GenericOutput单元上使用AudioUnitRender从中提取音频数据 Uint32 frames = 512; timestamp.mSampl

我正在构建音频图,它具有: 音频文件播放器(发电机组)->通用输出(输出机组)

基本思想是:

AudioFilePlayer正在为其输出生成音频帧。通用输出将AudioFilePlayer输出中的数据作为输入。这样我就可以把数据保存到另一个缓冲区

我的问题是如何从通用输出中提取数据,以获取用于脱机渲染的数据

我对它做了一些研究,发现我必须在GenericOutput单元上使用AudioUnitRender从中提取音频数据

Uint32 frames = 512;
timestamp.mSampleTime = 0;

... While Loop ...

timestamp.mFlags = kAudioTimeStampSampleTimeValid;

bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mNumberChannels = param->inputFormat.mChannelsPerFrame;
bufferList.mBuffers[0].mDataByteSize = frames * param->inputFormat.mChannelsPerFrame * sizeof(float);
bufferList.mBuffers[0].mData = NULL;

AudioUnitRenderActionFlags flags = 0;

OSStatus error = noErr;
if ((error = AudioUnitRender(param->genericOutput, &flags, &timestamp, 0, frames, &bufferList)) != noErr)
{
    printf("Cannot AudioUnitRender: %d\n", error);
}

timestamp.mSampleTime += frames;
但数字-50出现错误。


我是否设置了错误的输入参数?是否需要将任何渲染回调函数注册到GenericOutput unit?

问题是我在调用AUGraphInitialize()后设置了GenericOutput StreamFormat。 必须在那之前完成


我使用CAShow(reader.graph)获取音频图的日志,这帮助我注意到在尝试设置格式后格式没有改变。

希望您使用
GenericOutput
节点成功完成脱机渲染。 你能告诉我你是怎么做到的吗

  • 您正试图在循环中传递一个缓冲区列表,其中没有数据
  • 如果我们需要将输出保存到一个文件中,我必须做什么(或者我将
    ExtAudioFileWriteAsync
  • while循环的退出条件是什么

  • is
    timestamp
    是本地声明的变量


-50是参数列表错误,调试
param->genericOutput
一次,并确保它不为空。我让它工作了。在这里你可以找到我的工作代码。是的,时间戳是局部变量。我为要读取的帧数分配内存。bufferList.mNumberBuffers=1;bufferList.mBuffers[0].mNumberChannels=pFormat->mChannelsPerFrame;bufferList.mBuffers[0].mDataByteSize=pFormat->mBytesPerFrame*framesToRead;bufferList.mBuffers[0].mData=(UInt8*)malloc(bufferList.mBuffers[0].mDataByteSize);您应该将ExtAudioFileWriteAsync放在AudioUnitRender调用之后。我得到文件的总长度(以帧为单位),当我达到这个数字时,我终止循环。