创建数据列表以使用AdioGraph UWP传递到FFT

时间:2019-04-30 15:53:42

标签: c# audio uwp fft

我必须将数据传递给将计算光谱的fft方法。我尝试了错误的思考。我需要了解如何正确传递数据。

我怎么知道存在三个主要频率组:低,中和高?

代码:

List<double> List_db_For_FFT = new List<double>();
int Number_Of_db_List = 0;

private void AudioGraph_QuantumProcessed(AudioGraph sender, object args)
{
    AudioFrame frame = frameOutputNode.GetFrame();
    ProcessFrameOutput(frame);
}

unsafe private void ProcessFrameOutput(AudioFrame frame)
{
    using (AudioBuffer buffer = frame.LockBuffer(AudioBufferAccessMode.Write))
    using (IMemoryBufferReference reference = buffer.CreateReference())
    {
        byte* dataInBytes;
        uint capacityInBytes;
        float* dataInFloat;

        // Get the buffer from the AudioFrame
        ((IMemoryBufferByteAccess)reference).GetBuffer(out dataInBytes, out capacityInBytes);

        dataInFloat = (float*)dataInBytes;

        List_db_For_FFT.Clear();

        for (int i = 0; i <= 32; i++)
        {
            List_db_For_FFT.Add(dataInFloat[i]);
        }
    }
}

private void SpectrumTimer_Tick(object sender, object e)
{
    Debug.WriteLine("List number: " + Number_Of_db_List.ToString());
    for (int a = 0; a <= List_db_For_FFT.Count -1; a++)
    {
        Debug.WriteLine(List_db_For_FFT[a]);
    }
    Number_Of_db_List += 1;
}

在我写这篇文章时,从前32个数据(因为它必须是2的幂)的意义上看,我似乎会有所随机化。

(我未包括FFT代码,因为这是下一步,我想了解如何正确传递数据)

谢谢!

0 个答案:

没有答案