Best code examples for Android Visualizer class (android.media.audiofx.Visualizer)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Visualizer class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Visualizer examples from Open Source projects
This code example shows how to use the following methods: getScalingMode, release, setScalingMode
    public void test1_2ScalingMode() throws Exception { 
        boolean result = false;
        String msg = "test1_2ScalingMode()";
        getVisualizer(0); 
        try { 
            int res = mVisualizer.setScalingMode(Visualizer.SCALING_MODE_AS_PLAYED);
            assertEquals(msg + ": setting SCALING_MODE_AS_PLAYED failed",
                    res, Visualizer.SUCCESS);
            int mode = mVisualizer.getScalingMode();
            assertEquals(msg + ": setting SCALING_MODE_AS_PLAYED didn't stick",
                    mode, Visualizer.SCALING_MODE_AS_PLAYED);
 
            res = mVisualizer.setScalingMode(Visualizer.SCALING_MODE_NORMALIZED);
            assertEquals(msg + ": setting SCALING_MODE_NORMALIZED failed",
                    res, Visualizer.SUCCESS);
            mode = mVisualizer.getScalingMode();
            assertEquals(msg + ": setting SCALING_MODE_NORMALIZED didn't stick",
                    mode, Visualizer.SCALING_MODE_NORMALIZED);
 
            result = true;

9
CodeRank
This code example shows how to use the following methods: getSamplingRate, setCaptureSize
    private int mCapturePeriodMs;
    private byte[] mFft = new byte[CAPTURE_SIZE];
 
    public EnergyProbe(int session) {
        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");
        } 
    } 
 
    public int capture(int freq) throws InterruptedException {
        int energy = 0;
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getScalingMode, release, setScalingMode
    public void test1_2ScalingMode() throws Exception { 
        boolean result = false;
        String msg = "test1_2ScalingMode()";
        getVisualizer(0); 
        try { 
            int res = mVisualizer.setScalingMode(Visualizer.SCALING_MODE_AS_PLAYED);
            assertEquals(msg + ": setting SCALING_MODE_AS_PLAYED failed",
                    res, Visualizer.SUCCESS);
            int mode = mVisualizer.getScalingMode();
            assertEquals(msg + ": setting SCALING_MODE_AS_PLAYED didn't stick",
                    mode, Visualizer.SCALING_MODE_AS_PLAYED);
 
            res = mVisualizer.setScalingMode(Visualizer.SCALING_MODE_NORMALIZED);
            assertEquals(msg + ": setting SCALING_MODE_NORMALIZED failed",
                    res, Visualizer.SUCCESS);
            mode = mVisualizer.getScalingMode();
            assertEquals(msg + ": setting SCALING_MODE_NORMALIZED didn't stick",
                    mode, Visualizer.SCALING_MODE_NORMALIZED);
 
            result = true;

7
CodeRank
This code example shows how to use the following methods: setCaptureSize, setDataCaptureListener
                ViewGroup.LayoutParams.FILL_PARENT,
                (int)(VISUALIZER_HEIGHT_DIP * getResources().getDisplayMetrics().density)));
        mLinearLayout.addView(mVisualizerView);
 
        // Create the Visualizer object and attach it to our media player. 
        mVisualizer = new Visualizer(mMediaPlayer.getAudioSessionId());
        mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
        mVisualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
            public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes,
                    int samplingRate) {
                mVisualizerView.updateVisualizer(bytes);
            } 
 
            public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {}
        }, Visualizer.getMaxCaptureRate() / 2, true, false);
    } 
 
    @Override 
    protected void onPause() { 
        super.onPause(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getEnabled, setCaptureSize, setEnabled
        mRawVizData = new byte[size];
        mFormattedVizData = new int[size];
 
        mVisualizer = null;
        try { 
            mVisualizer = new Visualizer(0);
            if (mVisualizer != null) {
                if (mVisualizer.getEnabled()) {
                    mVisualizer.setEnabled(false);
                } 
                mVisualizer.setCaptureSize(mRawVizData.length);
            } 
        } catch (UnsupportedOperationException e) {
            Log.e("AudioCapture", "Visualizer cstor UnsupportedOperationException");
        } catch (IllegalStateException e) {
            Log.e("AudioCapture", "Visualizer cstor IllegalStateException");
        } catch (RuntimeException e) {
            Log.e("AudioCapture", "Visualizer cstor RuntimeException");
        } 
    } 
Full Snippet Info
6
CodeRank
Related Android Visualizer Questions & Answers:
See Code Examples for Android Visualizer Methods: