I am working on Android music player. I am trying to convert audio byte to rgb color so that I can show it in wave form while audio is playing. I am using felixpalmer API currently and it's able to generate single color waveform.
Here is the code:
private void setupVisualizerFxAndUI() {
// Create the Visualizer object and attach it to our media player.
Paint linePaint = new Paint();
linePaint.setStrokeWidth(2f);
linePaint.setAntiAlias(true);
linePaint.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
final LineRenderer lineRenderer = new LineRenderer(linePaint, true);
mVisualizerView.addRenderer(lineRenderer);
mVisualizer = new Visualizer(mediaPlayer.getAudioSessionId());
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
mVisualizer.setDataCaptureListener(
new Visualizer.OnDataCaptureListener() {
public void onWaveFormDataCapture(Visualizer visualizer,
byte[] bytes, int samplingRate) {
mVisualizerView.updateVisualizer(bytes);
onFFTData(bytes, lineRenderer);
}
public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
//onFFTData(bytes, lineRenderer);
}
}, Visualizer.getMaxCaptureRate() / 2, true, false);
}
Please point me to some resource where I can read about how can I generate dynamic rgb colors from this audio byte code. So that my music player can show waves in dynamic color instead of singer color as it's showing currently.