[java] Volume control for bgm vs effects

Started by
0 comments, last by Fahrenheit451 12 years, 11 months ago
Hi all, I recently started using Java at work, so as a home project I wrote a tic-tac-toe game for my kids. I have added sound effects (burps, farts etc - the typical things a 6 year old boy wants to hear in a game :-) and a track he likes as the background music. I have added two slider controls for controlling the volumes of the background music and the effects, but can't seem to find a way to program this so each volume control affects only the sound it is supposed to. The volume control routines I find on the web control the volume of all sounds - almost like controlling the system volume. Does anyone have any experience or advice on how to go about this? These are WAV files, loaded with AudioStreamInput passed to AudioClip objects. Like I said, new to Java so I might be going about this the wrong way entirely! Thanks everyone.
Advertisement
Think I have figured this out. Not as elegant as it could be with plenty of opportunity to refactor later on and come up with a better strategy overall. Seems I need to use the MASTER_GAIN FloatControl type and not the VOLUME type for controlling volume. For each sound clip instantiated I call the getControl method for the MASTER_GAIN control type and set the gain accordingly. Requires some thought when you hook that up to a slider control, since gain is handled differently than a regular volume, but on the whole it works.

F451

This topic is closed to new replies.

Advertisement