关于 Java Sound API 的一些问题
我对 Java 声音 API 和音频编程的使用还比较陌生。我一直想知道是否可以使用 Java 的声音 API 执行以下操作:
- 提取音频文件所包含的各个频率的值。 (例如:频率范围 20Hz-20kHz 的振幅)
- 根据这些值执行操作,然后写入新的修改后的音频文件。
如果您想知道我为什么问这些,我计划使用基于群的优化算法创建自定义音频压缩格式。因此,对于那些能够给出更直接答案的人来说:可以使用 Java 的声音 API 创建音频压缩程序吗?
谢谢。
I'm relatively new here and to the usage of Java's Sound API and audio programming altogether. I have been wondering if it's possible to do the following things with Java's Sound API:
- extract the values of individual frequencies an audio file consists of. (ex: amplitude for frequency range 20Hz-20kHz)
- based on those values, perform manipulations, then write a new modified audio file.
If you're wondering why I'm asking these, I'm planning to create a custom audio compression format with the use of a swarm-based optimization algorithm. So for those who can give a more straightforward answer: would creating an audio compression program be possible using Java's Sound API?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
引用自 SO 的 JavaSound info. 页面。
服务提供者接口
Java Sound API 使用服务提供者接口来识别编码器和声音。声音格式和序列类型的解码器。这样,添加对新格式或类型的支持就像为其提供解码器和/或编码器一样简单,将 SPI 文件添加到其所在 Jar 的清单中,然后将 Jar 添加到运行时类中 -应用程序的路径。
因此,如果您可以提供编码器/解码器,那么可以。
Quote from the JavaSound info. page here at SO.
Service Provider Interface
The Java Sound API uses a Service Provider Interface to identify encoders & decoders for sound formats and sequence types. This way, adding support for a new format or type is as simple as providing a decoder and/or encoder for it, adding an SPI file to the manifest of the Jar it is in, then adding the Jar to the run-time class-path of the application.
So if you can provide the encoder/decoder, then yes.
您当然可以读取波形。 IE,对于 44.1 kHz 文件,每秒可以读取 44,100 个不同的样本值。我不知道 Java Sound API 会为您计算音频频率,但如果您已经要执行操作,您可能可以自己计算所需的任何内容。
几年前,我使用类似的方法来解码可疑的 SMPTE 时间码信号,打印出各个位和字段。 (基本上,我只需要跟踪值何时超过 0,以及持续多长时间。)
简而言之,是的,创建一个音频压缩程序肯定是可能的 - 尽管我知道很多人会对选择这样做感到惊讶在爪哇。
You can certainly read the waveforms. I.E., for a 44.1 kHz file, you could read 44,100 different sample values per second. I don't know that the Java Sound API will calculate audio frequencies for you, but if you're already going to be performing manipulations, you can probably calculate whatever you need yourself.
A few years back, I had used something along these lines to decode a suspect SMPTE time code signal, printing out the various bits and fields. (Basically, I just had to track whenever the value crossed 0, and for how long.)
In short, yes, creating an audio compression program would certainly be possible - though I know many people who would be surprised at the choice to do this in Java.