Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The easiest way to do this is to use jlayer via <a href="http://www.javazoom.net/mp3spi/sources.html" rel="nofollow">mp3spi</a> which basically means you use jlayer via JavaSound. You can then set gain on the line as you would in JavaSound.</p> <p>Firstly, you will need to add the following to your classpath:</p> <ul> <li>jl1.0.1.jar</li> <li>mp3spi1.9.5.jar</li> <li>tritonus_share.jar</li> </ul> <p>...all of which are in the distribution for mp3spi (linked above).</p> <p>Secondly, you will need to decode the AudioInputStream prior to playback.</p> <pre><code>AudioInputStream audioStream = AudioSystem.getAudioInputStream(file); AudioFormat baseFormat = audioStream.getFormat(); AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false); AudioInputStream audioStream2 = AudioSystem.getAudioInputStream(decodedFormat, audioStream); </code></pre> <p>Then you play the decoded stream:</p> <pre><code>Clip clip = AudioSystem.getClip(); clip.open(audioStream2); </code></pre> <p>and JavaSound API controls are available:</p> <pre><code>FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); gainControl.setValue(-30.0f); </code></pre> <p>NOTE: Don't forget to close your resources, I've just shown the key points for this issue - familiarity with JavaSound is expected, <a href="http://docs.oracle.com/javase/tutorial/sound/" rel="nofollow">read here</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload