我正在使用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; }
答案 0 :(得分:4)
这是您在代码中执行的操作:
输入 - > stereoBufferRecording->记录器
输入 - > stereoBufferRecording->
播放器 - > musicBuffer->输入
当askRecording为false时,玩家根本不玩。
我猜测“输入”是同样的缓冲区,也是“输出”?