static short[] normalizeShortArray(short[] l) { int max = min(32767, absShortMax(l)); if (max == 0 || max == 32767) ret l; int n = l(l); short[] l2 = new[n]; double factor = 32767.0/max; for i to n: l2[i] = roundToShort(l[i]*factor); ret l2; }