Vaishali G Bijani
Vaishali G Bijani

Reputation: 47

Superpowered Android PlayBack & Record Simultaneously

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

Upvotes: 3

Views: 703

Answers (1)

Gabor Szanto
Gabor Szanto

Reputation: 1329

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?

Upvotes: 4

Related Questions