这是一个从音频信号里提取特征参量的程序

源代码在线查看: output.h

软件大小: 7567 K
上传用户: babydog00
关键词: 音频信号 特征 参量 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				// file: $isip/class/algo/Output/Output.h				// version: $Id: Output.h,v 1.12 2002/10/17 19:26:14 gao Exp $				//								// make sure definitions are only made once				//				#ifndef ISIP_OUTPUT				#define ISIP_OUTPUT								// isip include files				//				#ifndef ISIP_ALGORITHM_BASE				#include 				#endif								#ifndef ISIP_AUDIO_FILE				#include 				#endif								#ifndef ISIP_FEATURE_FILE				#include 				#endif								#ifndef ISIP_FILENAME				#include 				#endif								#ifndef ISIP_STRING				#include 				#endif								#ifndef ISIP_MEMORY_MANAGER				#include 				#endif								// Output: this is another class that is primarily used to facilitate				// recipe processing. this class is used to output data to a file.				// a recipe can have multiple outputs, and each output can write				// multichannel data in a variety of formats.				//				class Output : public AlgorithmBase {								  //---------------------------------------------------------------------------				  //				  // public Outputs				  //				  //---------------------------------------------------------------------------				public:				  				  // define the class name				  //				  static const String CLASS_NAME;								  //----------------------------------------				  //				  // other important constants				  //				  //----------------------------------------				  				  // define the algorithm choices				  //				  enum ALGORITHM { DATA = 0, DEF_ALGORITHM = DATA};								  // define the implementation choices				  //				  enum IMPLEMENTATION { FEATURES = 0, SAMPLED_DATA,							DEF_IMPLEMENTATION = FEATURES};								  // define the static NameMap objects				  //				  static const NameMap ALGO_MAP;				  static const NameMap IMPL_MAP;								  //----------------------------------------				  //				  // i/o related constants				  //				  //----------------------------------------								  static const String DEF_PARAM;				  static const String PARAM_ALGORITHM;				  static const String PARAM_IMPLEMENTATION;				  static const String PARAM_FILENAME;				  static const String PARAM_EXTENSION;				  static const String PARAM_AUDIO_OUTPUT;				  static const String PARAM_FEATURE_OUTPUT;				  static const String PARAM_DMODE;   				  //----------------------------------------				  //				  // default values and arguments				  //				  //----------------------------------------  								  // the default filename				  //				  static const String DEF_FILENAME;								  // the default file extension				  //				  static const String DEF_EXTENSION;								  // a default temporary filename				  //				  static const String DEF_TMP_FILE;								  //----------------------------------------				  //				  // error codes				  //				  //----------------------------------------  				  				  static const long ERR = 71400;								  //---------------------------------------------------------------------------				  //				  // protected data				  //				  //---------------------------------------------------------------------------				protected:				  				  // algorithm name				  //				  ALGORITHM algorithm_d;								  // implementation name				  //				  IMPLEMENTATION implementation_d;				  				  // file name and file name extension				  //				  Filename filename_d;				  String output_extension_d;								  // the basename of the input file				  //				  String basename_d;				  				  // the audiofile or featurefile to write out				  //				  AudioFile audio_output_d;				  FeatureFile feature_output_d;								  // static memory manager				  //				  static MemoryManager mgr_d;								  //---------------------------------------------------------------------------				  //				  // required public methods				  //				  //---------------------------------------------------------------------------				public:				    				  // method: name				  //				  static const String& name() {				    return CLASS_NAME;				  }								  // other static methods				  //				  static boolean diagnose(Integral::DEBUG debug_level);				  				  // debug methods:				  //  setDebug is inherited from the base class				  //				  boolean debug(const unichar* msg) const;								  // method: destructor				  //				  ~Output() {}								  // method: default constructor				  //				  Output(ALGORITHM algorithm = DEF_ALGORITHM,					   IMPLEMENTATION implementation = DEF_IMPLEMENTATION) {				    algorithm_d = algorithm;				    implementation_d = implementation;				    output_extension_d.assign(DEF_EXTENSION);				    is_valid_d = false;				  }								  // method: copy constructor				  //				  Output(const Output& arg) {				    assign(arg);				  }								  // assign methods				  //				  boolean assign(const Output& arg);								  // method: operator=				  //				  Output& operator= (const Output& arg) {				    assign(arg);				    return *this;				  }				  				  // i/o methods				  //				  long sofSize() const;				  				  boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);				  boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;								  boolean readData(Sof& sof, const String& pname = DEF_PARAM,						   long size = SofParser::FULL_OBJECT,						   boolean param = true,				                   boolean nested = false);				  boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;								  // equality methods				  //				  boolean eq(const Output& arg) const;				  				  // method: new				  //				  static void* operator new(size_t size) {				    return mgr_d.get();				  }								  // method: new[]				  //				  static void* operator new[](size_t size) {				    return mgr_d.getBlock(size);				  }								  // method: delete				  //				  static void operator delete(void* ptr) {				    mgr_d.release(ptr);				  }								  // method: delete[]				  //				  static void operator delete[](void* ptr) {				    mgr_d.releaseBlock(ptr);				  }								  // method: setGrowSize				  //				  static boolean setGrowSize(long grow_size) {				    return mgr_d.setGrow(grow_size);				  }								  // other memory management methods				  //				  boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);								  //---------------------------------------------------------------------------				  //				  // class-specific public methods:				  //  set methods				  //				  //---------------------------------------------------------------------------								  // method: setAlgorithm				  //				  boolean setAlgorithm(ALGORITHM algorithm) {				    algorithm_d = algorithm;				    is_valid_d = false;				    return true;				  }								  // method: setImplementation				  //				  boolean setImplementation(IMPLEMENTATION implementation) {				    implementation_d = implementation;				    is_valid_d = false;				    return true;  				  }								  // method: setFilename				  //				  boolean setFilename(String filename) {				    filename_d.assign(filename);				    is_valid_d = false;				    return true; 				  }								  // method: setBasename				  //				  boolean setBasename(String basename) {				    return basename_d.assign(basename);				  }				    				  // method: setOutputExtension				  //				  boolean setOutputExtension(String extension) {				    output_extension_d = extension;				    is_valid_d = false;				    return true;				  }								  // method: setOutputType				  //				  boolean setOutputType(File::TYPE type) {				    if (type == File::TEXT) {				      feature_output_d.setFileType(FeatureFile::TEXT);				      audio_output_d.setFileType(AudioFile::TEXT);				    }				    else {				      feature_output_d.setFileType(FeatureFile::BINARY);				      audio_output_d.setFileType(AudioFile::BINARY);					    }					    return true;    				  }				  				  // method: setFileType				  //				  boolean setFileType(AudioFile::FILE_TYPE file_type) {				    audio_output_d.setFileType(file_type);				    return true;				  }				  				  // method: setFileType				  //				  boolean setFileType(FeatureFile::FILE_TYPE file_type) {				    feature_output_d.setFileType(file_type);				    return true;				  }								  // method: setFileFormat				  //				  boolean setFileFormat(FeatureFile::FILE_FORMAT file_format) {				    feature_output_d.setFileFormat(file_format);				    return true;				  }								  // method: setFileFormat				  //				  boolean setFileFormat(AudioFile::FILE_FORMAT file_format) {				    audio_output_d.setFileFormat(file_format);				    return true;				  }								  // method: set				  //				  boolean set(ALGORITHM algorithm = DEF_ALGORITHM,					      IMPLEMENTATION implementation = DEF_IMPLEMENTATION) {				    algorithm_d = algorithm;				    implementation_d = implementation;				    is_valid_d = false;				    return true;				  }								  //---------------------------------------------------------------------------				  //				  // class-specific public methods:				  //  get methods				  //				  //---------------------------------------------------------------------------								  // method: getAlgorithm				  //				  ALGORITHM getAlgorithm() const {				    return algorithm_d;				  }  								  // method: getImplementation				  //				  IMPLEMENTATION getImplementation() const {				    return implementation_d;				  }								  // method: getBasename				  //				  boolean getBasename(String& basename) const{				    return basename.assign(basename_d);				  }				  				  // method: getFilename				  //				  boolean getFilename(String& filename) const{				    filename = filename_d;				    return true; 				  }								  // method: getOutputExtension				  //				  boolean getOutputExtension(String& extension) const{				    extension = output_extension_d;				    return true; 				  }								  // method: get				  //				  boolean get(ALGORITHM& algorithm,					      IMPLEMENTATION& implementation) const{				    algorithm = algorithm_d;				    implementation = implementation_d;				    return true;				  }								  //---------------------------------------------------------------------------				  //				  // class-specific public methods:				  //  computational methods				  //				  //---------------------------------------------------------------------------				  				  //---------------------------------------------------------------------------				  //				  // class-specific public methods:				  //  public methods required by the AlgorithmBase interface contract				  //				  //---------------------------------------------------------------------------								  // assign method				  //				  boolean assign(const AlgorithmBase& arg);								  // equality method				  //				  boolean eq(const AlgorithmBase& arg) const;								  // method: className				  //				  const String& className() const {				    return CLASS_NAME;				  }								  // initialization method				  //				  boolean init();								  // apply method				  //				  boolean apply(Vector& output,						const Vector< CircularBuffer >& input);				  				  // method to set the parser				  //				  boolean setParser(SofParser* parser);								  //---------------------------------------------------------------------------				  //				  // private methods				  //				  //---------------------------------------------------------------------------				private:								  // algorithm-specific i/o methods: DATA				  //				  boolean readDataData(Sof& sof, const String& pname,							 long size, boolean param, boolean nested);				  boolean writeDataData(Sof& sof, const String& pname) const;				  				  // implementation specific compute methods: FEATURES				  //				  boolean computeFeatures(Vector& output,							  const Vector< CircularBuffer >&							  input);								  // implementation specific compute methods: SAMPLED_DATA				  //				  boolean computeSampledData(Vector& output,							     const Vector< CircularBuffer >&							     input);				};								// end of include file				// 				#endif							

相关资源