Classes Utilities Scripts Speech Search Up Home
ISIP IFC Index
Title Bar

/home5/piconepr/public_html/isip/projects/speech/software/documentation/class/algo/Energy/enrgy_05.cc

// file: $isip/class/algo/Energy/enrgy_05.cc
// version: $Id: enrgy_05.cc 8165 2002-05-31 21:57:33Z picone $
//

// isip include files
//
#include "Energy.h"

[snipped]

// method: apply
//
// arguments:
//  Vector<AlgorithmData>& output: (output) output data
//  const Vector< CircularBuffer<AlgorithmData> >& input: (input) input data
//
// return: a boolean value indicating status
//
// this method calls the appropriate computation methods
//
boolean Energy::apply(Vector<AlgorithmData>& output_a,
		      const Vector< CircularBuffer<AlgorithmData> >& input_a) {

  // check the mode
  //
  if (cmode_d != FRAME_INTERNAL) {
    return Error::handle(name(), L"apply", ERR_UNSUPM, __FILE__, __LINE__);
  }

  // determine the number of input channels and force the output to be
  // that number
  //
  long len = input_a.length();
  output_a.setLength(len);
  boolean res = true;

  // set the number of channels
  //
  if (len != num_channels_d) {
    setNumChannels(len);
  }

  // start the debugging output
  //
  displayStart(this);

  // loop over the channels and call the compute method
  //
  for (long c = 0; c < len; c++) {

    // display the channel number
    //
    displayChannel(c);

    // branch on compute method type based on the type of input type
    //
    if (input_a(c)(0).getDataType() == AlgorithmData::VECTOR_FLOAT) {
      
      // call AlgorithmData::makeVectorFloat to force the output vector for
      // this channel to be a VectorFloat, call AlgorithmData::getVectorFloat
      // on the input for this channel to check that the input is
      // already a VectorFloat and return that vector.
      //
      res &= compute(output_a(c).makeVectorFloat(),
		     input_a(c)(0).getVectorFloat(),
		     input_a(c)(0).getCoefType(),
		     c);
    }

    else if (input_a(c)(0).getDataType() ==
	     AlgorithmData::VECTOR_COMPLEX_FLOAT) {

      // call AlgorithmData::makeVectorFloat to force the
      // output vector for this channel to be a VectorFloat,
      // call AlgorithmData::getVectorComplexFloat on the input for
      // this channel to check that the input is already a
      // VectorComplexFloat and return that vector.
      //
      res &= compute(output_a(c).makeVectorFloat(),
		     input_a(c)(0).getVectorComplexFloat(),
		     input_a(c)(0).getCoefType(),
		     c);      
     }

    // set the coefficient type for the output
    //            
    output_a(c).setCoefType(AlgorithmData::ENERGY);
  }

  // finish the debugging output
  //
  displayFinish(this);

  // exit gracefully
  //
  return res;
}

[snipped]

//
// end of file


Footer

Up | Home | Courses | Projects | Proposals | Publications Please direct questions or comments to joseph.picone@isip.piconepress.com