Controlling audio clip volume in Java 1.4

I would have thought it would be easy to do this, but no amount of searching could find any solutions.

I wrote a client application that runs in full screen mode and allows the user to view study books to help students read. So far, so good. Some phrases from the displayed materials are readable to the user and, again, are so good. Usually these sounds are read on the system volume. (i.e. any other sound in the system will be played at any volume.)

The client, however, now wants the user to be able to adjust the volume in the program . I have a UI and a processing workflow, but I'm having a hard time adjusting the volume of the clips being played in a meaningful way. Right now, I have a funky setup that involves reading the initial gain of a clip and then adjusting that up or down for each clip. While this does adjust the volume, it doesn't seem to be the case in relation to the system volume - all sounds are much quieter than the system volume.

So my question is actually: how do you suggest controlling the volume of the audio within the program? ... All my research has turned out to be of no value, which implies that it's kind of difficult or even impossible, but it just doesn't feel right.

Oh, the details: I am reading into WAV as AudioInputStreams and playing them as java.sound.sampled.Clip. I am controlling the gain using FloatControl.Type.MASTER_GAIN. (FloatControl.Type.VOLUME is not supported.) I am stuck using Java 1.4.

+2


source to share


2 answers


You can also see if there is an earlier version of the Java Media Framework (JMF) that will support Java 1.4 ... it might provide you with a richer audio environment.

Also, you say that you are stuck in 1.4 ... you can see if there is a way you can upgrade to Java 5 or 6, although you can test either one first on your local machine to see if They are helping.



I guess the last suggestion is to find some Java game development sites and post your question there; I would have thought they would sort things out ... although you might as well get a lot of "update your jvm" answers there too. :-)

Good luck.

+1


source


This is OS specific thing and you will have to use either JNI or J / Invoke or JNIWrapper or jna or ...



0


source







All Articles