quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <Spectrum.h> Spectrum(); Spectrum(const Spectrum& arg); boolean eq(const Spectrum& arg); boolean setAlgorithm(ALGORITHM algorithm); boolean setFtOrder(long order);
description:VectorFloat input; VectorFloat output; Spectrum spec; input.assign(L"1.0, 2,0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0"); spec.compute(output, input);
static const String CLASS_NAME = L"Spectrum";
enum ALGORITHM { FOURIER = 0, MAXIMUM_ENTROPY, DEF_ALGORITHM = FOURIER };
enum IMPLEMENTATION { MAGNITUDE = 0, COMPLEX, DEF_IMPLEMENTATION = MAGNITUDE };
static const NameMap ALGO_MAP = L"FOURIER, MAXIMUM_ENTROPY";
static const NameMap IMPL_MAP = L"MAGNITUDE, COMPLEX";
static const Float MAGNITUDE_SCALE = 10;
static const ComplexFloat COMPLEX_SCALE = -20;
static const String DEF_PARAM = L"";
static const String PARAM_ALGORITHM = L"algorithm";
static const String PARAM_IMPLEMENTATION = L"implementation";
static const String PARAM_DYN_RANGE = L"dynamic_range";
static const String PARAM_FT = L"ft";
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::SIGNAL;
static const long ERR = 71600;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
Float dyn_range_d;
FourierTransform ft_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~Spectrum();
Spectrum(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, float dyn_range = Prediction::DEF_DYN_RANGE);
Spectrum(const Spectrum& arg);
Spectrum& operator= (const Spectrum& 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 Spectrum& 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 setDynRange(float dyn_range);
boolean setFtAlgorithm(FourierTransform::ALGORITHM algorithm);
boolean setFtImplementation(FourierTransform::IMPLEMENTATION implementation);
boolean setFtOrder(long order);
boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, float dyn_range = Prediction::DEF_DYN_RANGE, FourierTransform::ALGORITHM ft_algorithm = FourierTransform::DEF_ALGORITHM, FourierTransform::IMPLEMENTATION ft_implementation = FourierTransform::DEF_IMPLEMENTATION, long order = FourierTransform::DEF_ORDER);
ALGORITHM getAlgorithm() const;
IMPLEMENTATION getImplementation() const;
float getDynRange() const
FourierTransform::ALGORITHM getFtAlgorithm() const;
FourierTransform::IMPLEMENTATION getImplementation() const;
long getFtOrder() const
boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, float& dyn_range, FourierTransform::ALGORITHM& ft_algorithm, FourierTransform::IMPLEMENTATION& ft_implementation, long& order) const;
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean compute(VectorComplexFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE 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 apply(Vector<AlgorithmData>& output, const Vector<CircularBuffer<AlgorithmData>>& input);
boolean setParser(SofParser* parser);
boolean readDataCommon(Sof& sof, const String& pname, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeDataCommon(Sof& sof, const String& pname = DEF_PARAM) const;
boolean computeFourierMag(VectorFloat& output, const VectorFloat& input);
boolean computeFourierComplex(VectorComplexFloat& output, const VectorFloat& input);
boolean computeReflectionMag(VectorFloat& output, const VectorFloat& input, double range = Prediction::DEF_DYNAMIC_RANGE);
boolean computePredictionMag(VectorFloat& output, const VectorFloat& input);
boolean computeCorrelationMag(VectorFloat& output, const VectorFloat& input, double range = Prediction::DEF_DYNAMIC_RANGE);
boolean computeReflectionComplex(VectorComplexFloat& output, const VectorFloat& input, double range = Prediction::DEF_DYNAMIC_RANGE);
boolean computePredictionComplex(VectorComplexFloat& output, const VectorFloat& input);
boolean computeCorrelationComplex(VectorComplexFloat& output, const VectorFloat& input, double range = Prediction::DEF_DYNAMIC_RANGE);
// isip include files // #include <Spectrum.h> // main program starts here // int main(int argc, const char **argv) { // declare a Spectrum object and an output vector // Spectrum spectrum; VectorFloat output; // generate 30 ms sine wave of frequency 1000Hz // long sample_freq = 8000; long num_samples = 240; // set the input vector // VectorFloat input(num_samples); double step = Integral::TWO_PI * 1000.0 / (double)sample_freq; input.ramp(0, step); input.sin(); // set algorithm and implementation // spectrum.setAlgorithm(Spectrum::FOURIER); spectrum.setImplementation(Spectrum::MAGNITUDE); // set the algorithm, implementation and order of the underlying // FourierTransform object // spectrum.setFtAlgorithm(FourierTransform::FFT); spectrum.setFtImplementation(FourierTransform::SPLIT_RADIX); spectrum.setFtOrder((long)256); // compute the spectrum of input data // spectrum.compute(output, input); input.debug(L"input"); spectrum.debug(L"spectrum"); output.debug(L"output"); // exit gracefully // Integral::exit(); }