超级强大的Android PlayBack和同时录制
作者:互联网
我正在使用Superpowered Android C库开发调音台,但在录制时播放器出现问题,播放器未在播放,只有录音器在录制.下面是代码,有人可以指导我在哪里我放错了什么
bool processRecording(short int *input, unsigned int numberOfSamples) {
pthread_mutex_lock(&mutex);
if (askRecording) {
unsigned int data = 0;
SuperpoweredShortIntToFloat(input, stereoBufferRecording, numberOfSamples);
data = recorder->process(stereoBufferRecording, NULL, numberOfSamples);
playerA->process( musicBuffer, false, numberOfSamples, 0.5f );
SuperpoweredShortIntToFloat(input, stereoBufferRecording, numberOfSamples);
SuperpoweredFloatToShortInt(musicBuffer, input, numberOfSamples);
pthread_mutex_unlock(&mutex);
return true;
}
pthread_mutex_unlock(&mutex);
return false;
}
有谁有想法将其放置在正确的位置?
@Gabor建议的更改之后,以下是代码段
bool processRecording(short int *input, unsigned int numberOfSamples) {
pthread_mutex_lock(&mutex);
if (askRecording) {
unsigned int data = 0;
SuperpoweredShortIntToFloat(input, stereoBufferRecording, numberOfSamples);
playerA->process( musicBuffer, false, numberOfSamples, 1.0f );
//=====================================================================================
// ================== Mixing Two Buffer ==================
mixerInputs[0] = musicBuffer;
mixerInputs[1] = stereoBufferRecording;
mixerInputs[2] = NULL;
mixerInputs[3] = NULL;
mixerOutputs[0] = outputBuffer;
mixerOutputs[1] = NULL;
float inputLevels[] = { 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
float outputLevels[] = { 1.0f, 1.0f };
__android_log_print(ANDROID_LOG_INFO, "NativeSuperpoweredRecorder ", " processRecording 2>>");
mixerBackend->process(mixerInputs, mixerOutputs, inputLevels, outputLevels, NULL, NULL, numberOfSamples);
//=====================================================================================
data = recorder->process(mixerOutputs[0], NULL, numberOfSamples);
SuperpoweredFloatToShortInt(musicBuffer, input, numberOfSamples);
pthread_mutex_unlock(&mutex);
return true;
}
pthread_mutex_unlock(&mutex);
return false; }
解决方法:
这是您在代码中执行的操作:
输入-> stereoBufferRecording->记录器
输入-> stereoBufferRecording-> ;?
播放器-> musicBuffer->输入
当askRecording为false时,播放器根本不播放.
我猜想“输入”和“输出”也是同一个缓冲区?
标签:audio-recording,superpowered,audio,c-4,android 来源: https://codeday.me/bug/20191025/1931098.html