• Post Reply Bookmark Topic Watch Topic
  • New Topic

Controling volume of a audio clip

 
Clayton Carter
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would have thought that this would be an easy thing to do, but no amount of googling around has turned up any solutions.

I have written an application for a client that runs in full screen and allows the user to page through educational books in order to help teach kids to read. So far so good. Some phrases from the displayed materials are read back to the user and, again, so far so good. Normally, these sounds are read at the system volume. (ie, at whatever volume any other system sound would be played.)

The client, however, now wants the user to be able to adjust the volume in program. I have the user input and processing end of that working, 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 original gain of the clip and then adjusting that up or down for each clip.

So, my question really is: how do you suggest controlling sound volume within a program? All of my research has turned up nothing meaningful, which implies to me that it's kind of hard or even impossible, but that just doesn't seem right.

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

Thanks in advance,
Clayton
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try the overal sound level. First, start with looking up the speaker port (using Port.Info), then look for its volume control. Don't forget to reset its value after playing the clip though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!