quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <Energy.h> Energy(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, float floor); boolean eq(const Energy& arg); boolean setAlgorithm(ALGORITHM algorithm); boolean setFloor(float floor);
description:Energy egy; VectorFloat input(L"1, 0, -1"); VectorFloat output; egy.setAlgorithm(Energy::IDENTITY); egy.compute(output, input);
static const String CLASS_NAME = L"Energy";
enum ALGORITHM { SUM = 0, FILTER, DEF_ALGORITHM = SUM };
enum IMPLEMENTATION { IDENTITY = 0, LOG, DB, POWER, LOG_POWER, DB_POWER, RMS, LOG_RMS, DB_RMS, DEF_IMPLEMENTATION = IDENTITY };
static const NameMap ALGO_MAP(L"SUM, FILTER");
static const NameMap IMPL_MAP(L"IDENTITY, LOG, DB, POWER, LOG_POWER, DB_POWER, RMS, LOG_RMS, DB_RMS");
static const String DEF_PARAM = L"";
static const String PARAM_ALGORITHM = L"algorithm";
static const String PARAM_IMPLEMENTATION = L"implementation";
static const String PARAM_FLOOR = L"floor";
static const String PARAM_MA_COEF = L"ma_coef";
static const String PARAM_AR_COEF = L"ar_coef";
static const float DEF_FLOOR = 0;
const VectorFloat Energy::DEF_MA_COEF(L"1");
const VectorFloat Energy::DEF_AR_COEF(L"1");
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::DEF_CTYPE;
static const long ERR = 70500;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
Float floor_d;
static MemoryManager mgr_d;
VectorFloat ma_coef_d;
VectorFloat ar_coef_d;
Vector< CircularDelayLine<Float> > ma_mem_d;
Vector< CircularDelayLine<Float> > ar_mem_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~Energy();
Energy(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, float floor);
Energy(const Energy& arg);
boolean assign(const Energy& arg);
Energy& operator= (const Energy& arg);
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;
boolean eq(const Energy& arg) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);
boolean setAlgorithm(ALGORITHM algorithm);
boolean setImplementation(IMPLEMENTATION implementation);
boolean setFloor(float floor = DEF_FLOOR);
boolean setFilter(VectorFloat& ma_coef_a, VectorFloat& ar_coef_a);
boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, float floor = DEF_FLOOR);
ALGORITHM getAlgorithm() const;
IMPLEMENTATION getImplementation() const;
float getFloor() const;
float getFilter(VectorFloat& ma_coef_a, VectorFloat& ar_coef_a) const;
boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, float& order);
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean compute(VectorFloat& output, const VectorComplexFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean assign(const AlgorithmBase& arg);
boolean eq(const AlgorithmBase& arg) const;
const String& className() const;
boolean init();
boolean apply(Vector<AlgorithmData>& output, const Vector<AlgorithmData>& input);
boolean setParser(SofParser* parser);
boolean readDataSum(Sof& sof, const String& pname, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeDataSum(Sof& sof, const String& pname) const;
boolean readDataFilt(Sof& sof, const String& pname, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeDataFilt(Sof& sof, const String& pname) const;
boolean computeSum(VectorFloat& output, const VectorFloat& input);
boolean computeFilt(VectorFloat& output, const VectorFloat& input, long channel_index);
boolean scale(const Float& value, long len);
// declare an Energy object and an output vector // Energy egy; VectorFloat output; // set the input vector // VectorFloat input(L"0, 1, 2"); // choose algorithm // enrgy.setAlgorithm(Energy::SUM); // choose implementation // egy.setImplementation(Energy::DB); // compute the energy of input data // egy.compute(output, input);
// declare an Energy object and an output vector // Energy egy; VectorFloat output; // set the input vector // VectorFloat input(L"0,1,2,3,4") // choose the algorithm and implementation // egy.setAlgorithm(Energy::FILTER); egy.setImplementation(Energy::LOG_POWER); // set up a filter // VectorFloat ma_coef(L"1,1,1"); VectorFloat ar_coef(L"1"); egy.setFilter(ma_coef, ar_coef); // compute the energy of input data // egy.compute(output, input);