How can I read info from .wave file using JavaSound (Java, Java Sound)

自闭症网瘾萝莉.ら 提交于 2021-02-10 05:34:27

问题


Hi I need to read SampleRate, SignalFrequency and Amplitude from .wave file. How can I do that using JavaSound?


回答1:


You can get the sampling rate by getting a handle on the AudioFormat object:

AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("test.wav"));
AudioFormat audioFormat = audioInputStream.getFormat();

Once you have that, you can get the sample rate as follows:

float sampleRate = audioFormat.getSampleRate();

As for the amplitude, that is basically the raw .wav file data, which you can access directly from the audioInputStream by calling any of its read() methods.



来源:https://stackoverflow.com/questions/7275647/how-can-i-read-info-from-wave-file-using-javasound-java-java-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!