i am working with a library that records audio and i can listen each time a new byte array if buffer if filled so i get this callback :
public void onVoiceReceived(byte[] buffer) {
}
now i want to take the buffer and translate it to a level so i can draw the amplitude meter.
how can i translate this data?
i dont want to create another recorder and use the read()
command.
this is the drawing code
private void drawCircleView(Canvas canvas, double ampValue) {
// paint a background color
canvas.drawColor(android.R.color.holo_blue_bright);
// paint a rectangular shape that fill the surface.
int border = 0;
RectF r = new RectF(border, border, canvas.getWidth(), canvas.getHeight());
Paint paint = new Paint();
paint.setARGB(255, 100, 0, 0); // paint color GRAY+SEMY TRANSPARENT
canvas.drawRect(r, paint);
/*
* i want to paint to circles, black and white. one of circles will bounce, tile the button 'swap' pressed and then other circle begin bouncing.
*/
calculateRadiuses();
// paint left circle(black)
paint.setStrokeWidth(0);
paint.setColor(getResources().getColor(android.R.color.holo_blue_light));
canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, ampValue, paint);
}
thanks!