The moose likes Applets and the fly likes Read wave file in as a float value Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Read wave file in as a float value" Watch "Read wave file in as a float value" New topic
Author

Read wave file in as a float value

Jody Monahan
Greenhorn

Joined: Feb 10, 2010
Posts: 20
Is it possible to read a .wav file into an applet as a float array value from a HTML page? I have a .wav file saved on a server and I would like to be able to manipulate the values of the file from an applet.

Anyone got any ideas?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32421
What would that float array contain - the pitch over time?

The javax.sound.sampled package has classes for dealing with WAV files; see http://www.exampledepot.com/egs/javax.sound.sampled/Load.html for an example. Some of the involved classes may let you get closer to the audio data.


Android appsImageJ pluginsJava web charts
Jody Monahan
Greenhorn

Joined: Feb 10, 2010
Posts: 20
Yes my float array would contain the amplitude over time ie an array with values between -1 and 1.

My question however is if it is possible to read a .wav file into the applet from a remote server. For example, if I have a HTML page that passes the .wav file as a parameter:



It is possible to get the value of the parameter "number" using the getParameter("number") method. Is it possible to read the contents of the .wav file into a float array from the HTML page?

Thanks.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32421
No, it's more complicated than that. The "From URL" part of the code sample shows how to load a file from the server.
Jody Monahan
Greenhorn

Joined: Feb 10, 2010
Posts: 20
Again, thanks for the reply Ulf. Is there any way, to your knowledge that you can get the AudioInputStream as a float array value?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32421
From an AudioInputStream you can obtain an AudioFormat object, about which its javadocs state "By examing the information stored in the audio format, you can discover how to interpret the bits in the binary sound data." There's also more information on how to go about this.
Jody Monahan
Greenhorn

Joined: Feb 10, 2010
Posts: 20
Thanks again Ulf, I'll look into it.
 
 
subject: Read wave file in as a float value
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com