Example usage for android.media.audiofx Visualizer getCaptureSizeRange

List of usage examples for android.media.audiofx Visualizer getCaptureSizeRange

Introduction

In this page you can find the example usage for android.media.audiofx Visualizer getCaptureSizeRange.

Prototype

public static native int[] getCaptureSizeRange();

Source Link

Document

Returns the capture size range.

Usage

From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing4Fragment.java

private void initVisualizer() {
    if (permissionManager.isAudioRecordGranted(getContext())) {
        mVisualizer = new Visualizer(audioSessionID());
        mVisualizer.setEnabled(false);/*from   w w w  .  jav  a2  s .c o  m*/
        mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
        mVisualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
            @Override
            public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {
            }

            @Override
            public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
                vizualview.updateVisualizer(fft);
            }
        }, Visualizer.getMaxCaptureRate() / 2, true, true);
    } else {
        Toast.makeText(getContext(), "AudioRecord permission not granted for visualizer", Toast.LENGTH_SHORT)
                .show();
        Log.d("Playing4Fragment", "permission not granted");
    }

}