我正在尝试使音频录音更生动。我用来将原始PCM数据转换为double []的方法。但是我得到的都是0。
public double[] readPCM()
{
double[] result = null;
try
{
File file = new File(ThePCMFile);
InputStream in = new FileInputStream(file);
int bufferSize = (int) (file.length()/2);
result = new double[bufferSize];
DataInputStream is = new DataInputStream(in);
for (int i = 0; i < bufferSize; i++)
{
result[i] = is.readShort() / 32768.0;
}
}
catch (IOException e)
{
e.printStackTrace();
}
return result;
}