I'm trying to create an audio viewer. I found this code but I can't implement it in B4a
I need help.
I need help.
Java code:
protected void onDraw(Canvas canvas) {
if (bytes != null) {
float barWidth = getWidth() / density;
float div = bytes.length / density;
paint.setStrokeWidth(barWidth - gap);
for (int i = 0; i < density; i++) {
int bytePosition = (int) Math.ceil(i * div);
int top = getHeight() +
((byte) (Math.abs(bytes[bytePosition]) + 128)) * getHeight() / 128;
float barX = (i * barWidth) + (barWidth / 2);
canvas.drawLine(barX, getHeight(), barX, top, paint);
}
super.onDraw(canvas);
}
}