// file: $isip/class/sp/FrontEnd/FrontEnd.h // version: $Id: FrontEnd.h 9236 2003-06-23 18:12:22Z gao $ // // this file defines the FrontEnd class // // make sure definitions are only made once // #ifndef ISIP_FRONTEND #define ISIP_FRONTEND #ifndef ISIP_FRONTEND_BASE #include #endif #ifndef ISIP_FRONTEND_UNDEFINED #include #endif #ifndef NAME_MAP #include #endif // FrontEnd: this class, coupled with FrontEndBase, defines a methodology // for implementing generic front ends - systems that convert a signal // (e.g., audio, video) to a feature stream. // class FrontEnd : public FrontEndBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: static const String CLASS_NAME; enum TYPES { AUDIO = 0, VIDEO, DEF_TYPE = AUDIO }; static const NameMap TYPES_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String PARAM_TYPES; //---------------------------------------- // // default values and arguments // //---------------------------------------- //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 80200; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // pointer to the base class object // FrontEndBase* virtual_fe_d; // define an empty object used for uninitialized things // static FrontEndUndefined NO_FRONTEND; // memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } static bool8 diagnose(Integral::DEBUG debug_level); // method: debug // setDebug is inherited from base class // bool8 debug(const unichar* msg) const { return virtual_fe_d->debug(msg); } // method: destructor // ~FrontEnd() { if (virtual_fe_d != (FrontEndBase*)&NO_FRONTEND) { delete virtual_fe_d; } } // method: default constructor // FrontEnd() { virtual_fe_d = (FrontEndBase*)&NO_FRONTEND; } // method: copy constructor // FrontEnd(const FrontEnd& arg) { virtual_fe_d = (FrontEndBase*)&NO_FRONTEND; assign(arg); } // method: assign // bool8 assign(const FrontEnd& arg) { return assign(*(arg.virtual_fe_d)); } // 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 = String::EMPTY, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeData(Sof& sof, const String& pname = String::EMPTY) const; // method: eq // bool8 eq(const FrontEnd& arg) const { return virtual_fe_d->eq(*(arg.virtual_fe_d)); } // 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); } // method: clear // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE) { return virtual_fe_d->clear(ctype); } //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // configuration methods // bool8 setType(TYPES type); // method: setVerbosity // bool8 setVerbosity(Integral::DEBUG verbosity) { return virtual_fe_d->setVerbosity(verbosity); } // method: setOutputDirectory // bool8 setOutputDirectory(const String& new_dir) { return virtual_fe_d->setOutputDirectory(new_dir); } // method: setOutputBasename // bool8 setOutputBasename(String& basename) { return virtual_fe_d->setOutputBasename(basename); } // method: setOutputExtension // bool8 setOutputExtension(String& extension) { return virtual_fe_d->setOutputExtension(extension); } // method: setOutputPreserve // bool8 setOutputPreserve(int32 new_preserve_level) { return virtual_fe_d->setOutputPreserve(new_preserve_level); } // method: setOutputSuffix // bool8 setOutputSuffix(String& suffix) { return virtual_fe_d->setOutputSuffix(suffix); } // method: setOutputType // bool8 setOutputType(File::TYPE type) { return virtual_fe_d->setOutputType(type); } // method: setOutputType // bool8 setOutputType(String& type) { if (type.eq(File::TYPE_TEXT, false)) { return virtual_fe_d->setOutputType(File::TEXT); } else { return virtual_fe_d->setOutputType(File::BINARY); } } // method: setNumChannels // bool8 setNumChannels(int32 arg) { return virtual_fe_d->setNumChannels(arg); } // method: setCoefName // set the name of the required features // bool8 setCoefName(const String& name) { return virtual_fe_d->setCoefName(name); } //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getType // TYPES getType() const { return (TYPES)TYPES_MAP(virtual_fe_d->className()); } // method: getVerbosity // Integral::DEBUG getVerbosity() const { return virtual_fe_d->getVerbosity(); } // method: getOutputBasename // const bool8 getOutputBasename(String& basename) const { return virtual_fe_d->getOutputBasename(basename); } // method: getOutputExtension // const bool8 getOutputExtension(String& extension) const { return virtual_fe_d->getOutputExtension(extension); } // method: getOutputSuffix // const bool8 getOutputSuffix(String& suffix) const { return virtual_fe_d->getOutputSuffix(suffix); } // method: getOutputType // const File::TYPE& getOutputType() const { return virtual_fe_d->getOutputType(); } // method: getVector // get the coeff vector for a given frame // bool8 getVector(VectorFloat& coeffs, int32 channel, int32 frame_index) { return virtual_fe_d->getVector(coeffs, channel, frame_index); } // method: getNumFeatures // get the total number of features after process a certain recipe // int32 getNumFeatures() { return virtual_fe_d->getNumFeatures(); } // method: getNumChannels // int32 getNumChannels() const { return virtual_fe_d->getNumChannels(); } // method: getNumFrames // get the total number of frames of the AudioFile // int32 getNumFrames() { return virtual_fe_d->getNumFrames(); } // method: getFrameDuration // get the frame duration // float32 getFrameDuration() const { return virtual_fe_d->getFrameDuration(); } // method: getID // virtual const String& getID() const { return virtual_fe_d->getID(); } // method: isNameInput // determine if a coefficient is an input or not // bool8 isNameInput(const String& name) const { return virtual_fe_d->isNameInput(name); } // method: getInputFlag // determine if input file exist // bool8 getInputFlag() const { return virtual_fe_d->getInputFlag(); } //--------------------------------------------------------------------------- // // class-specific public methods: // public methods required by the FrontEndBase interface contract // //--------------------------------------------------------------------------- // method: eq // bool8 eq(const FrontEndBase& arg) const { return virtual_fe_d->eq(arg); } // assign methods // bool8 assign(const FrontEndBase& arg); // method: className // const String& className() const { return virtual_fe_d->className(); } // method: open // bool8 open(const Filename& input) { return virtual_fe_d->open(input); } // method: close // bool8 close() { return virtual_fe_d->close(); } // method: init // bool8 init(float32 start_time, float32 stop_time, int channel) { return virtual_fe_d->init(start_time, stop_time, channel); } // method: run // process an entire file at a time // bool8 run(const Filename& input) { return virtual_fe_d->run(input); } //--------------------------------------------------------------------------- // // class-specific public methods: // additional parameter file processing methods // //--------------------------------------------------------------------------- // method: load // bool8 load(const Filename& input); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // reset methods // bool8 reset(); }; // end of include file // #endif