Which API to use?

Hi guys! I really need quick help with sound in Java. I’m working with DSP (Digital Signal Processing) and guys in my university want to see the implementation of my ideas (all works fine in theory, but you know those kind of professors they just want to see the “experiment”).

So, i need to read wave data from a wav file (that’s no problem doing this, I’ve already wrote an implementation for this).

Then I modify (filter) the wave data somehow…

Then I need to playback a part of modified wave data. This is a problem… (I really don’t know how to do this). I also need some kind of visualization of playback progress, so I must be able to monitor the progress somehow…

Please suggest some kind of API (non-commercial, for educational use at least).

Its really hard to develop such a software in a night, but I need to do my best because you know those professors!

As I understand it, you need to stream the data from the wav file, filter it, and play it in real time, correct?
I once wrote a library for real time sound synthesis, featuring all kinds of ‘modules’ for filtering, envelopes, LFO, FM, AM etc. I’m not sure I implemented a class for streaming wav’s yet, but this would be quite trivial to add. It can stream from the audio card though, for example the mic input or wav output.
If you can use it to see how you can use javasound for things like that, let me know.

Wow! That’s great piece of work, I guess! Could you post few code snippets that explain how to stream from audio card?! Or give some links to related materials? Was it implemented in raw java, or the implementation used JNI and platform-dependent code?

you could go for the OpenAL API, the LWJGL library has pretty good openal support. http://www.lwjgl.org

The sources are here :
http://www.gagaplay.com/SoftSyn.zip

In the org.modsyn.test package there are some examples.

The library is pure java. It has its JavaSound implementation abstracted away, so it should be possible to create modules for streaming to OpenAL for example.

EDIT:
For streaming from your sound card using JavaSound: org.modsyn.modules.SoundGrabber
For streaming to your sound card using JavaSound: org.modsyn.modules.masters.ToJavaSound

Erkid!

This is really great code! Thanks a lot, I like your architectural solutions very much, looking at your code I’ve finished forming my own architectural concepts! Thank you very much.

You’re welcome, I’m glad it was of any use. :slight_smile:

As for the architectural side of things, there’s room for improvement.
I still have to get rid of the ControlInput interface and connect everthing with just Triggers and SignalInputs. It’ll make things even more flexible (no need for the LFO anymore for example, as you can then just use an Oscillator for the same thing, no need for FMOperator as you can then achieve the same thing with multiple oscillators etc).
And then there was still the plan to make everything XML configurable, so that you can just link the lib to your game with the sound effects in the form of small XML files which describe the patching & params etc for the sound effects (which can then be pre-rendered).
Maybe I’ll still do that sometime…