字节数组到双精度数组

发布于 2024-10-04 22:09:56 字数 210 浏览 5 评论 0原文

我有一个字节数组,表示 .wav 文件中的数据。我想将其转换为双精度数组,以便我可以对其进行 FFT 等操作以确定一个文件是否包含在另一个文件中。

现在,我只是将字节转换为双精度,这给了我不错的结果,但没有我想要的那么精确。我知道这是不正确的转换,而且我觉得它导致我丢失数据,因为字节和双精度代表的内容不同。

在进行 FFT 相关之前,如何正确地将字节数组转换为双精度数组?

I have an array of bytes representing data from a .wav file. I want to convert it to an array of doubles, so that I can do operations such as FFT on it to determine whether one file is contained in the other.

Right now, I simply cast the bytes to doubles, which gives me decent results, but not as precise as I would like. I know this is improper conversion, and I feel like it is causing me to miss data, because of the difference in what bytes and doubles represent.

How can I convert the byte array to a double array properly before doing the FFT correlation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清泪尽 2024-10-11 22:09:56

如果每个字节实际上代表一个有符号的 8 位样本值,那么在记录样本时数据就已经丢失,并且转换为 double 并没有什么不正确或不精确的地方(可以< /em> 准确地表示 byte 可以的所有值) - 您实际上无能为力。

If each byte actually represents a signed 8-bit sample value, then the data has been lost when the sample was recorded, and there is nothing improper or imprecise about casting to double (which can accurately represent all values that byte can) - there isn't really anything else you can do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文