Java读取wav文件
我想用 Java 读取 wav 文件,并且将使用 K-means 对它们进行分类。
我怎样才能读取Java中的wav文件并将它们分配到一个数组或类似的东西(你可以建议它的想法)来对它们进行分类?
编辑:我想使用 API 来读取 wav 文件和 K-means。
I want to read wav files in Java and I am going to classify them with K-means.
How can I read wav files in Java and assign them into an array or something like that(you can suggest ideas for it) to classify them?
EDIT: I want to use APIs for reading wav files and for K-means.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
官方 Java Sound 程序员指南逐步阅读并编写音频文件。
A Greensted 的这篇文章:用 java 读取和写入 Wav 文件 应该会有所帮助。 WavFile 类非常有用,可以对其进行调整以返回整个数据数组而不是缓冲的片段。
The official Java Sound Programmer Guide walks through reading and writing audio files.
This article by A Greensted: Reading and Writing Wav Files in java should be helpful. The WavFile class is very useful and it can be tweaked to return the entire data array instead of buffered fragments.
相当于matlab的wavread函数:
http://web.archive.org/web/20120531113946/http://www.builogic.com/java/javasound-read-write.html
Equivalent to matlab's wavread function:
http://web.archive.org/web/20120531113946/http://www.builogic.com/java/javasound-read-write.html
您可以使用 javax sound 库和 FileInputStream 读取声音文件
(在这里找到了一个很好的示例)
并将波形文件视为位(0,1)或字节的向量..使用多序列对齐( Wiki)在每个位/字节流之间创建一个距离矩阵,从那里开始,聚类应该是直接的。
问题是,这种方法对噪声等非常敏感,但值得一试......
You could read the sound files using javax sound library and FileInputStream
(found a nice example here)
and treat the wave files as a vector of bits (0,1) or bytes.. using multiple sequence alignment (Wiki) create a distance matrix between every stream of bits/bytes, and from there, the clustering should be straight forward.
The Problem is, that this method is very sensitive to noise, etc, but it is worth a shot...
不确定这是否会对某人有帮助。 Java JDK已经提供了 AudioSystem 类。
我用它作为测试的一部分来检查生成的 WAV 属性,
Not sure if this will help someone. Java JDK already provides AudioSystem class.
I used this as part of my tests to check generated WAV properties,