通过GSM调制解调器播放WAV文件

Sha*_*jee 6 java modem gsm serial-port

我想通过GSM调制解调器播放WAV文件.这是我的示例代码

private final int BUFFER_SIZE = 8;
private File soundFile;
private AudioInputStream audioStream;
private AudioFormat audioFormat;
public void playSound(String filename) throws IOException{

    String strFilename = filename;

    try {
        soundFile = new File(strFilename);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    try {
        audioStream = AudioSystem.getAudioInputStream(soundFile);
    } catch (Exception e){
        e.printStackTrace();
        System.exit(1);
    }

    audioFormat = audioStream.getFormat();

    DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);

    int nBytesRead = 0;
    byte[] abData = new byte[BUFFER_SIZE];
    while (nBytesRead != -1) {
        try {
            nBytesRead = audioStream.read(abData);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (nBytesRead >= 0) {
            outputStream.write(abData, 0, nBytesRead);
            outputStream.flush();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但问题是通过串口发送的WAV文件播放速度非常快.我不知道是什么问题.这是我的WAV文件描述:

ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, Audio Sample Rate 8Khz.

任何人都可以帮我解决这个问题吗?

Ell*_*sch 1

我会检查以下内容 - 特别是#3。

  1. 同步
  2. 音频格式
  3. JSSRC 重采样库