Back to project page audio-analyzer-for-android.
The source code is released under:
Apache License
If you think the Android project audio-analyzer-for-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.google.corp.productivity.specialprojects.android.samples.fft; /*from w w w. j a va 2 s. co m*/ import android.os.SystemClock; import android.util.Log; public class FramesPerSecondCounter { long frameCount; long timeOld, timeUpdateInterval; // in ms double fps; String TAG_OUTSIDE; FramesPerSecondCounter(String TAG) { timeUpdateInterval = 2000; TAG_OUTSIDE = TAG; frameCount = 0; timeOld = SystemClock.uptimeMillis(); } // call this when number of frames plus one public void inc() { frameCount++; long timeNow = SystemClock.uptimeMillis(); if (timeOld + timeUpdateInterval <= timeNow) { fps = 1000 * (double) frameCount / (timeNow - timeOld); Log.i(TAG_OUTSIDE, "FPS: " + Math.round(100*fps)/100.0 + " (" + frameCount + "/" + (timeNow - timeOld) + "ms)"); timeOld = timeNow; frameCount = 0; } } public double getFPS() { return fps; } }