// Copyright (C) 1999 Jean-Marc Valin #include "BufferedNode.h" #include "Vector.h" using namespace std; namespace FD { class GCMS2; DECLARE_NODE(GCMS2) /*Node * * @name GCMS2 * @category DSP:TimeFreq * @description Growing-Window Cepstral Mean Subtraction, counting only speech * * @input_name INPUT * @input_type Vector * @input_description Input frames * * @input_name IS_SPEECH * @input_type bool * @input_description Whether the frame is speech * * @output_name OUTPUT * @output_type Vector * @output_description CMS output * * @parameter_name LENGTH * @parameter_type int * @parameter_description Frame lentgh (features) * END*/ class GCMS2 : public BufferedNode { protected: /**Length of input frames*/ int length; /** inputID*/ int inputID; int speechID; /** outputID */ int outputID; /** sum for the running average */ vector sum; /** number of frames accumulated */ int accumCount; public: GCMS2(string nodeName, const ParameterSet ¶ms) : BufferedNode(nodeName, params) , accumCount(0) { outputID = addOutput ("OUTPUT"); inputID = addInput("INPUT"); speechID = addInput("IS_SPEECH"); length = dereference_cast (parameters.get("LENGTH")); sum.resize(length); inOrder = true; } void initialize() { BufferedNode::initialize(); for (int i=0;i &output = *Vector::alloc(length); out[count] = &output; Vector &in = object_cast > (inputValue); ObjectRef speechValue = getInput(speechID, count); if (dereference_cast (speechValue) || count==0) { accumCount++; float inv_accum=1.0/accumCount; for (i=0;i