good java library for reading .wavs?

1,387 views
Skip to first unread message

filip krzysztof tomaszewski aka zambari

unread,
Aug 24, 2013, 4:41:54 PM8/24/13
to open-elect...@googlegroups.com
Hi Jeff,

Can you recommend a good library for reading wavs? I want to (some time in the future) write software visualizing samples played on the electribe in real time via midi input to java

I don't want to use audio in as its only one stereo pair and there is no way in sight to allow multiple audio inputs into java (none I know about). So the image drawing would be based in images - as your  software allows easy dumping of the .esx file into numbered .wavs - I could know when a sample change occur and swap for appropriate image. 
I need to reliably open a wav file and be able to freely access samples (it seems to me many libraries are optimized for playing the wav into audio buffer - no audio playback is needed here.

this would be done using processing

thanks for any suggestions

skratchdot.com

unread,
Aug 24, 2013, 5:24:57 PM8/24/13
to open-elect...@googlegroups.com
Java has built in support for most .wav/.aiff files using the javax.sound.* classes:

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;

You can see how I read in sample data from a file here:


Around line 801, I start to convert the stream to bytes, etc.

One thing the built in Java libraries don't have, is support for reading in special "chunks" of a .wav file.

I created a library called riff-wav-for-java that parses .wav files.  If you look at line 862 of that link I posted, you'll see how I grab loop points from files.  You could probably use that library to grab byte data, but I didn't really make a friendly API for that (kind of abandoned it since I only needed it for loop points).

Anyways, there's also the "Java Media Framework (JMF)", which is apparently the successor to the Java Sound libraries, but I don't have any experience with it.

You can also check Stack Overflow for what other people are doing.  I don't have a ton of experience messing with audio in Java (as I've only really used audio in Java for this project).  

Good luck!  Sounds like an interesting project you have planned.

filip krzysztof tomaszewski aka zambari

unread,
Aug 24, 2013, 5:41:04 PM8/24/13
to open-elect...@googlegroups.com
cheers, that's detailed help, exactly what I need, thank you

Reply all
Reply to author
Forward
0 new messages