Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:21:05+00:00 2026-06-17T04:21:05+00:00

Java Sound offers FloatControl instances for various sound line functionality, and both a MASTER_GAIN

  • 0

Java Sound offers FloatControl instances for various sound line functionality, and both a MASTER_GAIN & VOLUME control type.

Can these controls be used to change the system volume?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:21:06+00:00Added an answer on June 17, 2026 at 4:21 am

    No, it cannot. Here is source adapted from an answer to Adjusting master volume on coderanch. The source iterates the available lines, checks if they have a control of the right type, and if so, puts them in a GUI attached to a JSlider

    import java.awt.*;
    import javax.swing.*;
    import javax.sound.sampled.*;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    
    public class SoundMixer {
    
        public Component getGui() {
            JPanel gui = new JPanel(new GridLayout(0,1));
    
            Mixer.Info[] mixers = AudioSystem.getMixerInfo();
            System.out.println(
                    "There are " + mixers.length + " mixer info objects");
            for (Mixer.Info mixerInfo : mixers) {
                System.out.println("mixer name: " + mixerInfo.getName());
                Mixer mixer = AudioSystem.getMixer(mixerInfo);
                Line.Info[] lineInfos = mixer.getSourceLineInfo();
                for (Line.Info lineInfo : lineInfos) {
                    System.out.println("  Line.Info: " + lineInfo);
                    try {
                        Line line = mixer.getLine(lineInfo);
                        FloatControl volCtrl = (FloatControl)line.getControl(
                                FloatControl.Type.MASTER_GAIN);
                        VolumeSlider vs = new VolumeSlider(volCtrl);
                        gui.add( new JLabel(volCtrl.toString()) );
                        gui.add( vs.getVolume() );
                        System.out.println(
                                "    volCtrl.getValue() = " + volCtrl.getValue());
                    } catch (LineUnavailableException e) {
                        e.printStackTrace();
                    } catch (IllegalArgumentException iaEx) {
                        System.out.println("    " + iaEx);
                    }
                }
            }
    
            return gui;
        }
    
        public static void main(String[] args) {
            Runnable r = new Runnable() {
    
                @Override
                public void run() {
                    SoundMixer sm = new SoundMixer();
                    Component c = sm.getGui();
                    JOptionPane.showMessageDialog(null, c);
                }
            };
            // Swing GUIs should be created and updated on the EDT
            // http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html
            SwingUtilities.invokeLater(r);
        }
    }
    
    class VolumeSlider {
    
        JSlider volume;
    
        VolumeSlider(final FloatControl volumeControl) {
            volume = new JSlider(
                    (int) volumeControl.getMinimum() * 100,
                    (int) volumeControl.getMaximum() * 100,
                    (int) volumeControl.getValue() * 100);
            ChangeListener listener = new ChangeListener() {
    
                @Override
                public void stateChanged(ChangeEvent e) {
                    float val = volume.getValue() / 100f;
                    volumeControl.setValue(val);
                    System.out.println(
                            "Setting volume of " + volumeControl.toString() + 
                            " to " + val);
                }
            };
            volume.addChangeListener(listener);
        }
    
        public JSlider getVolume() {
            return volume;
        }
    }
    

    On this Windows 7 machine I get two controls, both from the “Java Sound Audio Engine”. Neither has any effect on the current system volume.

    run:
    There are 4 mixer info objects
    mixer name: Primary Sound Driver
      Line.Info: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
        java.lang.IllegalArgumentException: Unsupported control type: Master Gain
      Line.Info: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
        java.lang.IllegalArgumentException: Unsupported control type: Master Gain
    mixer name: Speakers (VIA High Definition Audio)
      Line.Info: interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
        java.lang.IllegalArgumentException: Unsupported control type: Master Gain
      Line.Info: interface Clip supporting 8 audio formats, and buffers of at least 32 bytes
        java.lang.IllegalArgumentException: Unsupported control type: Master Gain
    mixer name: Java Sound Audio Engine
      Line.Info: interface SourceDataLine supporting 8 audio formats
        volCtrl.getValue() = 0.0
      Line.Info: interface Clip supporting 8 audio formats, and buffers of 0 to 4194304 bytes
        volCtrl.getValue() = 0.0
    mixer name: Port Speakers (VIA High Definition A
    Setting volume of Master Gain with current value: 0.0 dB (range: -80.0 - 13.9794) to 0.0
    Setting volume of Master Gain with current value: 0.0 dB (range: -80.0 - 13.9794) to -0.41
    Setting volume of Master Gain with current value: 0.0 dB (range: -80.0 - 13.9794) to -0.68
    ...
    

    Swap FloatControl.Type.MASTER_GAIN for FloatControl.Type.VOLUME to see.. no controls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From How can I play sound in Java? Is it possible to have resouce
How do I generate my own sound by frequency in Java? I can play
Hi I've been writing a chat client and wanted to test the Java Sound
Hi I am completely new to Java, so sorry if my question may sound
I'm making Braid in Java. If you rewind the time, the sound plays backward.
Example: For(int i=0; i<4; i++) playSound(Sound.wav); I have the following classes: Main import java.io.IOException;
JAVA : is there a difference between the two references p && pp? PrintStream
Appears that java's sound API's work well for single streams, and even for setting
I want to record sound on my Java ME App on K770i. So I
How do I get a sound file's total time in Java? --UPDATE Looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.