Convert Audio samples from bytes to complex numbers?

后端 未结 1 763
孤街浪徒
孤街浪徒 2020-12-20 08:33

Greetings everyone,

I am currently developing a chromatic tuner for instruments/voice in Silverlight with a C# back-end. I am in the beginning stages and am having

相关标签:
1条回答
  • 2020-12-20 09:11

    This project on CodeProject might be of use to you as it's in C# and deals with audio processing via the Cooley-Turkey FFT algorithm.

    If you don't want to sift through it here is the byte to complex number bit:

    byte[] data = yourByteArray;
    double[] x = new double[data.Length];
    for (int i = 0; i < x.Length; i++)
    {
        x[i] = data[i] / 32768.0;
    }
    ComplexNumber[] data = new ComplexNumber[length];
    for (int i = 0; i < x.Length; i++)
    {
        data[j] = new ComplexNumber(x[i]);
    }
    

    I don't know much about sound processing so don't know whether the dividing by 32768 is unique to this solution or true in general.

    Also, although this will be 100% accurate, I don't know how well it performs. If that becomes an issue you might need to refactor.

    0 讨论(0)
提交回复
热议问题