0 Replies - 388 Views - Last Post: 22 October 2014 - 03:44 AM

#1 [email protected]  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-October 14

How to slow speed of recorded audio visualization in android?

Posted 22 October 2014 - 03:44 AM

public class VisualizerView1 extends View {
private byte[] mBytes;
private float[] mPoints;
private Rect mRect = new Rect();

private Paint mForePaint = new Paint();

public VisualizerView1(Context context) {
super(context);
init1();
}

private void init1() {
mBytes = null;

mForePaint.setStrokeWidth(2f);
mForePaint.setAntiAlias(true);
mForePaint.setColor(Color.rgb(0, 255, 128));
}

public void updateVisualizer(byte[] bytes) {
mBytes = bytes;
invalidate();
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

if (mBytes == null) {
return;
}

if (mPoints == null || mPoints.length < mBytes.length * 4) {
mPoints = new float[mBytes.length * 4];
}

mRect.set(0, 0, getWidth(), getHeight());

for (int i = 0; i < mBytes.length - 1; i++) {
mPoints[i * 4] = mRect.width() * i / (mBytes.length - 1);
mPoints[i * 4 + 1] = mRect.height() / 2
+ ((byte) (mBytes[i] + 128)) * (mRect.height() / 2) / 128;
mPoints[i * 4 + 2] = mRect.width() * (i + 1) / (mBytes.length - 1);
mPoints[i * 4 + 3] = mRect.height() / 2
+ ((byte) (mBytes[i + 1] + 128)) * (mRect.height() / 2) / 128;
}

canvas.drawLines(mPoints, mForePaint);
}



}

Code is working fine need to reduce the speed of the visualization in android..
i am able to record the voice from mic and play the recorded audio with visualization,
but the speed of visualization is to fast, how can i slow the speed of visualization.
Above code is used to draw the visualization in android..

Is This A Good Question/Topic? 0
  • +

Page 1 of 1