How to apply Bass effect programmatically in android

醉酒当歌 提交于 2019-11-29 20:56:29

问题


I am trying to apply the Bass Effects programmatically by using the following code:

BassBoost bassBoost = new BassBoost(0, audioSessionId);
bassBoost.setEnabled(true);
BassBoost.Settings bassBoostSettingTemp =  bassBoost.getProperties();
BassBoost.Settings bassBoostSetting = new BassBoost.Settings(bassBoostSettingTemp.toString());
bassBoostSetting.strength = MAX_STRENGTH_FOR_BASS; // 1000
bassBoost.setProperties(bassBoostSetting);

bassBoost.setStrength((short) progress); // progress value from seek bar

But the bass effects aren't applied on the current audio session.
Please help me by showing me what's wrong.


回答1:


Check whether it is supported or not.

bassBoost = new BassBoost(0, 0);
bassBoost.setEnabled(true);

if (bassBoost.getStrengthSupported())
{
    short word1 = bassBoost.getRoundedStrength();
    bassBoost.setStrength(word1);
}

And you can also check that whatever you're testing on supports it (it is device-dependent). You can use:

final Descriptor[] effects = AudioEffect.queryEffects();

// Determine available/supported effects 
for (final Descriptor effect : effects) {
    Log.d(TAG, effect.name.toString() + ", type: " + effect.type.toString());
}


来源:https://stackoverflow.com/questions/13320236/how-to-apply-bass-effect-programmatically-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!