⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cep_05.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
			   ERR_UNKIMP, __FILE__, __LINE__);    }        // convert back to the output to the real type    //    complex_output.real(output_a);  }    // possibly display the data  //  display(output_a, input_a, name());    // exit gracefully  //  return status;}// method: compute//// arguments://  VectorComplexFloat& output: (output) cepstral coefficients//  const VectorFloat& input: (input) input vector//  AlgorithmData::COEF_TYPE input_coef_type: (input) type of input//  long channel_index: (input) channel index//// return: a boolean value indicating status//// this method computes the cepstral coefficients for a given input vector//boolean Cepstrum::compute(VectorComplexFloat& output_a,			  const VectorFloat& input_a,			  AlgorithmData::COEF_TYPE input_coef_type_a,			  long channel_index_a) {  // declare local variables  //  boolean status = false;  VectorFloat input(input_a);      // check the input arguments  //  if (order_d < (long)0) {    Error::handle(name(), L"compute", ERR, __FILE__, __LINE__);  }  // compute the log spectrum from spectrum  //  VectorFloat logspectrum;  // make sure that input amplitude doesn't fall below the minimum  // amplitude if it is defined  //  if (flag_min_amp_d) {    input.limitMin((float)min_amp_d);  }    // take log of the input vector  //  logspectrum.log(input);    // branch on algorithm  //  Algorithm: IDCT  //  if (algorithm_d == IDCT) {    // branch on implementation    //  Implementation: TYPE_I    //    if (implementation_d == TYPE_I) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKALG, __FILE__, __LINE__);	      }      // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // branch on implementation    //  Implementation: TYPE_II    //    else if (implementation_d == TYPE_II) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKALG, __FILE__, __LINE__);	      }      // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // branch on implementation    //  Implementation: TYPE_III    //    else if (implementation_d == TYPE_III) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKALG, __FILE__, __LINE__);	      }            // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // branch on implementation    //  Implementation: TYPE_IV    //    if (implementation_d == TYPE_IV) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKIMP, __FILE__, __LINE__);	      }      // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }        // else: error unknown implementation type    //    else {      return Error::handle(name(), L"compute",			   ERR_UNKIMP, __FILE__, __LINE__);    }      }     // Algorithm: IDFT  //  else {        // branch on implementation:    //  Implementation: CONVENTIONAL    //        if (implementation_d == CONVENTIONAL) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	status = computeIdftConvRealFloat(output_a, logspectrum);      }            // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // else: error unknown implementation type    //    else {      return Error::handle(name(), L"compute",			   ERR_UNKIMP, __FILE__, __LINE__);    }      }    // possibly display the data  //  display(output_a, input_a, name());    // exit gracefully  //  return status;}// method: compute//// arguments://  VectorComplexFloat& output: (output) cepstral coefficients//  const VectorComplexFloat& input: (input) input vector//  AlgorithmData::COEF_TYPE input_coef_type: (input) type of input//  long channel_index: (input) channel index//// return: a boolean value indicating status//// this method computes the cepstral coefficients for a given input vector//boolean Cepstrum::compute(VectorComplexFloat& output_a,			  const VectorComplexFloat& input_a,			  AlgorithmData::COEF_TYPE input_coef_type_a,			  long channel_index_a) {    // declare local variables  //  boolean status = false;  VectorComplexFloat input(input_a);    // check the input arguments  //  if (order_d < (long)0) {    Error::handle(name(), L"compute", ERR, __FILE__, __LINE__);  }  // compute the log spectrum from spectrum  //  VectorComplexFloat logspectrum;  // make sure that input amplitude doesn't fall below the minimum  // amplitude if it is defined  //  if (flag_min_amp_d) {    input.limitMin((float)min_amp_d);  }    // take log of the input vector  //  logspectrum.log(input);  // branch on algorithm  //  Algorithm: IDCT  //  if (algorithm_d == IDCT) {    // branch on implementation    //  Implementation: TYPE_I    //    if (implementation_d == TYPE_I) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKALG, __FILE__, __LINE__);	      }      // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // branch on implementation    //  Implementation: TYPE_II    //    else if (implementation_d == TYPE_II) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKALG, __FILE__, __LINE__);	      }      // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // branch on implementation    //  Implementation: TYPE_III    //    else if (implementation_d == TYPE_III) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKALG, __FILE__, __LINE__);	      }            // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // branch on implementation    //  Implementation: TYPE_IV    //    if (implementation_d == TYPE_IV) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	return Error::handle(name(), L"compute",			     ERR_UNKIMP, __FILE__, __LINE__);	      }      // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }        // else: error unknown implementation type    //    else {      return Error::handle(name(), L"compute",			   ERR_UNKIMP, __FILE__, __LINE__);    }      }     // Algorithm: IDFT  //  else {        // branch on implementation:    //  Implementation: CONVENTIONAL    //        if (implementation_d == CONVENTIONAL) {      if (input_coef_type_a == AlgorithmData::SPECTRUM) {	status = computeIdftConvComplexFloat(output_a, logspectrum);      }            // else: error unknown input type      //      else {	return Error::handle(name(), L"compute",			     ERR_UNCTYP, __FILE__, __LINE__);      }    }    // else: error unknown implementation type    //    else {      return Error::handle(name(), L"compute",			   ERR_UNKIMP, __FILE__, __LINE__);    }      }    // possibly display the data  //  display(output_a, input_a, name());    // exit gracefully  //  return status;}// method: computeIdctT1Float//// arguments://  VectorFloat& cepstrum: (output) cepstral coefficients//  const VectorFloat& logspectrum: (input) input log magnitude spectrum//// return: a boolean value indicating status//// this method gives the cepstral coefficients for given input log// magnitude spectrum using IDCT algorithm and TYPE_I implementation//boolean Cepstrum::computeIdctT1Float(VectorFloat& cepstrum_a,				     const VectorFloat& logspectrum_a) {    // check the algorithm and implementation  //  if ((algorithm_d != IDCT) && (implementation_d != TYPE_I)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }  // declare local variable  //  long comp_num_coeffs = order_d + (long)1;  // compute the order  //  Long order;  order.max(comp_num_coeffs, logspectrum_a.length());    // setup the algorithm  //  if (!ft_d.setAlgorithm(FourierTransform::DCT)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }    // setup the implementation  //  if (!ft_d.setImplementation(FourierTransform::TYPE_I)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }  // setup the direction  //  if (!ft_d.setDirection(FourierTransform::INVERSE)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }  // setup the resolution  //  if (!ft_d.setResolution(FourierTransform::FIXED)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }  // setup the input length (order of IDCT)  //  if (!ft_d.setInputLength(order)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }  // setup the output length  //  if (!ft_d.setOutputLength(comp_num_coeffs)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }    // call compute method of fourier transform  //  if (!ft_d.compute(cepstrum_a, logspectrum_a)) {    return Error::handle(name(), L"computeIdctT1Float",			 ERR, __FILE__, __LINE__);  }    // output debugging information  //  if (debug_level_d >= Integral::ALL) {    cepstrum_a.debug(L"cepstrum");  }    // exit gracefully  //  return true;}// method: computeIdctT2Float//// arguments://  VectorFloat& cepstrum: (output) cepstral coefficients//  const VectorFloat& logspectrum: (input) input log magnitude spectrum//// return: a boolean value indicating status//// this method gives the cepstral coefficients for given input log// magnitude spectrum using IDCT algorithm and TYPE_II implementation

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -