2

私はあなたの助けが必要です。.wavファイルを逆方向​​に再生するために次のコードを調整するにはどうすればよいですか?

どんな助けでも大歓迎です..ありがとう。カルロス

import java.io.*;
import javax.sound.sampled.*;

public class WavPlay {
   public static void main(String[] args) {
      SourceDataLine soundLine = null;
      int BUFFER_SIZE = 64*1024;  // 64 KB

      // Set up an audio input stream piped from the sound file.
      try {
         File soundFile = new File("chord.wav");
         AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(soundFile);
         AudioFormat audioFormat = audioInputStream.getFormat();
         DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
         soundLine = (SourceDataLine) AudioSystem.getLine(info);
         soundLine.open(audioFormat);
         soundLine.start();
         System.out.println("File chord.wav....playing");
         int nBytesRead = 0;
         byte[] sampledData = new byte[BUFFER_SIZE];

         while (nBytesRead != -1) {
            nBytesRead = audioInputStream.read(sampledData, 0, sampledData.length);
            if (nBytesRead >= 0) {
               // Writes audio data to the mixer via this source data line.
               soundLine.write(sampledData, 0, nBytesRead);

            }

         }
      } catch (UnsupportedAudioFileException ex) {
         ex.printStackTrace();
      } catch (IOException ex) {
         ex.printStackTrace();
      } catch (LineUnavailableException ex) {
         ex.printStackTrace();
      } finally {
         soundLine.drain();
         soundLine.close();
      }
   }

}
4

1 に答える 1

0

はい!それは可能です、ずっと前に私はそれのために賞金を稼ぎました。これが私の質問へのリンクです。そして問題は、私が自分のやり方でそれを見つけなければならなかったということでした。

于 2010-11-07T17:10:55.140 に答える