Based on the answer of this question and this example I've implemented a Visualizer
using Xamarin.
myVisualizer = new Visualizer(0);
myVisualizer.SetEnabled(false);
myVisualizer.SetCaptureSize(Visualizer.GetCaptureSizeRange()[1]);
myVisualizer.SetDataCaptureListener(new VisualizerCapturer(), Visualizer.MaxCaptureRate, true, false);
The code works until I call myVisualizer.SetDataCaptureListener(...)
and the exception
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid. at Android.Media.Audiofx.Visualizer.SetDataCaptureListener (Android.Media.Audiofx.Visualizer+IOnDataCaptureListener listener, System.Int32 rate, System.Boolean waveform, System.Boolean fft) [0x0000b] in /Users/builder/data/lanes/4009/9578cdcd/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Media.Audiofx.Visualizer.cs:811
gets thrown. My IOnDataCaptureListener
implementation is without any code (I've made breakpoints inside the methods, no method gets called before the exception gets thrown)
public class VisualizerCapturer : Visualizer.IOnDataCaptureListener
{
public IntPtr Handle
{
get
{
throw new NotImplementedException();
}
}
public void Dispose()
{
throw new NotImplementedException();
}
public void OnFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate)
{
throw new NotImplementedException();
}
public void OnWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate)
{
throw new NotImplementedException();
}
}
I have absolutely no idea whats my problem and I hope anybody can help me with my problem.