banner



How To Change The Volume Of Sound In Jva

Best Java code snippets using javax.audio.sampled.Line.getControl (Showing top 20 results out of 315)

  • Add together the Codota plugin to your IDE and go smart completions
                    

individual void myMethod ()

{

}

                                                                                                                                                                                                                            import                                                                                      javax.sound.sampled.*;                                                                                                                                                          AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(                                                                                                                                                                                      new                                                                                      File(                                                              "some_file.wav"                                                              ));                                                                                                  Prune prune = AudioSystem.getClip();                                                        clip.open up(audioInputStream);                                                        FloatControl gainControl =                                                                                                                          (FloatControl) clip.                                                              getControl                                                              (FloatControl.Blazon.MASTER_GAIN);                                                                                                                                            gainControl.setValue(-                                                              x.0f                                                              );                                                                                                                                                                                                          clip.start();                                  
                                                                                                                                        FloatControl volumeControl = (FloatControl) sourceDataLine.                                                              getControl                                                              (FloatControl.Blazon.MASTER_GAIN);                                                                                                                                            volumeControl.setValue(                                                              100.0f                                                              );                                                                                                                                    
                                                                                                                                                                                                      try                                                                                      {                                                                                                                      Line line = mixer.getLine(lineInfo);                                                                                                                          FloatControl volCtrl = (FloatControl)line.                                                              getControl                                                              (                                                                                                                      FloatControl.Type.MASTER_GAIN);                                                                                                                          VolumeSlider vs =                                                                                    new                                                                                      VolumeSlider(volCtrl);                                                                                                                                    
                                                                                                                                                                                                                            import                                                                                      javax.sound.sampled.Prune;                                                                                                                                            import                                                                                      javax.audio.sampled.FloatControl;                                                                                                                                                          ...                                                                                                                                                          private                                                                                      Clip clip                                                                                                                                                                                                    public                                                                                                                                                  float                                                                                      getVolume() {                                                                                                                                                                    FloatControl gainControl = (FloatControl) clip.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                                                                                                                                                render                                                                                      (                                                              float                                                              ) Math.pow(                                                              10f                                                              , gainControl.getValue() /                                                                                    20f                                                              );                                                                                                  }                                                                                                                                                          public                                                                                                                                                  void                                                                                      setVolume(                                                              float                                                                                      book) {                                                                                                                                                                                                                                if                                                                                      (book <                                                                                    0f                                                                                      || book >                                                                                    1f                                                              )                                                                                                                                                                                                                                throw                                                                                                                                                  new                                                                                      IllegalArgumentException(                                                              "Volume not valid: "                                                                                      + volume);                                                                                                                                                                    FloatControl gainControl = (FloatControl) clip.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                                                                                    gainControl.setValue(                                                              20f                                                                                      * (                                                              float                                                              ) Math.log10(book));                                                                                                  }                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            protected                                                                                                                                                  static                                                                                                                                                  void                                                                                      adjustVolume (Line line,                                                                                    float                                                                                      vol)                                                                                                  {                                                                                                                          FloatControl command = (FloatControl) line.                                                              getControl                                                              (FloatControl.Blazon.MASTER_GAIN);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    float                                                                                      gain;                                                                                                                                                                                                                                if                                                                                      (vol ==                                                                                    0f                                                              ) {                                                                                                                      gain = control.getMinimum();                                                                                                                          }                                                                                    else                                                                                      {                                                                                                                                                                    gain = (                                                              bladder                                                              ) ((Math.log(vol) / Math.log(                                                              10.0                                                              )) *                                                                                    20.0                                                              );                                                                                                                      }                                                                                                                                    command.setValue(gain);                                                                                                                                                                                                                                                                                                            }                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            protected                                                                                                                                                  static                                                                                                                                                  void                                                                                      adjustPan (Line line,                                                                                    float                                                                                      pan)                                                                                                  {                                                                                                                                                                                      attempt                                                                                      {                                                                                                                                                                    FloatControl control = (FloatControl) line.                                                              getControl                                                              (FloatControl.Type.PAN);                                                                                                                      control.setValue(pan);                                                                                                                          }                                                                                    grab                                                                                      (Exception e) {                                                                                                                                                                    log.debug(                                                              "Cannot set up pan on line: "                                                                                      + e);                                                                                                                      }                                                        }                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            protected                                                                                                                                                  static                                                                                                                                                  void                                                                                      adjustVolume (Line line,                                                                                    bladder                                                                                      vol)                                                                                                  {                                                                                                                          FloatControl control = (FloatControl) line.                                                              getControl                                                              (FloatControl.Blazon.MASTER_GAIN);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    bladder                                                                                      gain;                                                                                                                                                                                                                                if                                                                                      (vol ==                                                                                    0f                                                              ) {                                                                                                                      gain = command.getMinimum();                                                                                                                          }                                                                                    else                                                                                      {                                                                                                                                                                    gain = (                                                              bladder                                                              ) ((Math.log(vol) / Math.log(                                                              10.0                                                              )) *                                                                                    twenty.0                                                              );                                                                                                                      }                                                                                                                                    control.setValue(gain);                                                                                                                                                                                                                                                                                                            }                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            protected                                                                                                                                                  static                                                                                                                                                  void                                                                                      adjustPan (Line line,                                                                                    bladder                                                                                      pan)                                                                                                  {                                                                                                                                                                                      try                                                                                      {                                                                                                                                                                    FloatControl control = (FloatControl) line.                                                              getControl                                                              (FloatControl.Type.PAN);                                                                                                                      command.setValue(pan);                                                                                                                          }                                                                                    take hold of                                                                                      (Exception e) {                                                                                                                                                                    log.debug(                                                              "Cannot set pan on line: "                                                                                      + e);                                                                                                                      }                                                        }                                                                                          
                                                                                                                                                                                                                            import                                                                                      java.io.File;                                                                                                                                            import                                                                                      javax.audio.sampled.AudioInputStream;                                                                                                                                            import                                                                                      javax.sound.sampled.AudioSystem;                                                                                                                                            import                                                                                      javax.sound.sampled.Clip;                                                                                                                                            import                                                                                      javax.sound.sampled.FloatControl;                                                                                                                                                          ...                                                                                                                                                          public                                                                                                                                                  static                                                                                                                                                  void                                                                                      chief(String[] args) {                                                                                                                                                                                                                                endeavour                                                                                      {                                                                                                                      Prune clip = AudioSystem.getClip();                                                                                                                                                                                  File file =                                                                                    new                                                                                      File(                                                              "[Some *.wav file]"                                                              );                                                                                                                      AudioInputStream stream = AudioSystem.getAudioInputStream(file);                                                                                                                                    clip.open up(stream);                                                                                                                                                                                                                                                                                                                                                                              FloatControl gainControl = (FloatControl) clip.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                                                                                    gainControl.setValue(-                                                              twenty.0f                                                              );                                                                                                                                                                              clip.beginning();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Thread.slumber(                                                              1000                                                              );                                                                                                                      clip.close();                                                                                                                          }                                                                                    catch                                                              (Exception due east) {                                                                                                                      e.printStackTrace();                                                                            }                                                        }                                  
                                                                                                                                        FloatControl volumeControl = (FloatControl) outline.                                                              getControl                                                              (FloatControl.Type.VOLUME);                                                                                                                                            Organization.out.println(                                                              "       volume: "                                                                                      + volumeControl.getValue() );                                                                                                                                                                                                          float                                                                                      v =                                                                                    0.33F                                                              ;                                                                                                                                    
                                                                                              line.open up();                                                                                                                                                                if                                                              (line.isControlSupported(FloatControl.Type.Book)){                                                                                                                                                                    FloatControl control = (FloatControl) line.                                                              getControl                                                              (FloatControl.Type.VOLUME);                                                                                                                                                                    System.out.println(                                                              "Book:"                                                              +control.getValue());                                                                                                                                                                    JProgressBar pb =                                                                                    new                                                                                      JProgressBar();                                                                                                                                    
                                                                                              sourceDataLine.start();                                                                                                                                                          FloatControl volumeControl = (FloatControl) sourceDataLine.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                                                            volumeControl.setValue(                                                              i.00f                                                              );                                                                                                                                    
                                                                                                                  line.open();                                                                                                  }                                                                                    take hold of                                                                                      (IllegalArgumentException iae) {}                                                                                                                                                                                                          return                                                                                      (FloatControl) line.                                                              getControl                                                              (FloatControl.Blazon.Book);                                                                                                                                    
                                                                                                                                                                                                      public                                                                                                                                                  void                                                                                      run() {                                                                                                                                                                                                                                concluding                                                                                      FloatControl control = (FloatControl)                                                                                                                                                                    prune.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                                                    
                                                                                                                                        FloatControl gainControl = (FloatControl)clip.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                  gainControl.setValue(gain);                                                                                          
                                                                                              line.open();                                                                                                                                                                if                                                              (line.isControlSupported(FloatControl.Type.VOLUME)){                                                                                                                                                                    FloatControl command = (FloatControl) line.                                                              getControl                                                              (FloatControl.Blazon.Volume);                                                                                                                                                                    System.out.println(                                                              "Volume:"                                                              +control.getValue());                                                                                                                                                                    JProgressBar pb =                                                                                    new                                                                                      JProgressBar();                                                                                                                                    
                                                                                              play.addLineListener(listener);                                                        play.open(audioInputStream);                                                                                                  FloatControl volume = (FloatControl) play.                                                              getControl                                                              (FloatControl.Type.MASTER_GAIN);                                                                                                                                            volume.setValue(                                                              1.0f                                                              );                                                                                                                                                                                                          play.start();                                                                                          
                                                                                                                                                                .                                                              getControl                                                              (FloatControl.Type.PAN);                                                                                                                                                                                                          if                                                                                      (curPosition == Position.RIGHT)                                                                                                                                                                    pan.setValue(                                                              1.0f                                                              );                                                                                                                                    

Source: https://www.tabnine.com/code/java/methods/javax.sound.sampled.Line/getControl

Posted by: warrenexhaf1942.blogspot.com

0 Response to "How To Change The Volume Of Sound In Jva"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel