// file: $isip/class/mmedia/FeatureSelect/FeatureSelect.h // version: $Id: FeatureSelect.h 9407 2004-02-25 01:53:46Z parihar $ // // make sure definitions are only made once // #ifndef ISIP_FEATURE_SELECT #define ISIP_FEATURE_SELECT // isip include files // #ifndef ISIP_VECTOR_FLOAT #include #endif #ifndef ISIP_SDB #include #endif #ifndef ISIP_FEATURE_FILE #include #endif #ifndef ISIP_AUDIO_DATABASE #include #endif #ifndef ISIP_MEMORY_MANAGER #include #endif // FeatureSelect: a class that selects the feature // vectors. currently, only one algorithm is supported: // CLASS_BASED - selects out of class data // Only one implementation supported for NONE is: // NONE. // class FeatureSelect { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum ALGORITHM { CLASS_BASED = 0, DEF_ALGORITHM = CLASS_BASED }; // define the implementation choices // enum IMPLEMENTATION { NONE = 0, DEF_IMPLEMENTATION = NONE }; // 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; //---------------------------------------- // // default values and arguments // //---------------------------------------- static const unichar DEF_DELIM = L':'; static const int32 DEF_DIMENSION = 118; static const String DEF_RATIO_CLASS; static const String DEF_RATIO_SIMILAR; static const String DEF_OUTPUT_SUFFIX; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 50900; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // variables associated to feature selection // VectorLong ratio_class_d; VectorLong ratio_similar_d; // variables associated with input feature file // Long dim_d; FeatureFile::FILE_TYPE input_type_d; FeatureFile::FILE_FORMAT input_format_d; // variables associated with output feature file // FeatureFile::FILE_TYPE output_type_d; FeatureFile::FILE_FORMAT output_format_d; String output_directory_d; String output_extension_d; Long output_preserve_d; String output_suffix_d; // variables associated with the databases // Filename audiodb_file_d; AudioDatabase audiodb_d; // declare a static debug level for all class instantiations // static Integral::DEBUG debug_level_d; // declare a static debug level for all class instantiations // static Integral::DEBUG verbosity_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 bool8 diagnose(Integral::DEBUG debug_level); // method: setDebug // static bool8 setDebug(Integral::DEBUG arg) { debug_level_d = arg; return true; } // other debug methods // bool8 debug(const unichar* msg) const; // method: destructor // ~FeatureSelect() {} // other constructor // FeatureSelect(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION); FeatureSelect(const FeatureSelect& arg) { assign(arg); } // assign methods // bool8 assign(const FeatureSelect& arg); // method: operator= // FeatureSelect& operator= (const FeatureSelect& arg) { assign(arg); return *this; } // i/o methods // int32 sofSize() const; bool8 read(Sof& sof, int32 tag, const String& name = CLASS_NAME); bool8 write(Sof& sof, int32 tag, const String& name = CLASS_NAME) const; bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // equality methods // bool8 eq(const FeatureSelect& 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 bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // other memory management methods // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // method: setAlgorithm // bool8 setAlgorithm(ALGORITHM algorithm) { algorithm_d = algorithm; return true; } // method: setImplementation // bool8 setImplementation(IMPLEMENTATION implementation) { implementation_d = implementation; return true; } // method: setAudioDatabaseFile // bool8 setAudioDatabaseFile(const Filename& audiodb_file) { audiodb_file_d = audiodb_file; return true; } // method: setDimension // bool8 setDimension(int32 dim) { dim_d = dim; return true; } // method: setRatioClass // bool8 setRatioClass(const String& ratio_class) { ratio_class_d.assign(ratio_class, DEF_DELIM); return true; } // method: setRatioSimilar // bool8 setRatioSimilar(const String& ratio_similar) { ratio_similar_d.assign(ratio_similar, DEF_DELIM); return true; } // method: setInputType // bool8 setInputType(const FeatureFile::FILE_TYPE input_type = FeatureFile::DEF_FILE_TYPE) { input_type_d = input_type; return true; } // method: setInputFormat // bool8 setInputFormat(const FeatureFile::FILE_FORMAT input_format = FeatureFile::DEF_FILE_FORMAT) { input_format_d = input_format; return true; } // method: setOutputType // bool8 setOutputType(const FeatureFile::FILE_TYPE output_type = FeatureFile::DEF_FILE_TYPE) { output_type_d = output_type; return true; } // method: setOutputFormat // bool8 setOutputFormat(const FeatureFile::FILE_FORMAT output_format = FeatureFile::DEF_FILE_FORMAT) { output_format_d = output_format; return true; } // method: setOutputDirectory // bool8 setOutputDirectory(const String& new_dir) { return output_directory_d.assign(new_dir); } // method: setOutputExtension // bool8 setOutputExtension(const String& extension) { output_extension_d = extension; return true; } // method: setOutputPreserve // bool8 setOutputPreserve(const int32 new_preserve_level) { return output_preserve_d.assign(new_preserve_level); } // method: setOutputSuffix // bool8 setOutputSuffix(const String& suffix) { output_suffix_d = suffix; return true; } // method: setVerbosity // bool8 setVerbosity(const Integral::DEBUG verbosity) { verbosity_d = verbosity; 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: getAudioDatabaseFile // Filename getAudioDatabaseFile() const { return audiodb_file_d; } // method: getDimension // int32 getDimension() const { return dim_d; } // method: getRatioClass // VectorLong getRatioClass() const { return ratio_class_d; } // method: getRatioSimilar // VectorLong getRatioSimilar() const { return ratio_similar_d; } // method: getInputType // FeatureFile::FILE_TYPE getInputType() const { return input_type_d; } // method: getInputFormat // FeatureFile::FILE_FORMAT getInputFormat() const { return input_format_d; } // method: getOutputType // FeatureFile::FILE_TYPE getOutputType() const { return output_type_d; } // method: getOutputFormat // FeatureFile::FILE_FORMAT getOutputFormat() const { return output_format_d; } // method: getOutputDirectory // String getOutputDirectory() const { return output_directory_d; } // method: getOutputExtension // String getOutputExtension() const { return output_extension_d; } // method: getOutputPreserve // int32 getOutputPreserve() const { return (int32)output_preserve_d; } // method: getOutputSuffix // String getOutputSuffix() const { return output_suffix_d; } //--------------------------------------------------------------------------- // // class-specific public methods: // computational methods // //--------------------------------------------------------------------------- // compute method // bool8 compute(String& symbol, Sdb& symbols_similar, Sdb& symbols_all); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // methods to open audio database // bool8 openAudioDatabase(); // methods to close audio database // bool8 closeAudioDatabase(); // method to retrieve feature file from audio database // bool8 retrieveFtrFile(const String& identifier, Filename& ftr_file); // method to read features from feature file // bool8 readFeatures(const Filename& ftr_file, Vector& features); // method to write features to feature file // bool8 writeFeatures(const Filename& ftr_file, const Vector& features); // method to select features on a class basis // bool8 computeClassBased(const String& symbol, Sdb& symbols_similar, Sdb& symbols_all); // method to get features corresponding to symbols // bool8 getAllFeatures(Sdb& symbols, int32 num_feat_vectors, Vector& features); // method to get features corresponding to a symbol // bool8 getFeatures(String& symbol, int32 num_feat_vectors, Vector& features); }; // end of include file // #endif