• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to write a .WAV file

 
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 32
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just taken a very quick glance at this so it may not be anything like the tool you need - http://code.google.com/p/j-simple-wav-io/
 
Joe Areeda
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Mark!

That looks good at first glance. I'll report back if I can get it to do what I want.

Joe
 
Joe Areeda
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Mark! This does exactly what I need.

Do you remember your search string that found this? I tried a bunch of them.

Joe
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic