从字节复数转换的音频采样? [英] Convert Audio samples from bytes to complex numbers?

查看:162
本文介绍了从字节复数转换的音频采样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候大家,

我目前正在开发Silverlight中的仪器/语音半音调谐器与C#后端。我在开始阶段,我有抢夺音频数据的问题。我使用的是AudioSink类实时捕捉启动时写的音频到内存流。我遇到的问题是转换这些字节流以复数中,以便它可以被送入一个F​​FT算法。我试图在这个岗​​位问题讨论的各种方式转换字节数组翻番但我不知道应该用哪种方法。

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 issues in grabbing the audio data. I am using an AudioSink class to write the audio to a memory stream when the live capture starts. The problem I am having is converting those bytes in the stream to complex numbers so that it can be fed into a FFT algorithm. I have tried the various way discussed in this post Problem to convert byte array to double but am not sure which method should be used.

从字节数组将复数的数组有什么建议?精度和速度是必须的(比速度更精确),因为我的项目会做这个过程的实时,以diplay球场的后期正在播放的声音中来了。

Any suggestions on going from a byte array to an array of complex numbers? Accuracy and speed is a must ( more accuracy than speed ) because the later stages of my project will do this process real time in order to diplay the pitch being played as the sound is coming in.

欢呼和感谢!

约什 -

推荐答案

该项目在CodeProject 可能会利用你,因为它是在C#和涉及通过库利,土耳其 FFT算法音频处理。

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

我不知道声音处理竟有如此别知道32768分割是否是唯一的这个解决方案或真一般。

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.

此外,虽然这将是100%准确的,我不知道它如何妥善施行。如果这成为一个问题,你可能需要重构。

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.

这篇关于从字节复数转换的音频采样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆