I am trying to get the audio spectrum from the microphone stream on an Android. I am using TarsosDSP to do the heavy lifting. But cannot seem to get results that make any sense in the process event. I am trying to get 8 frequencies and show their magnitudes real time. I am using the SpectrumPeakAnalyser class but I dont know if thats the right one to use. Here is the relevant code on the process event:
public static int SAMPLE_RATE = 22050;
public static int BUFFER_SIZE = 1024;
public static int OVERLAP = 0;
AudioDispatcher dispatcher = AudioDispatcherFactory.FromDefaultMicrophone(SAMPLE_RATE, BUFFER_SIZE, OVERLAP); spectralPeakFollower = new SpectralPeakProcessor(BUFFER_SIZE, OVERLAP, SAMPLE_RATE); dispatcher.AddAudioProcessor(spectralPeakFollower);
And in the process event
var magnitudes = spectralPeakFollower.GetMagnitudes();
var freqencies = spectralPeakFollower.GetFrequencyEstimates();
float[] noiseFloor = SpectralPeakProcessor.CalculateNoiseFloor(magnitudes, BUFFER_SIZE / 2, 1f);
var localMaximaIndexes = SpectralPeakProcessor.FindLocalMaxima(magnitudes, noiseFloor);
var peaks = SpectralPeakProcessor.FindPeaks(magnitudes, freqencies, localMaximaIndexes, 8, 80);
I cannot seem to find any examples that fit this scenario as I do not care about peaks, I just want the real time magnitudes. Thank you for any help you can offer.