我是java的新手,有人可以告诉我将wav文件名放在下面的代码中,我的文件名是" p.wav"它的位置是D:/p.wav; PLZ帮助,我收到以下错误 - :
线程中的异常" main" java.lang.Error:
未解决的编译问题:
WavFile无法解析为类型
无法解析WavFile
import java.io.*;
public class ReadExample
{
public static void main(String[] args)
{
try
{
// Open the wav file specified as the first argument
WavFile wavFile = WavFile.openWavFile(new File(args[0]));
// Display information about the wav file
wavFile.display();
// Get the number of audio channels in the wav file
int numChannels = wavFile.getNumChannels();
// Create a buffer of 100 frames
double[] buffer = new double[100 * numChannels];
int framesRead;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
do
{
// Read frames into buffer
framesRead = wavFile.readFrames(buffer, 100);
// Loop through frames and look for minimum and maximum value
for (int s=0 ; s<framesRead * numChannels ; s++)
{
if (buffer[s] > max) max = buffer[s];
if (buffer[s] < min) min = buffer[s];
}
}
while (framesRead != 0);
// Close the wavFile
wavFile.close();
// Output the minimum and maximum value
System.out.printf("Min: %f, Max: %f\n", min, max);
}
catch (Exception e)
{
System.err.println(e);
}
} }
答案 0 :(得分:3)
您需要从HERE下载java文件,并将它们添加到与您的代码相同的包中。
然后改变这一行:
WavFile wavFile = WavFile.openWavFile(new File(args[0]));
为:
WavFile wavFile = WavFile.openWavFile(new File("D:/p.wav"));