捕获从Port Audio写入输出音频设备的音频输出

时间:2016-02-17 13:35:43

标签: c++ audio portaudio

我有一个端口音频回调,它接受一个输入声音缓冲区并在缓冲区上执行fft,以便在应用程序的其他部分使用。输出缓冲区未被修改。我想抓住其他应用程序写入默认输出音频设备的声音。但是,在使用输出设备作为输入初始化流时,端口音频会引发错误的无效通道数'。是否可以使用端口音频捕获写入输出设备的所有音频?流初始化代码如下:

PaStreamParameters inputParams;
inputParams.device = Pa_GetDefaultOutputDevice();
inputParams.channelCount = 2;
inputParams.sampleFormat = paFloat32;
const PaDeviceInfo * inputInfo = Pa_GetDeviceInfo(inputParams.device);
inputParams.suggestedLatency = inputInfo->defaultLowOutputLatency;
inputParams.hostApiSpecificStreamInfo = NULL;

error = Pa_OpenStream( &_pInputStream,
                      &inputParams,
                      NULL,
                             inputInfo->defaultSampleRate,
                             paFramesPerBufferUnspecified,
                             0,
                             coreAudioCallback,
                             this);
if( error != paNoError ){
    printf("Port audio error = %s", Pa_GetErrorText(error));
}

1 个答案:

答案 0 :(得分:0)

Port Audio不支持此功能。解决方案是使用现有的OS音频环回设备,并将此设备设置为OS的默认输出设备。然后,环回设备可以用作端口音频中的输入流源,并且最终声音可以从端口音频回调路由到所需的输出设备。

相关问题