如何从TarsosDSP获取音频频谱

时间:2018-08-28 21:26:13

标签: java fft tarsosdsp

我正在尝试从Android上的麦克风流中获取音频频谱。我正在使用TarsosDSP进行繁重的工作。但是似乎无法获得在流程事件中有意义的结果。我试图获得8个频率并实时显示其幅度。我正在使用SpectrumPeakAnalyser类,但我不知道这是否是正确的选择。以下是有关流程事件的相关代码:

    public static int SAMPLE_RATE = 22050;
    public static int BUFFER_SIZE = 1024;
    public static int OVERLAP = 0; 

AudioDispatcher调度程序= AudioDispatcherFactory.FromDefaultMicrophone(SAMPLE_RATE,BUFFER_SIZE,OVERLAP);                 spectrumPeakFollower =新的SpectralPeakProcessor(BUFFER_SIZE,OVERLAP,SAMPLE_RATE);                 dispatcher.AddAudioProcessor(spectralPeakFollower);

在处理事件中

        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);

我似乎找不到适合该场景的示例,因为我不在乎峰值,我只是想要实时幅度。感谢您提供的任何帮助。

0 个答案:

没有答案