Answer the question
In order to leave comments, you need to log in
How to make good music rendering?
Good day to all!
I am trying to render a music file. I don't know if I'm calling it right but I mean
when the line dances to the music :D.
Everything works but not qualitatively, I do not like it. I do this: then I public class VisualizerView extends View
override the method
@Override
protected void onDraw(Canvas canvas) {
for (int i = 0; i < bytes.length - 1; i++) {
mPoints[i * 4] = rect.width() * i / (bytes.length - 1);
mPoints[i * 4 + 1] = rect.height() / 2
+ ((byte) (bytes[i] + 128)) * (rect.height() / 2) / 128;
mPoints[i * 4 + 2] = rect.width() * (i + 1) / (bytes.length - 1);
mPoints[i * 4 + 3] = rect.height() / 2
+ ((byte) (bytes[i + 1] + 128)) * (rect.height() / 2)
/ 128;
}
canvas.drawLines(mPoints, mPaint);
Answer the question
In order to leave comments, you need to log in
The problem is that you are taking bytes[] in an encoded format. For such a thing - you need to write a decoder yourself in the native space, and do playback, skipping the decoded (you can get it using some codec, for example, for mp3 - lime) bytes through the buffer, drawing the picture you need along the way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question