From 50733ffbf0037a579dde8f05053069522c22e819 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Mon, 19 Aug 2024 12:29:55 -0700 Subject: [PATCH 1/2] OboeTester: show default AEC status Also add NoiseSuppressor For #2090 --- .../oboetester/StreamConfigurationView.java | 42 ++++++++++++++++++- .../app/src/main/res/layout/stream_config.xml | 11 ++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java index d9589ad3f..b131031fb 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java @@ -22,6 +22,7 @@ import android.media.audiofx.AutomaticGainControl; import android.media.audiofx.BassBoost; import android.media.audiofx.LoudnessEnhancer; +import android.media.audiofx.NoiseSuppressor; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; @@ -100,7 +101,11 @@ public class StreamConfigurationView extends LinearLayout { private LinearLayout mOutputEffectsLayout; private CheckBox mAutomaticGainControlCheckBox; + private CharSequence mAutomaticGainControlText; private CheckBox mAcousticEchoCancelerCheckBox; + private CharSequence mAcousticEchoCancelerText; + private CheckBox mNoiseSuppressorCheckBox; + private CharSequence mNoiseSuppressorText; private TextView mBassBoostTextView; private SeekBar mBassBoostSeekBar; private TextView mLoudnessEnhancerTextView; @@ -112,8 +117,9 @@ public class StreamConfigurationView extends LinearLayout { private BassBoost mBassBoost; private LoudnessEnhancer mLoudnessEnhancer; - private AcousticEchoCanceler mAcousticEchoCanceler; private AutomaticGainControl mAutomaticGainControl; + private AcousticEchoCanceler mAcousticEchoCanceler; + private NoiseSuppressor mNoiseSuppressor; // Create an anonymous implementation of OnClickListener private View.OnClickListener mToggleListener = new View.OnClickListener() { @@ -229,13 +235,18 @@ public void onClick(View view) { mAutomaticGainControlCheckBox = (CheckBox) findViewById(R.id.checkBoxAutomaticGainControl); mAcousticEchoCancelerCheckBox = (CheckBox) findViewById(R.id.checkBoxAcousticEchoCanceler); + mNoiseSuppressorCheckBox = (CheckBox) findViewById(R.id.checkBoxNoiseSuppressor); mBassBoostTextView = (TextView) findViewById(R.id.textBassBoost); mBassBoostSeekBar = (SeekBar) findViewById(R.id.seekBarBassBoost); mLoudnessEnhancerTextView = (TextView) findViewById(R.id.textLoudnessEnhancer); mLoudnessEnhancerSeekBar = (SeekBar) findViewById(R.id.seekBarLoudnessEnhancer); mAutomaticGainControlCheckBox.setEnabled(AutomaticGainControl.isAvailable()); + mAutomaticGainControlText = mAutomaticGainControlCheckBox.getText(); mAcousticEchoCancelerCheckBox.setEnabled(AcousticEchoCanceler.isAvailable()); + mAcousticEchoCancelerText = mAcousticEchoCancelerCheckBox.getText(); + mNoiseSuppressorCheckBox.setEnabled(NoiseSuppressor.isAvailable()); + mNoiseSuppressorText = mNoiseSuppressorCheckBox.getText(); mBassBoostSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { @@ -276,6 +287,11 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { onAcousticEchoCancelerCheckBoxChanged(isChecked); } }); + mNoiseSuppressorCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + onNoiseSuppressorCheckBoxChanged(isChecked); + } + }); mActualSampleRateView = (TextView) findViewById(R.id.actualSampleRate); mSampleRateSpinner = (Spinner) findViewById(R.id.spinnerSampleRate); @@ -566,6 +582,9 @@ public void setupEffects(int sessionId) { if (mAcousticEchoCancelerCheckBox.isEnabled()) { mAcousticEchoCanceler = AcousticEchoCanceler.create(sessionId); if (mAcousticEchoCanceler != null) { + boolean wasOn = mAcousticEchoCanceler.getEnabled(); + String text = mAcousticEchoCancelerText + "(" + (wasOn ? "Y" : "N") + ")"; + mAcousticEchoCancelerCheckBox.setText(text); mAcousticEchoCanceler.setEnabled(mAcousticEchoCancelerCheckBox.isChecked()); } else { Log.e(TAG, String.format(Locale.getDefault(), "Could not create AcousticEchoCanceler")); @@ -575,11 +594,26 @@ public void setupEffects(int sessionId) { if (mAutomaticGainControlCheckBox.isEnabled()) { mAutomaticGainControl = AutomaticGainControl.create(sessionId); if (mAutomaticGainControl != null) { + boolean wasOn = mAutomaticGainControl.getEnabled(); + String text = mAutomaticGainControlText + "(" + (wasOn ? "Y" : "N") + ")"; + mAutomaticGainControlCheckBox.setText(text); mAutomaticGainControl.setEnabled(mAutomaticGainControlCheckBox.isChecked()); } else { Log.e(TAG, String.format(Locale.getDefault(), "Could not create AutomaticGainControl")); } } + // If AEC is not available, the checkbox will be disabled in initializeViews(). + if (mNoiseSuppressorCheckBox.isEnabled()) { + mNoiseSuppressor = NoiseSuppressor.create(sessionId); + if (mNoiseSuppressor != null) { + boolean wasOn = mNoiseSuppressor.getEnabled(); + String text = mNoiseSuppressorText + "(" + (wasOn ? "Y" : "N") + ")"; + mNoiseSuppressorCheckBox.setText(text); + mNoiseSuppressor.setEnabled(mNoiseSuppressorCheckBox.isChecked()); + } else { + Log.e(TAG, String.format(Locale.getDefault(), "Could not create NoiseSuppressor")); + } + } } } @@ -608,4 +642,10 @@ private void onAcousticEchoCancelerCheckBoxChanged(boolean isChecked) { mAcousticEchoCanceler.setEnabled(isChecked); } } + + private void onNoiseSuppressorCheckBoxChanged(boolean isChecked) { + if (mNoiseSuppressorCheckBox.isEnabled() && mNoiseSuppressor != null) { + mNoiseSuppressor.setEnabled(isChecked); + } + } } diff --git a/apps/OboeTester/app/src/main/res/layout/stream_config.xml b/apps/OboeTester/app/src/main/res/layout/stream_config.xml index e24d53d8f..f06a71e9c 100644 --- a/apps/OboeTester/app/src/main/res/layout/stream_config.xml +++ b/apps/OboeTester/app/src/main/res/layout/stream_config.xml @@ -330,14 +330,21 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8sp" - android:text="Automatic Gain Control" /> + android:text="AGC" /> + android:text="AEC" /> + + From 2dbf4d319a56dc67a9813b6c068355db6c478d63 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Fri, 30 Aug 2024 13:05:37 -0700 Subject: [PATCH 2/2] Fix comment --- .../java/com/mobileer/oboetester/StreamConfigurationView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java index b131031fb..3b7edca4c 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/StreamConfigurationView.java @@ -590,6 +590,7 @@ public void setupEffects(int sessionId) { Log.e(TAG, String.format(Locale.getDefault(), "Could not create AcousticEchoCanceler")); } } + // If AGC is not available, the checkbox will be disabled in initializeViews(). if (mAutomaticGainControlCheckBox.isEnabled()) { mAutomaticGainControl = AutomaticGainControl.create(sessionId); @@ -602,7 +603,8 @@ public void setupEffects(int sessionId) { Log.e(TAG, String.format(Locale.getDefault(), "Could not create AutomaticGainControl")); } } - // If AEC is not available, the checkbox will be disabled in initializeViews(). + + // If Noise Suppressor is not available, the checkbox will be disabled in initializeViews(). if (mNoiseSuppressorCheckBox.isEnabled()) { mNoiseSuppressor = NoiseSuppressor.create(sessionId); if (mNoiseSuppressor != null) {