/** * Quantize an array of floats over the 16bits signed short range * * @param f * the array of floats to quantize * @param fMin * the minimum possible value for variable f * @param fRange * the possible range for variable f * * @return an array of 16bits signed codewords, returned as signed shorts * * */ public static short[] quantize(float[] f, float fMin, float fRange) { int len = f.length; short[] ret = new short[len]; for (int i = 0; i < len; i++) ret[i] = quantize(f[i], fMin, fRange); return (ret); }
/** * Quantize an array of floats over the 16bits signed short range * * @param f * the array of floats to quantize * @param fMin * the minimum possible value for variable f * @param fRange * the possible range for variable f * * @return an array of 16bits signed codewords, returned as signed shorts * * */ public static short[] quantize(float[] f, float fMin, float fRange) { int len = f.length; short[] ret = new short[len]; for (int i = 0; i < len; i++) ret[i] = quantize(f[i], fMin, fRange); return (ret); }
/** * Construct an LPC datagram from unquantized data. * * @param setDuration * the duration, in samples, of the data represented by this datagram * @param coeffs * the (unquantized) LPC coefficients * @param residual * the (unquantized) residual * @param lpcMin * lpcMin * @param lpcRange * lpcRange */ public LPCDatagram(long setDuration, float[] coeffs, short[] residual, float lpcMin, float lpcRange) { super(setDuration); this.quantizedCoeffs = General.quantize(coeffs, lpcMin, lpcRange); this.quantizedResidual = General.shortToUlaw(residual); }
/** * Construct an LPC datagram from unquantized data. * * @param setDuration * the duration, in samples, of the data represented by this datagram * @param coeffs * the (unquantized) LPC coefficients * @param residual * the (unquantized) residual * @param lpcMin * lpcMin * @param lpcRange * lpcRange */ public LPCDatagram(long setDuration, float[] coeffs, short[] residual, float lpcMin, float lpcRange) { super(setDuration); this.quantizedCoeffs = General.quantize(coeffs, lpcMin, lpcRange); this.quantizedResidual = General.shortToUlaw(residual); }
/** * Construct an LPC datagram from unquantized data. * * @param setDuration * the duration, in samples, of the data represented by this datagram * @param coeffs * the (unquantized) LPC coefficients * @param residual * the (unquantized) residual * @param lpcMin * lpcMin * @param lpcRange * lpcRange */ public LPCDatagram(long setDuration, float[] coeffs, short[] residual, float lpcMin, float lpcRange) { super(setDuration); this.quantizedCoeffs = General.quantize(coeffs, lpcMin, lpcRange); this.quantizedResidual = General.shortToUlaw(residual); }
short[] quantizedFrame = General.quantize(lpcFile.getFrame(f), lpcMin, lpcRange); float[] unQuantizedFrame = General.unQuantize(quantizedFrame, lpcMin, lpcRange);