字节数组到双精度数组
我有一个字节数组,表示 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果每个字节实际上代表一个有符号的 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 thatbyte
can) - there isn't really anything else you can do.