Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Enable equalizer, in order to not depend on volume settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kmmbvnr committed Mar 12, 2012
1 parent 8b140a1 commit 98f5d7d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CryDetector/src/cc/wthr/crydetector/CryDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Queue;

import android.media.MediaRecorder;
import android.media.audiofx.Equalizer;
import android.media.audiofx.Visualizer;
import android.media.audiofx.Visualizer.OnDataCaptureListener;

Expand Down Expand Up @@ -44,6 +45,7 @@ public class CryDetector implements OnDataCaptureListener {
private Queue<Boolean> mCryFilter = new LinkedList<Boolean>();
private int mCryFilterCount = 0;
private MediaRecorder mRecorder;
private Equalizer mEqualizer;

public CryDetector() {
mBytes = new byte[SAMPLES_SIZE];
Expand All @@ -70,6 +72,9 @@ public void link(int sessionId) {
throw new RuntimeException(e);
}
}

mEqualizer = new Equalizer(0, sessionId);
mEqualizer.setEnabled(true);

mVisualizer = new Visualizer(sessionId);
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
Expand All @@ -85,6 +90,12 @@ public void unlink() {
mCryFilter.clear();
mCryFilterCount = 0;
}

if(mEqualizer != null) {
mEqualizer.setEnabled(false);
//mEqualizer.release()
mEqualizer = null;
}
if (mRecorder != null) {
mRecorder.stop();
mRecorder.release();
Expand Down

0 comments on commit 98f5d7d

Please sign in to comment.