0

我正在尝试从 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); SpectralPeakFollower = new 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);

我似乎找不到任何适合这种情况的例子,因为我不关心峰值,我只想要实时幅度。感谢您提供的任何帮助。

4

0 回答 0