Convert Audio samples from bytes to complex numbers?

隐身守侯 提交于 2019-11-29 12:28:12

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!