OpenSL RecorderObject does not implement an interface for installing a volume or setting on Android

I tried to get the SLDeviceVolumeItfinterface RecorderObjecton Android, but got an error:SL_RESULT_FEATURE_UNSUPPORTED.

I read that the OpenSL ES implementation in Android does not support volume setting for AudioRecorder. It's true?

If so, is there a workaround? I have a VOIP application that doesn't reflect very well on the Galaxy Nexus due to the very high microphone gain.

I also tried installing SL_IID_ANDROIDCONFIGURATIONto install streamTypein a new audio source VOICE_COMMUNINCATION, but again I get error 12 (not supported).

   // create audio recorder
const SLInterfaceID id[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION };
const SLboolean    req[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };

result = (*engine)->CreateAudioRecorder(engine, &recorderObject, &audioSrc,  &audioSnk, 2, id, req);
if (SL_RESULT_SUCCESS != result) {
    return false;
}

SLAndroidConfigurationItf recorderConfig;   
result = (*recorderObject)->GetInterface(recorderObject, SL_IID_ANDROIDCONFIGURATION, &recorderConfig);
if(result != SL_RESULT_SUCCESS) {
    error("failed to get SL_IID_ANDROIDCONFIGURATION interface. e == %d", result);
}

recorderObject, SL_IID_ANDROIDCONFIGURATION. Galaxy Nexus (ICS), HTC sense (ICS) Motorola Blur (Gingerbread). NDK 6.

+5
4

. NDK 8 -14. 10 , (dirent.h ). -14.

+1

. . , SL_IID_ANDROIDCONFIGURATION.

0
    apiLvl = (*env)->GetStaticIntField(env, versionClass, sdkIntFieldID);

SLint32 streamType = SL_ANDROID_RECORDING_PRESET_GENERIC;
    if(apiLvl > 10){
        streamType = SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
        I("set SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION");
    }

    result = (*recorderConfig)->SetConfiguration(recorderConfig, SL_ANDROID_KEY_RECORDING_PRESET, &streamType, sizeof(SLint32));
    if (SL_RESULT_SUCCESS != result) {
        return 0;
    }
0

OpenSL, , api/interface. ,

void multiply_gain(void *buffer, int bytes, int gain_val) { int i = 0, j = 0;

    short *buffer_samples = (short*)buffer;

    for(i = 0, j = 0; i < bytes; i+=2,j++)
    {
       buffer_samples [j] = (buffer_samples [j] >> gain_val);
    }

}

But here the gain is multiplied / divided (based on <lt; or →) by the factor or 2. If you need a smoother gain curve, you need to write a more complex digital gain function.

0
source

All Articles