这几天一直在弄音频文件的解码问题
纠结我好久
public class AudioSampleReader {
private AudioInputStream audioInputStream;
private AudioFormat format;
public AudioSampleReader(File file)
throws UnsupportedAudioFileException, IOException {
audioInputStream = AudioSystem.getAudioInputStream(file);
format = audioInputStream.getFormat();
}
public AudioFormat getFormat() {
return format;
}
//获取样本数目
public long getSampleCount() {
long total = (audioInputStream.getFrameLength() *
format.getFrameSize() * 8) / format.getSampleSizeInBits();
return total / format.getChannels();
}
//获取十进制样本值
public void getInterleavedSamples(long begin, lon
纠结我好久
public class AudioSampleReader {
private AudioInputStream audioInputStream;
private AudioFormat format;
public AudioSampleReader(File file)
throws UnsupportedAudioFileException, IOException {
audioInputStream = AudioSystem.getAudioInputStream(file);
format = audioInputStream.getFormat();
}
public AudioFormat getFormat() {
return format;
}
//获取样本数目
public long getSampleCount() {
long total = (audioInputStream.getFrameLength() *
format.getFrameSize() * 8) / format.getSampleSizeInBits();
return total / format.getChannels();
}
//获取十进制样本值
public void getInterleavedSamples(long begin, lon