// file: $isip/class/sp/FrontEnd/FrontEndBase.h // version: $Id: FrontEndBase.h 9236 2003-06-23 18:12:22Z gao $ // // this file defines the FrontEndBase class // // make sure definitions are only made once // #ifndef ISIP_FRONTEND_BASE #define ISIP_FRONTEND_BASE // forward class definitions // class Sdb; class Filename; // isip include files // #ifndef ISIP_STRING #include #endif #ifndef ISIP_NAME_MAP #include #endif // forward class definitions // class VectorFloat; // FrontEndBase: this class defines an interface contract for all front end // implementations (e.g., AudioFrontEnd) that allows data (e.g., audio, video) // to be converted to a feature stream. // class FrontEndBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- //---------------------------------------- // // default values and arguments // //---------------------------------------- enum DATA_TYPE { SAMPLED_DATA = 0, FEATURES, DEF_DATA_TYPE = SAMPLED_DATA }; enum DATA_MODE { NONE = 0, SOF_FEATURES_BINARY, SOF_FEATURES_TEXT, AUDIO_FILE, RAW_FEATURES, SOF_FEATURES = SOF_FEATURES_BINARY, DEF_DATA_MODE = NONE, DEF_INPUT_DATA_MODE = AUDIO_FILE, DEF_OUTPUT_DATA_MODE = SOF_FEATURES_BINARY }; static const NameMap DATA_MODE_MAP; static const NameMap DATA_TYPE_MAP; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = (int32)80250; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // declare a verbosity level // Integral::DEBUG verbosity_d; // declare a static debug level for all class instantiations // static Integral::DEBUG debug_level_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // debug methods // virtual bool8 debug(const unichar* message) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG level) { debug_level_d = level; return true; } // method: destructor // virtual ~FrontEndBase() {} // method: default constructor // FrontEndBase() { verbosity_d = Integral::NONE; } // assign methods // virtual bool8 assign(const FrontEndBase& arg) = 0; // i/o methods // virtual int32 sofSize() const = 0; virtual bool8 read(Sof& sof_a, int32 tag, const String& name) = 0; virtual bool8 write(Sof& sof_a, int32 tag, const String& name) const = 0; virtual bool8 readData(Sof& sof_a, const String& pname, int32 size, bool8 param, bool8 nested) = 0; virtual bool8 writeData(Sof& sof_a, const String& param) const = 0; // method: setParser // virtual bool8 setParser(SofParser* parser) { Error::handle(CLASS_NAME, L"getParser", Error::VIRTUAL_PTR, __FILE__, __LINE__); return (SofParser*)NULL; } // equality methods // virtual bool8 eq(const FrontEndBase& arg) const = 0; // clear methods // virtual bool8 clear(Integral::CMODE ctype_a) = 0; //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // method: setVerbosity // bool8 setVerbosity(Integral::DEBUG verbosity) { verbosity_d = verbosity; return true; } // set the number of channels // virtual bool8 setNumChannels(int32 arg) = 0; // set the name of the required features // virtual bool8 setCoefName(const String& name) = 0; // set the output basename // virtual bool8 setOutputBasename(String& basename) = 0; // set the output extension // virtual bool8 setOutputExtension(String& extension) = 0; // set output directory // virtual bool8 setOutputDirectory(const String& new_dir) = 0; // set directory preserve level // virtual bool8 setOutputPreserve(int32 new_preserve_level) = 0; // set the output suffix // virtual bool8 setOutputSuffix(String& suffix) = 0; // set the output type // virtual bool8 setOutputType(File::TYPE type) = 0; //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getVerbosity // Integral::DEBUG getVerbosity() const { return verbosity_d; } // get the total number of frames // virtual int32 getNumFeatures() = 0; // get the number of channels // virtual int32 getNumChannels() const = 0; // get the total number of frames // virtual int32 getNumFrames() = 0; // get the frame duration // virtual float32 getFrameDuration() const = 0; // get the utterance ID for the given file // virtual const String& getID() const = 0; // get the output basename // virtual const bool8 getOutputBasename(String& basename) const = 0; // get the output extension // virtual const bool8 getOutputExtension(String& extension) const = 0; // get the output suffix // virtual const bool8 getOutputSuffix(String& suffix) const = 0; // get the output type // virtual const File::TYPE& getOutputType() const = 0; // determine if a coefficient is an input // virtual bool8 isNameInput(const String& name) const = 0; // determine if input file exists // virtual bool8 getInputFlag() const = 0; //--------------------------------------------------------------------------- // // class-specific public methods: // core FrontEndBase interface contract methods // //--------------------------------------------------------------------------- // identification methods // virtual const String& className() const = 0; // get the coeff vector for a given frame // virtual bool8 getVector(VectorFloat& coeffs, int32 channel, int32 frame_index) = 0; // open and close the input files // virtual bool8 open(const Filename& input) = 0; virtual bool8 close() = 0; // init method // virtual bool8 init(float32 start_time, float32 stop_time, int channel) = 0; // process an entire file at a time // virtual bool8 run(const Filename& input) = 0; //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif