Greetings,
I've been googling and grepping for an answer to what I think is a few lines of code.
My problem
I have data sampled in the audio range at various frequencies (256-65KHz) some of the data is actual audio from microphones but the rest is from various sensors. The scientists like to listen to this data as audio because it's a good way to cover lots of data and detect changes.
My plan
I have code already to get this data into an array. It's easy to scale and get it into a short or byte array. I think WAV is the simplest format, so write one of those and then use ffmpeg to convert it to .mp3 and .ogg so it can be served in an HTML5 <audio> tag or downloaded.
My question
Where can I find an example of how to take a
java array and write it as a wav file? I've been reading about JMF and javax.sound.sampled but everything I've seen starts with an existing sound file of some sort.
Matlab has a function "wavwrite(Y,FS,NBITS,WAVEFILE)" which is what I'd like to duplicate in Java. It is possible but inefficient to have my
servlet call a Matlab program to write the WAV and go from there. I've used that before when the algorithm is very complicated or the Matlab functions are not documented well enough to duplicate.
Thanks,
Joe