3

i am developing mixer using Superpowered Android C++ library, i am getting issue with the Player while Recording, player is not playing, only recorder is recording. below is the code, can anyone guide me where i am misplacing something

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;
}

does anyone have idea to get it in right place?

after changes suggested by @Gabor following is the code snippet

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; }
  • @kasurd can you please help me, as i had seen your code https://bitbucket.org/snippets/kasurd/Mynnp for simultaneous mode of recorder & player – Vaishali G Bijani Aug 18 '17 at 20:47

1 Answers1

4

This is what you do in your code:

input->stereoBufferRecording->recorder

input->stereoBufferRecording->?

player->musicBuffer->input

When askRecording is false, player is not playing at all.

I'm guessing that "input" is the same buffer which goes to "output" as well?

Gabor Szanto
  • 1,329
  • 8
  • 12