// Copyright (C) 1999 Jean-Marc Valin #include "BufferedNode.h" #include "Buffer.h" #include "Vector.h" #include "lpc.h" #include #include #include "FFTWrap.h" #include "misc.h" using namespace std; namespace FD { class PS2LPC; DECLARE_NODE(PS2LPC) /*Node * * @name PS2LPC * @category DSP:Adaptive * @require FFT * @description Computes LPC coefficients from the spectral envelope of the all-pole filter * * @input_name INPUT * @input_type Vector * @input_description Spectral envelope * * @output_name OUTPUT * @output_type Vector * @output_description LPC coefficients * * @parameter_name INPUTLENGTH * @parameter_type int * @parameter_description Number of points in the spectral envelope * * @parameter_name OUTPUTLENGTH * @parameter_type int * @parameter_description Number of LPC coefficients (order + 1) * * @parameter_name LAG_THETA * @parameter_type float * @parameter_description Lag-windowing parameter (roughly the minimum bandwidth of resonances) * END*/ class PS2LPC : public BufferedNode { int inputID; int outputID; int inputLength; int outputLength; float *hamming; int SAMP_SIZE; int SAMP_SIZE_2; float *response; float *ps; float *rc; float *lag_window; public: PS2LPC(string nodeName, ParameterSet params) : BufferedNode(nodeName, params) { inputID = addInput("INPUT"); outputID = addOutput("OUTPUT"); inputLength = dereference_cast (parameters.get("INPUTLENGTH")); outputLength = dereference_cast (parameters.get("OUTPUTLENGTH")); SAMP_SIZE_2 = inputLength; SAMP_SIZE = 2 * SAMP_SIZE_2; rc=new float[outputLength]; response=new float[SAMP_SIZE]; ps=new float[SAMP_SIZE]; lag_window=new float[SAMP_SIZE]; if (parameters.exist("LAG_THETA")) { for (int i=0;i (parameters.get("LAG_THETA")))); } else { for (int i=0;iBufferedNode::initialize(); hamming = new float[SAMP_SIZE]; for (int i=0;i &in = object_cast > (inputValue); if (inputLength != in.size()) throw new NodeException(this, "Input length mismatch", __FILE__, __LINE__); Vector &output = *Vector::alloc(outputLength); out[count] = &output; for (int i=0;i