Equializer problem.

Hi everyone,

I have been playing around with google’s NDK project audio-echo (ndk-samples/audio-echo at master · android/ndk-samples · GitHub). It basically echoes the input from the microphone of an android device. Well I have been trying to attach an equalizer to the original code without success and I was wondering if you could help me out. The code is as follows (equalizer related code marked in red):

// Creating output mix.
SLboolean r[1] = {SL_BOOLEAN_TRUE};
SLInterfaceID ifac[1] = {SL_IID_EQUALIZER};
result = (*slEngine)->CreateOutputMix(slEngine, &outputMixObjectItf_, 1, ifac, r);

SLASSERT(result);

// realize the output mix
result = (*outputMixObjectItf_)->Realize(outputMixObjectItf_, SL_BOOLEAN_FALSE);
SLASSERT(result);

// configure audio source
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {
        SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
        DEVICE_SHADOW_BUFFER_QUEUE_LEN };

SLAndroidDataFormat_PCM_EX format_pcm;
ConvertToSLSampleFormat(&format_pcm, &sampleInfo_);
SLDataSource audioSrc = {&loc_bufq, &format_pcm};

// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObjectItf_};
SLDataSink audioSnk = {&loc_outmix, NULL};

/*
 * create fast path audio player: SL_IID_BUFFERQUEUE and SL_IID_VOLUME interfaces ok,
 * NO others!
 */
SLInterfaceID  ids[2] = {SL_IID_BUFFERQUEUE, SL_IID_VOLUME};
SLboolean      req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};

result = (*slEngine)->CreateAudioPlayer(slEngine, &playerObjectItf_, &audioSrc, &audioSnk, sizeof(ids)/sizeof(ids[0]), ids, req);

SLASSERT(result);

// realize the player
result = (*playerObjectItf_)->Realize(playerObjectItf_, SL_BOOLEAN_FALSE);
SLASSERT(result);

// get the play interface
result = (*playerObjectItf_)->GetInterface(playerObjectItf_, SL_IID_PLAY, &playItf_);
SLASSERT(result);

// get the buffer queue interface
result = (*playerObjectItf_)->GetInterface(playerObjectItf_, SL_IID_BUFFERQUEUE, &playBufferQueueItf_);
SLASSERT(result);

result = (*outputMixObjectItf_)->GetInterface(outputMixObjectItf_, SL_IID_EQUALIZER, (void *) &slEqualizerItf_);
SLASSERT(result);

// register callback on the buffer queue
result = (*playBufferQueueItf_)->RegisterCallback(playBufferQueueItf_, bqPlayerCallback, this);
SLASSERT(result);

result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_STOPPED);
SLASSERT(result);

// create an empty queue to track deviceQueue
devShadowQueue_ = new AudioQueue(DEVICE_SHADOW_BUFFER_QUEUE_LEN);
assert(devShadowQueue_);

/********** In other code section **********/

SLuint32   state;
SLresult  result = (*playItf_)->GetPlayState(playItf_, &state);
if (result != SL_RESULT_SUCCESS) {
    return SL_BOOLEAN_FALSE;
}
if(state == SL_PLAYSTATE_PLAYING) {
    return SL_BOOLEAN_TRUE;
}

result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_STOPPED);
SLASSERT(result);

result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_PLAYING);
SLASSERT(result);

result = (*slEqualizerItf_)->GetNumberOfBands(slEqualizerItf_, &eQBandsNo_);
SLASSERT(result);

result = (*slEqualizerItf_)->GetBandLevelRange(slEqualizerItf_, &sLmillibelMin_, &sLmillibelMax_);
SLASSERT(result);

result = (*slEqualizerItf_)->SetBandLevel(slEqualizerItf_, 0, sLmillibelMax_);
SLASSERT(result);
for (int b = 0; b < eQBandsNo_; ++b) {
    result = (*slEqualizerItf_)->SetBandLevel(slEqualizerItf_, b, sLmillibelMin_);
    SLASSERT(result);
}

result = (*slEqualizerItf_)->SetEnabled(slEqualizerItf_, SL_BOOLEAN_TRUE);
SLASSERT(result);

SLboolean ret;
result = (*slEqualizerItf_)->IsEnabled(slEqualizerItf_, &ret);
SLASSERT(result);

After doing that isn’t the equalizer supposed to do something? What am I missing or what am I doing wrong?

Thank you in advanced.