title: AbstractLine Unsupported control type: Master Gain Java
body: <p>I am having an error when using <code>Clip.getControl()</code> as per:-</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import javax.sound.sampled.AudioInputStream;
  import javax.sound.sampled.AudioSystem;
  import javax.sound.sampled.Clip;
  import javax.sound.sampled.FloatControl;
  import javax.sound.sampled.LineUnavailableException;
  import javax.sound.sampled.UnsupportedAudioFileException;
  
  public class HitPlayer {
      private AudioInputStream ais;
      private Clip clip;
      private FloatControl gain;
  
      public HitPlayer(String fname){
          try {
              ais = AudioSystem.getAudioInputStream(new File(fname));
              clip = AudioSystem.getClip();
              gain = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
          } catch(UnsupportedAudioFileException e){
              System.err.println("File format not accepted");
          } catch(IOException e){
              System.err.println("IO error");
          } catch(LineUnavailableException e){
              System.err.println("Line unavailable");
          }
      }
  
      public void setGain(float db){
          gain.setValue(db);
      }
  
      public void reset(){
          try {
              ais.reset();
          } catch (IOException e) {
              System.err.println("IO error when resetting");
          }
      }
  
      public void play(){
          clip.start();
      }
  }
  </code></pre>
  
  <p>The stacktrace is as follows:-</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Unsupported control type: Master Gain
  at com.sun.media.sound.AbstractLine.getControl(AbstractLine.java:164)
  at beat.HitPlayer.&lt;init&gt;(HitPlayer.java:21)
  at beat.DrumMachine.&lt;init&gt;(DrumMachine.java:18)
  at beat.Main.main(Main.java:14)
  </code></pre>
  
  <p>I have been trying to trace the error by checking the code for OpenJDK on grepcode; <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/com/sun/media/sound/AbstractLine.java#AbstractLine" rel="nofollow noreferrer" title="AbstractLine grepcode">AbstractLine grepcode.com</a> and the related classes.</p>
  
  <p>I was wondering if anybody had ran into this problem, I am using 
  <code>java version "1.7.0_07"
  OpenJDK Runtime Environment (IcedTea7 2.3.2) (Slackware)
  OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)</code> if that makes a difference.</p>
  
  <p>I am basically trying to access the gain or volume controls via <code>gain = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);</code>. The error persists regardless of whether I am using <code>MASTER_GAIN</code> or <code>VOLUME</code></p>
  
  <p>Regards</p>