private void OnVisualizationData (IntPtr player, int channels, int samples, IntPtr data, int bands, IntPtr spectrum)
{
VisualizationDataHandler handler = data_available;
if (handler == null) {
return;
}
float [] flat = new float[channels * samples];
Marshal.Copy (data, flat, 0, flat.Length);
float [][] cbd = new float[channels][];
for (int i = 0; i < channels; i++) {
float [] channel = new float[samples];
Array.Copy (flat, i * samples, channel, 0, samples);
cbd[i] = channel;
}
float [] spec = new float[bands];
Marshal.Copy (spectrum, spec, 0, bands);
try {
handler (cbd, new float[][] { spec });
} catch (Exception e) {
Log.Exception ("Uncaught exception during visualization data post.", e);
}
}