Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JFrame - Change the volume of the audio file being played with JSlider

  1. #1
    Junior Member
    Join Date
    May 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JFrame - Change the volume of the audio file being played with JSlider

    I want to try using the JSlider as a volume control, but don't quite know how to continue.

        public void stateChanged(ChangeEvent e) {
            //Main.mii_floatControl.setValue(20f * (float) Math.log10(Main.slider.getValue()) / 10);
            Main.mii_floatControl.setValue(Main.slider.getValue() / 10);
            System.out.println("" + Main.mii_floatControl.getValue());
     
        }

    I've tried quite a bit, when converting for Main.mii_floatControl.setValue() to have a suitable value calculated, but neither the volume is changed, nor do I know the correct formula for it. Maybe I have to do it completely differently?

    But if it is done very differently, an example would be very helpful

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: JFrame - Change the volume of the audio file being played with JSlider

    What are the desired values you want to pass to the setValue() method?
    I assume that the mii_floatControl variable is an instance of the volume control class.

    What values do you get from the JSlider?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Using a JSlider to change the red contrast of an image on a jLabel
    By Bruz69er in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 22nd, 2012, 01:40 AM
  2. How do I upload an audio wav file?!
    By mcgras22 in forum File Input/Output Tutorials
    Replies: 5
    Last Post: June 15th, 2012, 08:29 PM
  3. Reading Audio file
    By madhura.yerawar in forum Java Theory & Questions
    Replies: 0
    Last Post: January 21st, 2012, 01:05 AM
  4. How to play Audio file?
    By sush in forum Object Oriented Programming
    Replies: 3
    Last Post: June 29th, 2011, 08:11 AM
  5. Change JFrame components problem
    By bruno88 in forum AWT / Java Swing
    Replies: 0
    Last Post: June 30th, 2009, 01:25 PM

Tags for this Thread