Advertisement
isendrak

JLayer_setGain.patch

Jul 29th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.46 KB | None | 0 0
  1. --- src/javazoom/jl/player/Player.java  2008-11-16 17:34:07.000000000 +0100
  2. +++ src/javazoom/jl/player/Player.java  2018-07-29 23:45:42.383258868 +0200
  3. @@ -136,6 +136,20 @@
  4.         }
  5.         return ret;
  6.     }
  7. +  
  8. +       public boolean setGain(float newGain) {
  9. +        if (audio instanceof JavaSoundAudioDevice) {
  10. +            System.out.println("InstanceOf");
  11. +            JavaSoundAudioDevice jsAudio = (JavaSoundAudioDevice) audio;
  12. +            try {
  13. +                jsAudio.write(null, 0, 0);
  14. +            } catch (JavaLayerException ex) {
  15. +                ex.printStackTrace();
  16. +            }
  17. +            return jsAudio.setLineGain(newGain);
  18. +        }
  19. +        return false;
  20. +    }
  21.        
  22.     /**
  23.      * Cloases this player. Any audio currently playing is stopped
  24. --- src/javazoom/jl/player/JavaSoundAudioDevice.java    2008-11-16 17:34:07.000000000 +0100
  25. +++ src/javazoom/jl/player/JavaSoundAudioDevice.java    2018-07-29 23:44:22.769057955 +0200
  26. @@ -85,6 +85,19 @@
  27.             setOpen(true);
  28.         }
  29.     }
  30. +  
  31. +       public boolean setLineGain(float gain)
  32. +   {
  33. +       System.out.println("Vor Source");
  34. +       if (source != null) {
  35. +           System.out.println("Nach Source");
  36. +           FloatControl volControl = (FloatControl) source.getControl(FloatControl.Type.MASTER_GAIN);
  37. +           float newGain = Math.min(Math.max(gain, volControl.getMinimum()), volControl.getMaximum());
  38. +           volControl.setValue(newGain);
  39. +           return true;
  40. +       }
  41. +       return false;
  42. +   }
  43.  
  44.     protected void openImpl()
  45.         throws JavaLayerException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement