sm8150-common: Introduce more Dolby Atmos effects

- Bass Enhancer
- Dialogue Enhancer
- Stereo Widening

Change-Id: I05ec5add1496d7227d608b9e58aede14dfa0395c
This commit is contained in:
Adithya R 2023-10-10 08:04:31 +05:30 committed by fazilsheik96
parent 9cd354ec40
commit 700c99e688
6 changed files with 136 additions and 3 deletions

View File

@ -54,4 +54,32 @@
<item>50,34,18,2,-14,-6,2,-2,-6,-26,-46,-26,-6,-2,2,2,2,2,2,2</item>
<item>40,24,8,8,8,-4,-16,-12,-8,-32,-56,-24,8,8,8,8,8,8,8,8</item>
</string-array>
<string-array name="dolby_dialogue_entries">
<item>@string/dolby_off</item>
<item>@string/dolby_low</item>
<item>@string/dolby_medium</item>
<item>@string/dolby_high</item>
</string-array>
<string-array name="dolby_dialogue_values">
<item>2</item>
<item>6</item>
<item>9</item>
<item>12</item>
</string-array>
<string-array name="dolby_stereo_entries">
<item>@string/dolby_off</item>
<item>@string/dolby_low</item>
<item>@string/dolby_medium</item>
<item>@string/dolby_high</item>
</string-array>
<string-array name="dolby_stereo_values">
<item>4</item>
<item>24</item>
<item>44</item>
<item>64</item>
</string-array>
</resources>

View File

@ -22,7 +22,14 @@
<string name="dolby_profile_title">Choose a profile</string>
<string name="dolby_off">Off</string>
<string name="dolby_on">On</string>
<string name="dolby_low">Low</string>
<string name="dolby_medium">Medium</string>
<string name="dolby_high">High</string>
<string name="dolby_on_with_profile">On (%1$s)</string>
<string name="dolby_bass_enhancer">Bass Enhancer</string>
<string name="dolby_dialogue_enhancer">Dialogue Enhancer</string>
<string name="dolby_stereo_widening">Stereo Widening</string>
<string name="dolby_category_advanced">Advanced</string>
<!-- Dolby Atmos: Sound Profiles -->
<string name="dolby_profile_dynamic">Dynamic</string>

View File

@ -41,4 +41,30 @@
android:summary="%s"
android:icon="@drawable/ic_preset"/>
<PreferenceCategory
android:title="@string/dolby_category_advanced">
<ListPreference
android:key="dolby_dialogue"
android:entries="@array/dolby_dialogue_entries"
android:entryValues="@array/dolby_dialogue_values"
android:defaultValue="2"
android:title="@string/dolby_dialogue_enhancer"
android:summary="%s" />
<ListPreference
android:key="dolby_stereo"
android:entries="@array/dolby_stereo_entries"
android:entryValues="@array/dolby_stereo_values"
android:defaultValue="4"
android:title="@string/dolby_stereo_widening"
android:summary="%s" />
<SwitchPreference
android:key="dolby_bass"
android:title="@string/dolby_bass_enhancer"
android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -29,8 +29,13 @@ public class DolbyAtmos extends AudioEffect {
private static final int DAP_PARAM = 5;
private static final int DAP_PARAM_PROFILE = 0xA000000;
private static final int DAP_PARAM_VALUE = 0x1000000;
private static final int DAP_PARAM_GEQ = 110;
private static final int DAP_PARAM_HEADPHONE_VIRTUALIZER = 101;
private static final int DAP_PARAM_VOLUME_LEVELER = 103;
private static final int DAP_PARAM_DIALOGUE_ENHANCER_ENABLE = 105;
private static final int DAP_PARAM_DIALOGUE_ENHANCER_AMOUNT = 108;
private static final int DAP_PARAM_GEQ = 110;
private static final int DAP_PARAM_BASS_ENHANCER = 111;
private static final int DAP_PARAM_STEREO_WIDENING = 113;
private static final int DAP_PROFILES_COUNT = 10;
public DolbyAtmos(int priority, int audioSession) {
@ -111,4 +116,24 @@ public class DolbyAtmos extends AudioEffect {
public void setVolumeLevelerEnabled(boolean enable) {
setDapParameter(DAP_PARAM_VOLUME_LEVELER, new int[]{enable ? 1 : 0});
}
public void setBassEnhancerEnabled(boolean enable) {
setDapParameter(DAP_PARAM_BASS_ENHANCER, new int[]{enable ? 1 : 0});
}
public void setDialogueEnhancerEnabled(boolean enable) {
setDapParameter(DAP_PARAM_DIALOGUE_ENHANCER_ENABLE, new int[]{enable ? 1 : 0});
}
public void setDialogueEnhancerAmount(int amount) {
setDapParameter(DAP_PARAM_DIALOGUE_ENHANCER_AMOUNT, new int[]{amount});
}
public void setHeadphoneVirtualizerEnabled(boolean enable) {
setDapParameter(DAP_PARAM_HEADPHONE_VIRTUALIZER, new int[]{enable ? 1 : 0});
}
public void setStereoWideningAmount(int amount) {
setDapParameter(DAP_PARAM_STEREO_WIDENING, new int[]{amount});
}
}

View File

@ -39,10 +39,13 @@ public class DolbySettingsFragment extends PreferenceFragment implements
public static final String PREF_ENABLE = "dolby_enable";
public static final String PREF_PRESET = "dolby_preset";
public static final String PREF_PROFILE = "dolby_profile";
public static final String PREF_DIALOGUE = "dolby_dialogue";
public static final String PREF_STEREO = "dolby_stereo";
public static final String PREF_BASS = "dolby_bass";
private MainSwitchPreference mSwitchBar;
private ListPreference mPresetPref;
private ListPreference mProfilePref;
private ListPreference mPresetPref, mProfilePref, mDialoguePref, mStereoPref;
private SwitchPreference mBassPref;
private DolbyUtils mDolbyUtils;
@ -65,6 +68,18 @@ public class DolbySettingsFragment extends PreferenceFragment implements
mProfilePref.setOnPreferenceChangeListener(this);
mProfilePref.setEnabled(dsOn);
mProfilePref.setValue(Integer.toString(mDolbyUtils.getProfile()));
mDialoguePref = (ListPreference) findPreference(PREF_DIALOGUE);
mDialoguePref.setOnPreferenceChangeListener(this);
mDialoguePref.setEnabled(dsOn);
mStereoPref = (ListPreference) findPreference(PREF_STEREO);
mStereoPref.setOnPreferenceChangeListener(this);
mStereoPref.setEnabled(dsOn);
mBassPref = (SwitchPreference) findPreference(PREF_BASS);
mBassPref.setOnPreferenceChangeListener(this);
mBassPref.setEnabled(dsOn);
}
@Override
@ -76,6 +91,15 @@ public class DolbySettingsFragment extends PreferenceFragment implements
case PREF_PROFILE:
mDolbyUtils.setProfile(Integer.parseInt((newValue.toString())));
return true;
case PREF_DIALOGUE:
mDolbyUtils.setDialogueEnhancerAmount(Integer.parseInt((newValue.toString())));
return true;
case PREF_STEREO:
mDolbyUtils.setStereoWideningAmount(Integer.parseInt((newValue.toString())));
return true;
case PREF_BASS:
mDolbyUtils.setBassEnhancerEnabled((Boolean) newValue);
return true;
default:
return false;
}
@ -88,5 +112,8 @@ public class DolbySettingsFragment extends PreferenceFragment implements
mDolbyUtils.setDsOn(isChecked);
mPresetPref.setEnabled(isChecked);
mProfilePref.setEnabled(isChecked);
mDialoguePref.setEnabled(isChecked);
mStereoPref.setEnabled(isChecked);
mBassPref.setEnabled(isChecked);
}
}

View File

@ -100,4 +100,24 @@ public final class DolbyUtils {
Log.i(TAG, "setPreset: " + Arrays.toString(gains));
mDolbyAtmos.setGeqBandGains(gains);
}
public void setBassEnhancerEnabled(boolean enable) {
checkEffect();
Log.i(TAG, "setBassEnhancerEnabled: " + enable);
mDolbyAtmos.setBassEnhancerEnabled(enable);
}
public void setDialogueEnhancerAmount(int amount) {
checkEffect();
Log.i(TAG, "setDialogueEnhancerAmount: " + amount);
mDolbyAtmos.setDialogueEnhancerEnabled(true);
mDolbyAtmos.setDialogueEnhancerAmount(amount);
}
public void setStereoWideningAmount(int amount) {
checkEffect();
Log.i(TAG, "setStereoWideningAmount: " + amount);
mDolbyAtmos.setHeadphoneVirtualizerEnabled(true);
mDolbyAtmos.setStereoWideningAmount(amount);
}
}