开发者

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

开发者 https://www.devze.com 2023-04-01 03:49 出处:网络
Hi I need to read SampleRate,开发者_C百科 SignalFrequency and Amplitude from .wave file. How can I do that using JavaSound?You can get the sampling rate by getting a handle on the AudioFormat object:

Hi I need to read SampleRate,开发者_C百科 SignalFrequency and Amplitude from .wave file. How can I do that using JavaSound?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号