/****************************************************************************** * window.cpp * *------------* * *------------------------------------------------------------------------------ * Copyright (C) 1999 Entropic, Inc * Copyright (C) 2000 Microsoft Corporation Date: 03/02/00 * All Rights Reserved * ********************************************************************* PACOG ***/ #include "sigprocInt.h" static double* Rectangular (int iLength); static double* Bartlett (int iLength, bool bSymmetric); static double* Hanning (int iLength, bool bSymmetric); static double* Hamming (int iLength, bool bSymmetric); static double* Blackman (int iLength, bool bSymmetric); /***************************************************************************** * WindowSignal * *--------------* * Description: * Multiplies the input signal by a window. The window length is * the length of the vector. The window is symmetrical if symmetry != 0. * Parameters: * samples: Vector to input data. It is modified by the routine. * type: Type of window, must be one of the types defined in lpc.h ******************************************************************* PACOG ***/ int WindowSignal (double* pdSamples, int iNumSamples, int iWindType, bool bSymmetric) { double* pdWindow; assert (pdSamples); assert (iNumSamples>0); if ( (pdWindow = ComputeWindow(iWindType, iNumSamples, bSymmetric)) == 0) { return 0; } for (int i=0; i0); if (iWindLen<=0) { //fprintf (stderr, "Zero length window requested in ComputeWindow"); return 0; } switch (iWindType) { case WINDOW_RECT: pdWind = Rectangular (iWindLen); break; case WINDOW_BART: pdWind = Bartlett (iWindLen, bSymmetric); break; case WINDOW_HANN: pdWind = Hanning (iWindLen, bSymmetric); break; case WINDOW_HAMM: pdWind = Hamming (iWindLen, bSymmetric); break; case WINDOW_BLACK: pdWind = Blackman (iWindLen, bSymmetric); break; default: //fprintf(stderr, "Window type not known"); return 0; } return pdWind; } /***************************************************************************** * Rectangular * *-------------* * Description: * Returns a unit vector of the specified length. ******************************************************************* PACOG ***/ double* Rectangular (int iLength) { double* pdWindow; if ((pdWindow = new double[iLength]) != 0) { for (int i=0; i