Android Visualizer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Visualizer class.

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;

10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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;
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
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(); 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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");
        } 
    } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setCaptureSize
 
    public VisualizerController(Context context, MediaPlayer mediaPlayer) {
        this.context = context;
        try { 
			audioSessionId = mediaPlayer.getAudioSessionId();
            visualizer = new Visualizer(audioSessionId);
        } catch (Throwable x) {
            Log.w(TAG, "Failed to create visualizer.", x);
        } 
 
        if (visualizer != null) {
            int[] captureSizeRange = Visualizer.getCaptureSizeRange();
            int captureSize = Math.max(PREFERRED_CAPTURE_SIZE, captureSizeRange[0]);
            captureSize = Math.min(captureSize, captureSizeRange[1]);
            visualizer.setCaptureSize(captureSize);
        } 
    } 
 
    public boolean isAvailable() { 
        return visualizer != null;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setCaptureSize, setDataCaptureListener, setEnabled
	  } 
	   
	  public static void initVisualizer( MediaPlayer player ){
		  VisualizerUtils.releaseVisualizer(); 
		  try{ 
			  mVisualizer =  new Visualizer(player.getAudioSessionId());
		  } 
		  catch(Exception e){
			  mVisualizer = null;
			  return; 
		  } 
 
		  mVisualizer.setEnabled(false);		  
 
		  mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
 
		  Visualizer.OnDataCaptureListener captureListener = new Visualizer.OnDataCaptureListener()
		  { 
			  @Override 
			  public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes,

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getCaptureSize, release, setCaptureSize
            int[] range = mVisualizer.getCaptureSizeRange();
            assertTrue(msg +": insufficient min capture size",
                    range[0] <= MAX_CAPTURE_SIZE_MIN);
            assertTrue(msg +": insufficient min capture size",
                    range[1] >= MIN_CAPTURE_SIZE_MAX);
            mVisualizer.setCaptureSize(range[0]);
            assertEquals(msg +": insufficient min capture size",
                    range[0], mVisualizer.getCaptureSize());
            mVisualizer.setCaptureSize(range[1]);
            assertEquals(msg +": insufficient min capture size",
                    range[1], mVisualizer.getCaptureSize());
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setCaptureSize, setDataCaptureListener, setEnabled
	private void setupVisualizerFxAndUi() { 
		if(!devExists()) 
		{ 
			return; 
		} 
		mVisualizer = new Visualizer(0);
		mVisualizer.setEnabled(false);
		int[] size = Visualizer.getCaptureSizeRange();
		mVisualizer.setCaptureSize(size[0]);
		mVisualizer.setDataCaptureListener(new OnDataCaptureListener() {
 
			@Override 
			public void onWaveFormDataCapture(Visualizer visualizer,
					byte[] waveform, int samplingRate) {
			} 
 
			@Override 
			public void onFftDataCapture(Visualizer visualizer, byte[] fft,
					int samplingRate) {
				int[] model = new int[40];

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android Visualizer Questions & Answers:

See Code Examples for Android Visualizer Methods: