答案 0 :(得分:0)
这是一个使用WAV文件的简单框架:http://www.labbookpages.co.uk/audio/javaWavFiles.html
我很快写完了这个,所以如果有任何错误我会道歉,但这里是将wav文件加载到ArrayList中的样子:
//make sure to import java.util.ArrayList;
try {
// load the file, set up the buffer
WavFile gameWav = WavFile.openWavFile( new File( "game_sound.wav" ) );
ArrayList<double> gameWavArray = new ArrayList<double>();
long framesRead = 0;
long totalFrames = gameWav.getNumFrames();
//read the buffer in 1000 frames at a time
do {
double[] gameWavBuffer = new double[1000];
// Read the frames into array, increment framesRead
framesRead = framesRead + Long.valueOf( gameWav.readFrames(gameWavBuffer, framesRead, 1000) );
//add all of the new frames to our ArrayList
Collections.addAll(gameWavArray, gameWavBuffer );
}
while (framesRead < totalFrames );
}
catch (Exception e) {
System.err.println(e);
}