try {
mVisualizer = new Visualizer(session);
if (mVisualizer != null) {
mVisualizer.setCaptureSize(CAPTURE_SIZE);
mMaxFrequency = mVisualizer.getSamplingRate() / 2000;
mCapturePeriodMs = 1000000 / mVisualizer.getMaxCaptureRate();
}
} catch (UnsupportedOperationException e) {
Log.e(TAG, "Error creating visualizer");
} catch (IllegalStateException e) {
Log.e(TAG, "Error configuring visualizer");
}