Jump to content
  • Advertisement
Sign in to follow this  
Fahrenheit451

[java] Volume control for bgm vs effects

This topic is 2602 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!