How can I known whether it is a beat now of the current mp3 music in Android

138 views Asked by At

I'm trying to develop such a android app: when it is druming or beating now of the current playing music, I can do something. So I should analyse the current music first, and then I should decide whether it is beating now! I have test the Android Api Demo, using the MediaPlayer and Visualizer class I can get the original byte data, but how can I know whether it is beating now? I'm new here...sorry if I have not describe clearly and any answer is appreciative! Here is my partial code to refresh android view:

public void updateVisualizer(byte[] fft)
    {
        if(mFirst )
        {
            mInfoView.setText(mInfoView.getText().toString() + "\nCaptureSize: " + fft.length);
            mFirst = false;
        }
        byte[] model = new byte[fft.length / 2 + 1];

        model[0] = (byte) Math.abs(fft[0]);
        for (int i = 2, j = 1; j < mSpectrumNum;)
        {
            model[j] = (byte) Math.hypot(fft[i], fft[i + 1]);
            i += 2;
            j++;
        }
        mBytes = model;

        // I want to decide whether it is beating now
        /*if(beating){
            doSomeThing();
        }*/

        invalidate();
    }
0

There are 0 answers