PAMGuard/src/wavFiles/ByteConverterFloat32.java
2022-01-07 10:41:38 +00:00

35 lines
786 B
Java

package wavFiles;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
public class ByteConverterFloat32 extends ByteConverter {
@Override
public int bytesToDouble(byte[] byteData, double[][] doubleData,
int numBytes) {
int nChan = doubleData.length;
int nSamples = numBytes/nChan/4;
int iChan = 0, iSamp = 0;
int iPos;
FloatBuffer bb = ByteBuffer.wrap(byteData).order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer();
for (iSamp = 0; iSamp < nSamples; iSamp++) {
for (iChan = 0; iChan < nChan; iChan++) {
doubleData[iChan][iSamp] = bb.get();
}
}
return nChan*nSamples;
}
@Override
public int doubleToBytes(double[][] doubleData, byte[] byteData,
int numSamples) {
// TODO Auto-generated method stub
return 0;
}
}