Jump to content

controlling volume

- - - - -

  • Please log in to reply
3 replies to this topic

#1
sana'a

sana'a

    Newbie

  • Members
  • PipPip
  • 19 posts
Hi everybody

i'm using Clip to play some wav files in a simple gui.
i thought it would be cool if i have a slide bar to control the volume so i googled that and found many examples like this:
(FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);

gainControl.setValue(-10.0f);

but i couldn't make it work:mad:

so,how i can adjust the volume while playing the audio using a slider bar?

#2
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Post a small program that shows how you are trying to use the Slider and get values from it.
What range of values do you want to get from the Slider?

#3
sana'a

sana'a

    Newbie

  • Members
  • PipPip
  • 19 posts
private void jSlider1MouseClicked(java.awt.event.MouseEvent evt) {                                      


        FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);

        gainControl.setValue(jSlider1.getValue());// TODO add your handling code here:

    } 

and the rage of the slider is (-10 to 10)

#4
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Can you make a small, complete program that shows how you want to get values from the slider?
Something that will compile and execute and show values as the slider is changed.
Just have it print out the values, no need for anything else.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users