Example usage for android.media.audiofx Visualizer getMaxCaptureRate

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

Introduction

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

Prototype

public static native int getMaxCaptureRate();

Source Link

Document

Returns the maximum capture rate for the callback capture method.

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);/*  ww  w. j  av a2s .  c  om*/
        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");
    }

}