Android 将数据从文件转换为浮点

Android 将数据从文件转换为浮点,android,audio-recording,typeconverter,Android,Audio Recording,Typeconverter,所以,我正在用android制作这个应用程序,我编写了下面的代码,将存储在文件中的音频数据(以字节为单位)转换为float。问题是,我得到了很多NaN值,而且,其他值看起来和实际的音频数据不一样。我知道,大于[255 255 127]的值溢出,结果为NaN,但在播放时音频很好 private float[] FileToFloat(File file, int allSamples){ byte[] byteBuffer = null; byteBuffer =

所以,我正在用android制作这个应用程序,我编写了下面的代码,将存储在文件中的音频数据(以字节为单位)转换为float。问题是,我得到了很多NaN值,而且,其他值看起来和实际的音频数据不一样。我知道,大于[255 255 127]的值溢出,结果为NaN,但在播放时音频很好

private float[] FileToFloat(File file, int allSamples){
        byte[] byteBuffer = null;
        byteBuffer = new byte[allSamples];
        FileInputStream in = null;
        try {
            in = new FileInputStream(file);
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }

        try {
            in.read(byteBuffer);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        ByteBuffer bb = ByteBuffer.wrap(byteBuffer);

        float[] floatBuffer = new float[byteBuffer.length/4];

        for(int i = 0; i < floatBuffer.length; i++){
            floatBuffer[i] = bb.getFloat(i*4);}

        return(floatBuffer);
    }
private float[]FileToFloat(文件文件,int-allSamples){
字节[]byteBuffer=null;
byteBuffer=新字节[所有样本];
FileInputStream in=null;
试一试{
in=新文件输入流(文件);
}捕获(FileNotFoundException e1){
e1.printStackTrace();
}
试一试{
in.read(byteBuffer);
in.close();
}捕获(IOE异常){
e、 printStackTrace();
}
ByteBuffer bb=ByteBuffer.wrap(ByteBuffer);
float[]floatBuffer=新的float[byteBuffer.length/4];
for(int i=0;i
编辑:也许我应该先添加标题