From 700c99e688bb8173a6c73f458ced2515350c7355 Mon Sep 17 00:00:00 2001 From: Adithya R Date: Tue, 10 Oct 2023 08:04:31 +0530 Subject: [PATCH] sm8150-common: Introduce more Dolby Atmos effects - Bass Enhancer - Dialogue Enhancer - Stereo Widening Change-Id: I05ec5add1496d7227d608b9e58aede14dfa0395c --- DolbyManager/res/values/arrays.xml | 28 +++++++++++++++++ DolbyManager/res/values/strings.xml | 7 +++++ DolbyManager/res/xml/dolby_settings.xml | 26 ++++++++++++++++ .../co/aospa/settings/dolby/DolbyAtmos.java | 27 +++++++++++++++- .../settings/dolby/DolbySettingsFragment.java | 31 +++++++++++++++++-- .../co/aospa/settings/dolby/DolbyUtils.java | 20 ++++++++++++ 6 files changed, 136 insertions(+), 3 deletions(-) diff --git a/DolbyManager/res/values/arrays.xml b/DolbyManager/res/values/arrays.xml index 4bd39e68..622b3e52 100644 --- a/DolbyManager/res/values/arrays.xml +++ b/DolbyManager/res/values/arrays.xml @@ -54,4 +54,32 @@ 50,34,18,2,-14,-6,2,-2,-6,-26,-46,-26,-6,-2,2,2,2,2,2,2 40,24,8,8,8,-4,-16,-12,-8,-32,-56,-24,8,8,8,8,8,8,8,8 + + + @string/dolby_off + @string/dolby_low + @string/dolby_medium + @string/dolby_high + + + + 2 + 6 + 9 + 12 + + + + @string/dolby_off + @string/dolby_low + @string/dolby_medium + @string/dolby_high + + + + 4 + 24 + 44 + 64 + diff --git a/DolbyManager/res/values/strings.xml b/DolbyManager/res/values/strings.xml index 1b84ff0a..c6d9da59 100644 --- a/DolbyManager/res/values/strings.xml +++ b/DolbyManager/res/values/strings.xml @@ -22,7 +22,14 @@ Choose a profile Off On + Low + Medium + High On (%1$s) + Bass Enhancer + Dialogue Enhancer + Stereo Widening + Advanced Dynamic diff --git a/DolbyManager/res/xml/dolby_settings.xml b/DolbyManager/res/xml/dolby_settings.xml index 318f9679..9ac7de4e 100644 --- a/DolbyManager/res/xml/dolby_settings.xml +++ b/DolbyManager/res/xml/dolby_settings.xml @@ -41,4 +41,30 @@ android:summary="%s" android:icon="@drawable/ic_preset"/> + + + + + + + + + + diff --git a/DolbyManager/src/co/aospa/settings/dolby/DolbyAtmos.java b/DolbyManager/src/co/aospa/settings/dolby/DolbyAtmos.java index f1669443..203e935f 100644 --- a/DolbyManager/src/co/aospa/settings/dolby/DolbyAtmos.java +++ b/DolbyManager/src/co/aospa/settings/dolby/DolbyAtmos.java @@ -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}); + } } diff --git a/DolbyManager/src/co/aospa/settings/dolby/DolbySettingsFragment.java b/DolbyManager/src/co/aospa/settings/dolby/DolbySettingsFragment.java index 868d25e8..c0162db3 100644 --- a/DolbyManager/src/co/aospa/settings/dolby/DolbySettingsFragment.java +++ b/DolbyManager/src/co/aospa/settings/dolby/DolbySettingsFragment.java @@ -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); } } diff --git a/DolbyManager/src/co/aospa/settings/dolby/DolbyUtils.java b/DolbyManager/src/co/aospa/settings/dolby/DolbyUtils.java index 23debcc3..88de26b6 100644 --- a/DolbyManager/src/co/aospa/settings/dolby/DolbyUtils.java +++ b/DolbyManager/src/co/aospa/settings/dolby/DolbyUtils.java @@ -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); + } }