0

I'm working on a mute button in my GUI and until now have not figured out a way that i can do this so i thought decreasing the decibels and increasing them back with each click. So when i click the mute button i have:

for (int i=1; i<clips.length; i++) {
                FloatControl gainControl =
                        (FloatControl) clips[i].getControl(FloatControl.Type.MASTER_GAIN);
                gainControl.setValue(-60.0f);
            }

and it works great. but when i do the opposite (meaning with +60.0f) i get IllegalArgumentException: Requested value 60.0 exceeds allowable maximum value 6.0206.

I load the clips like this:

AudioInputStream i1 = AudioSystem.getAudioInputStream(Game.class.getResource("clips/1.wav"));
    clips[1] = AudioSystem.getClip();
    clips[1].open(i1);

is there a way to bypass this with my method or does someone know a better way to do what i want? any help is greatly appreciated.

HavingNoHead
  • 117
  • 1
  • 8
  • Abstract class `javax.sound.sampled.FloatControl` has a private member variable named `maximum`. The class has a `getMaximum()` method but there is no `setMaximum(float)` method. The class constructor initializes the `maximum` value. So I'm guessing that you need to modify the way you are constructing your `FloatControl`. Forgive me but I could not find, in the code in your question, how you are populating the `clips` array and therefore I cannot be more specific. – Abra Apr 05 '21 at 10:21
  • @Abra thanks for the answer, I edited the question with the way I populate the clips. – HavingNoHead Apr 05 '21 at 11:02
  • @Abra anyways i managed to it by replacing the clip with a new one at the frame position of the old one, still i would like a better way to do this – HavingNoHead Apr 05 '21 at 11:26

0 Answers0