1 添加依赖
<dependency><groupId>com.googlecode.soundlibs</groupId><artifactId>mp3spi</artifactId><version>1.9.5.4</version>
</dependency>
2 Java 代码
package com.xu.music.player.player;import javazoom.spi.mpeg.sampled.file.MpegAudioFileReader;import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;import java.io.File;
public class NewTest {public static void main(String[] args) throws Exception {toPcm("D:\\Kugou\\梦涵 - 加减乘除.mp3", "C:\\Users\\xuyq\\Desktop\\梦涵 - 加减乘除.pcm");}public static void toPcm(String iPath, String oPath) throws Exception {AudioInputStream stream = new MpegAudioFileReader().getAudioInputStream(new File(iPath));AudioFormat format = stream.getFormat();format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), 16, format.getChannels(),format.getChannels() * 2, format.getSampleRate(), false);stream = AudioSystem.getAudioInputStream(format, stream);AudioSystem.write(stream, AudioFileFormat.Type.WAVE, new File(oPath));}}