mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
35 lines
786 B
Java
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;
|
|
}
|
|
|
|
}
|