class SoundDataUtils {
public static short[] convertFromDoubleArrayToShortArray(double[] doubleData) {
int size = doubleData.length;
short[] shortData = new short[size];
for (int i = 0; i < size; i++) {
double d = (doubleData[i] + 1.0) / 2.0 * 65536.0;
if (d > 65535.0) {
d = 65535.0;
} else if (d < 0.0) {
d = 0.0;
}
shortData[i] = (short) ((d + 0.5) - 32768);
}
return shortData;
}
}