Hi Erik,
Thanks for your reply,I am providing the code what i did…yes it is impossible to say why it is failing…sorry for the inconvenience. Here i am using asset audio player i am exposing bassboost to this player.Previously i checked with reverb effect.Reverb is the first effect i tried i did not got any effect so i tried of checking with bassboost…so for this i faced the same problem no effect.So please resolve the issue by checking the code(don’t check about reverb problem).The red color code is where I exposed BassBoost.The bassboost effect is easy to identify…so i exposed directly to player and i played the music after exposing to player. previously i maintained a status based on the status i enabling or disabling bassboost but in this case also i did not got any effect.
#include <assert.h>
#include <jni.h>
#include <string.h>
// for __android_log_print(ANDROID_LOG_INFO, “YourApp”, “formatted message”);
// #include <android/log.h>
// for native audio
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
// for native asset manager
#include <sys/types.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
// engine interfaces
static SLObjectItf engineObject = NULL;
static SLEngineItf engineEngine;
// output mix interfaces
static SLObjectItf outputMixObject = NULL;
static SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
// buffer queue player interfaces
static SLObjectItf bqPlayerObject = NULL;
static SLPlayItf bqPlayerPlay;
static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
static SLEffectSendItf bqPlayerEffectSend;
static SLMuteSoloItf bqPlayerMuteSolo;
static SLVolumeItf bqPlayerVolume;
SLBassBoostItf bassboost;
// aux effect on the output mix, used by the buffer queue player
static const SLEnvironmentalReverbSettings reverbSettings =
SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
// URI player interfaces
static SLObjectItf uriPlayerObject = NULL;
static SLPlayItf uriPlayerPlay;
static SLSeekItf uriPlayerSeek;
static SLMuteSoloItf uriPlayerMuteSolo;
static SLVolumeItf uriPlayerVolume;
// file descriptor player interfaces
static SLObjectItf fdPlayerObject = NULL;
static SLPlayItf fdPlayerPlay;
static SLSeekItf fdPlayerSeek;
static SLMuteSoloItf fdPlayerMuteSolo;
static SLVolumeItf fdPlayerVolume;
SLEqualizerItf equalizer;
SLVirtualizerItf virtualizer;
// recorder interfaces
static SLObjectItf recorderObject = NULL;
static SLRecordItf recorderRecord;
static SLAndroidSimpleBufferQueueItf recorderBufferQueue;
// synthesized sawtooth clip
#define SAWTOOTH_FRAMES 8000
static short sawtoothBuffer[SAWTOOTH_FRAMES];
// 5 seconds of recorded audio at 16 kHz mono, 16-bit signed little endian
#define RECORDER_FRAMES (16000 * 5)
static short recorderBuffer[RECORDER_FRAMES];
static unsigned recorderSize = 0;
static SLmilliHertz recorderSR;
// create the engine and output mix objects
void Java_com_example_nativeaudio_NativeAudio_createEngine(JNIEnv* env,jclass clazz)
{
SLresult result;
// create engine
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// realize the engine
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// get the engine interface, which is needed in order to create other objects
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE,&engineEngine);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// create output mix, with environmental reverb specified as a non-required interface
const SLInterfaceID ids[1] = { SL_IID_ENVIRONMENTALREVERB };
const SLboolean req[1] = { SL_BOOLEAN_FALSE };
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject,1, ids, req);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// realize the output mix
result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void) result;
}
// create asset audio player
jboolean Java_com_example_nativeaudio_NativeAudio_createAssetAudioPlayer(JNIEnv* env, jclass clazz, jobject assetManager, jstring filename)
{
SLresult result;
// convert Java string to UTF-8
const char *utf8 = (*env)->GetStringUTFChars(env, filename, NULL);
assert(NULL != utf8);
// use asset manager to open asset by filename
AAssetManager* mgr = AAssetManager_fromJava(env, assetManager);
assert(NULL != mgr);
AAsset* asset = AAssetManager_open(mgr, utf8, AASSET_MODE_UNKNOWN);
// release the Java string and UTF-8
(*env)->ReleaseStringUTFChars(env, filename, utf8);
// the asset might not be found
if (NULL == asset)
{
return JNI_FALSE;
}
// open asset as file descriptor
off_t start, length;
int fd = AAsset_openFileDescriptor(asset, &start, &length);
assert(0 <= fd);
AAsset_close(asset);
// configure audio source
SLDataLocator_AndroidFD loc_fd = { SL_DATALOCATOR_ANDROIDFD, fd, start,length };
SLDataFormat_MIME format_mime = { SL_DATAFORMAT_MIME, NULL,SL_CONTAINERTYPE_UNSPECIFIED };
SLDataSource audioSrc = { &loc_fd, &format_mime };
// configure audio sink
SLDataLocator_OutputMix loc_outmix = { SL_DATALOCATOR_OUTPUTMIX,outputMixObject };
SLDataSink audioSnk = { &loc_outmix, NULL };
// create audio player
const SLInterfaceID ids[4] = { SL_IID_SEEK, SL_IID_MUTESOLO, SL_IID_VOLUME,SL_IID_BASSBOOST};
const SLboolean req[4] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE,SL_BOOLEAN_TRUE};
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &fdPlayerObject,&audioSrc, &audioSnk, 5, ids, req);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// realize the player
result = (*fdPlayerObject)->Realize(fdPlayerObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// get the play interface
result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_PLAY,&fdPlayerPlay);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// get the seek interface
result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_SEEK,&fdPlayerSeek);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// get the mute/solo interface
result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_MUTESOLO,&fdPlayerMuteSolo);
assert(SL_RESULT_SUCCESS == result);
(void) result;
// get the volume interface
result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_VOLUME,&fdPlayerVolume);
assert(SL_RESULT_SUCCESS == result);
(void) result;
result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_BASSBOOST,(void *) &bassboost);
if (result != SL_RESULT_SUCCESS)
__android_log_print(ANDROID_LOG_DEBUG, "demo", "result not sucess");
else
__android_log_print(ANDROID_LOG_DEBUG, "demo", "result sucess");
result = (*bassboost)->SetEnabled(bassboost, SL_BOOLEAN_TRUE);
if (result != SL_RESULT_SUCCESS)
__android_log_print(ANDROID_LOG_DEBUG, "demo","result not set enabled sucess");
else
__android_log_print(ANDROID_LOG_DEBUG, "demo","result set enabled sucess");
SLboolean isEnabled, isSupported;
result = (*bassboost)->IsEnabled(bassboost, &isEnabled); /* Verify bass boost is enabled */
if (result != SL_RESULT_SUCCESS)
__android_log_print(ANDROID_LOG_DEBUG, "demo","result not enabled sucess");
else
__android_log_print(ANDROID_LOG_DEBUG, "demo","result enabled sucess");
result = (*bassboost)->IsStrengthSupported(bassboost, &isSupported); /* Is strength supported? */
if (result != SL_RESULT_SUCCESS)
__android_log_print(ANDROID_LOG_DEBUG, "demo","result is strength not supported");
else
__android_log_print(ANDROID_LOG_DEBUG, "demo","result is strength supported");
result = (*bassboost)->SetStrength(bassboost, 1000); /* Max strength */
if (result != SL_RESULT_SUCCESS)
__android_log_print(ANDROID_LOG_DEBUG, "demo","result set strength not supported");
else
__android_log_print(ANDROID_LOG_DEBUG, "demo","result set strength supported");
SLint32 roundedStrength = 0;
result = (*bassboost)->GetRoundedStrength(bassboost, &roundedStrength); /*Check to see what the system set */
if (result != SL_RESULT_SUCCESS)
__android_log_print(ANDROID_LOG_DEBUG, "demo","result no round strength supported");
else
__android_log_print(ANDROID_LOG_DEBUG, "demo", "The value is %d",
roundedStrength);
result = (*fdPlayerSeek)->SetLoop(fdPlayerSeek, SL_BOOLEAN_TRUE, 0,
SL_TIME_UNKNOWN);
assert(SL_RESULT_SUCCESS == result);
(void) result;
return JNI_TRUE;
}
// set the playing state for the asset audio player
void Java_com_example_nativeaudio_NativeAudio_setPlayingAssetAudioPlayer(
JNIEnv* env, jclass clazz, jboolean isPlaying) {
SLresult result;
// make sure the asset audio player was created
if (NULL != fdPlayerPlay) {
// set the player's state
result = (*fdPlayerPlay)->SetPlayState(fdPlayerPlay,
isPlaying ? SL_PLAYSTATE_PLAYING : SL_PLAYSTATE_PAUSED);
assert(SL_RESULT_SUCCESS == result);
(void) result;
}
}
}
Thanks & Regards
Bitfield