Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OboeTester: show default AEC status #2091

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -566,20 +582,40 @@ 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"));
}
}

// If AGC is not available, the checkbox will be disabled in initializeViews().
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 Noise Suppressor 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"));
}
}
}
}

Expand Down Expand Up @@ -608,4 +644,10 @@ private void onAcousticEchoCancelerCheckBoxChanged(boolean isChecked) {
mAcousticEchoCanceler.setEnabled(isChecked);
}
}

private void onNoiseSuppressorCheckBoxChanged(boolean isChecked) {
if (mNoiseSuppressorCheckBox.isEnabled() && mNoiseSuppressor != null) {
mNoiseSuppressor.setEnabled(isChecked);
}
}
}
11 changes: 9 additions & 2 deletions apps/OboeTester/app/src/main/res/layout/stream_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<CheckBox
android:id="@+id/checkBoxAcousticEchoCanceler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8sp"
android:text="Acoustic Echo Canceler" />
android:text="AEC" />

<CheckBox
android:id="@+id/checkBoxNoiseSuppressor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8sp"
android:text="NoNoise" />

</LinearLayout>

Expand Down