quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <Generator.h> Generator(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION); Generator(const Generator& arg); boolean assign(const Generator& arg); boolean setAlgorithm(ALGORITHM type);
description:Generator gen; VectorFloat input; VectorFloat output; gen.compute(output, input);
static const String CLASS_NAME = L"Generator";
enum ALGORITHM { SINE = 0, PULSE, TRIANGLE, GAUSSIAN, SQUARE, LORENTZ, ROSSLER, DEF_ALGORITHM = SINE };
enum IMPLEMENTATION { FUNCTION = 0, DEF_IMPLEMENTATION = FUNCTION };
enum PHMODE { DETERMINISTIC = 0, RANDOM, DEF_PHMODE = DETERMINISTIC };
static const NameMap ALGO_MAP(L"SINE, PULSE, TRIANGLE, GAUSSIAN, SQUARE, LORENTZ, ROSSLER");
static const NameMap IMPL_MAP(L"FUNCTION");
static const NameMap PHMODE_MAP(L"DETERMINISTIC, RANDOM");
static const String DEF_PARAM = L"";
static const String PARAM_ALGORITHM = L"algorithm";
static const String PARAM_IMPLEMENTATION = L"implementation";
static const String PARAM_PHMODE = L"phase_mode";
static const String PARAM_SAMPLE_FREQUENCY = L"sample_frequency";
static const String PARAM_FRAME_DURATION = L"frame_duration";
static const String PARAM_TIME = L"time";
static const String PARAM_ACCUM_FRAME = L"accum_frame";
static const String PARAM_CHANNELS = L"channels";
static const String PARAM_FREQUENCY = L"frequency";
static const String PARAM_AMPLITUDE = L"amplitude";
static const String PARAM_MEAN = L"mean";
static const String PARAM_VARIANCE = L"variance";
static const String PARAM_DUTY_CYCLE = L"duty_cycle";
static const String PARAM_PHASE = L"phase";
static const String PARAM_MODE = L"mode";
static const String PARAM_BIAS = L"DC";
static const String PARAM_BIAS = L"seed";
static const String PARAM_GEN_SAMPLE_FREQUENCY = L"gen_sample_frequency";
static const String PARAM_CHAOS_A = L"gen_chaos_a";
static const String PARAM_CHAOS_B = L"gen_chaos_b";
static const String PARAM_CHAOS_C = L"gen_chaos_c";
static const String PARAM_CHAOS_X0 = L"gen_chaos_x0";
static const String PARAM_CHAOS_Y0 = L"gen_chaos_y0";
static const String PARAM_CHAOS_Z0 = L"gen_chaos_z0";
static const String PARAM_CHAOS_integrate_upsample = L"gen_chaos_integrate_upsample";
static const double DEF_SAMPLE_FREQUENCY = 8000;
static const double DEF_FRAME_DURATION = 0.01;
static const llong DEF_TIME = (llong)0;
static const llong DEF_ACCUM_FRAME = (llong)0;
static const long DEF_CHANNELS = (long)1;
static const float DEF_AMPLITUDE = 1.0;
static const float DEF_FREQUENCY = 100;
static const float DEF_MEAN = 0.0;
static const float DEF_VARIANCE = 1.0;
static const float DEF_DUTY_CYCLE = 50.0;
static const float DEF_PHASE = 0.0;
static const llong DEF_BIAS = 0.0;
static const llong DEF_SEED = 27;
static const float DEF_CHAOS_A = 16;
static const float DEF_CHAOS_B = 40;
static const float DEF_CHAOS_C = 6;
static const float DEF_CHAOS_X0 = 0.5;
static const float DEF_CHAOS_Y0 = 0.5;
static const float DEF_CHAOS_Z0 = 0.5;
static const long DEF_CHAOS_INTEGRATE_UPSAMPLE = 1;
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::SIGNAL;
static const long ERR = 70900;
static const long ERR_ALGO = 70901;
static const long ERR_DTYPE = 70902;
static const long ERR_ZFREQ = 70903;
static const long ERR_FREQ = 70904;
static const long ERR_INTEGRATE = 70905;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
PHMODE phase_mode_d;
Float frequency_d;
Float amplitude_d;
Float phase_d;
Float mean_d;
Float variance_d;
Float duty_cycle_d;
Long channels_d;
Vector<Llong> accum_frame_d;
Float bias_d;
Long seed_d;
float chaos_a_d;
float chaos_b_d;
float chaos_c_d;
float chaos_x0_d;
float chaos_y0_d;
float chaos_z0_d;
long chaos_integrate_upsample_d;
Float gen_sample_freq_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~Generator();
Generator(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);
Generator(const Generator& arg);
boolean assign(const Generator& arg);
Generator& operator= (const Generator& 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 Generator& 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();
boolean setAlgorithm(ALGORITHM algorithm);
boolean setImplementation(IMPLEMENTATION implementation);
boolean set(ALGoRIHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);
boolean setPhaseMode(PHMODE phase_mode);
boolean setAccumFrame(Vector<Llong> &accum_frame);
boolean setChannel(long channels);
boolean setFrequency(Float frequency);
boolean setGenSampleFrequency(Float sf);
boolean setAmplitude(Float amplitude);
boolean setMean(Float mean);
boolean setVariance(Float mean);
boolean setDutyCycle(Float duty_cycle);
boolean setPhase(Float phase);
boolean setBias(Float bias);
boolean setSeed(Float bias);
boolean setSine(Float frequency, Float amplitude, Float phase, Float bias);
boolean setGaussian(Float mean, Float variance);
boolean setPulse(Float frequency, Float amplitude, Float phase, Float duty_cycle, Float bias);
boolean setSquare(Float frequency, Float amplitude, Float phase, Float duty_cycle, Float bias);
boolean setTriangle(Float frequency, Float amplitude, Float phase, Float duty_cycle, Float bias);
boolean setChaosParams(float chaos_a, float chaos_b, float chaos_c);
boolean setChaosInitialValues(float chaos_x0, float chaos_y0, float chaos_z0);
boolean setIntegrateUpsample(long chaos_integrate_upsample);
boolean setLorentz(float chaos_a, float chaos_b, float chaos_c,float chaos_x0, float chaos_y0, float chaos_z0, long chaos_integrate_upsample);
boolean setRossler(float chaos_a, float chaos_b, float chaos_c,float chaos_x0, float chaos_y0, float chaos_z0, long chaos_integrate_upsample);
ALGORITHM getAlgorithm() const;
IMPLEMENTATION getImplementation() const;
boolean get(Algorithm& algorithm, IMPLEMENTATION& implementation) const;
PHMODE getPhaseMode() const;
llong getAccumFrame() const;
long getChannel() const;
double getSampleFrequency() const;
double getFrameDuration() const;
Float getFrequency() const;
Float getAmplitude() const;
Float getMean() const;
Float getVariance() const;
Float getDutyCycle() const;
Float getPhase() const;
Float getBias() const;
Float getSeed() const;
Float getChaosA() const;
Float getChaosB() const;
Float getChaosC() const;
Float getChaosX0() const;
Float getChaosX0() const;
Float getChaosY0() const;
Float getChaosZ0() const;
Long getChaosIntegrationUpsample() const;
Float getGenSampleFrequency(Float& freq) const;
boolean compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, long channel_index = DEF_CHANNEL_INDEX);
boolean assign(const AlgorithmBase& arg);
boolean eq(const AlgorithmBase& arg) const;
boolean apply(Vector<AlgorithmData>& output, const Vector<CircularBuffer<AlgorithmData> >& input);
const String& className() const;
boolean init();
boolean setSampleFrequency(double sf);
boolean setFrameDuration(double fd);
boolean setParser(SofParser* parser);
boolean computeSine(VectorFloat& sine_wave, long channel_index);
boolean computeGaussianNoise(VectorFloat& gaussian_noise, long channel_index);
boolean computeSquare(VectorFloat& square_wave, long channel_index);
boolean computePulse(VectorFloat& pulse_wave, long channel_index);
boolean computeTriangle(VectorFloat& triangle_wave, long channel_index);
boolean computeLorentz(VectorFloat& lorentz, long channel_index);
boolean computeRossler(VectorFloat& rossler, long channel_index);
// isip include files // #include <Generator.h> // main program starts here // int main(int argc, const char **argv) { // declare a generator // Generator gen; // set signal type to be sine // gen.setAlgorithm(Generator::SINE); // set sample frequency // gen.setSampleFrequency(40); // set frame duration // gen.setFrameDuration(1); // set amplitude // gen.setAmplitude(1); // set frequency // gen.setFrequency(4); // create a pseudo input vector // VectorFloat input; // compute the signal output // VectorFloat output; gen.compute(output, input); // print the input, the output and the generator object to the console // input.debug(L"input:"); gen.debug(L"generator:"); output.debug(L"output:"); // exit gracefully // Integral::exit(); }
// isip include files // #include <Generator.h> // main program starts here // int main(int argc, const char **argv) { // declare a generator // Generator gen; // set signal type to be gaussian // gen.setAlgorithm(Generator::GAUSSIAN); // set the mean and the variance of the gaussian noise // gen.setMean(1.5); gen.setVariance(-0.5); // seed the random number generator // gen.setSeed(80); // set other parameters // gen.setSampleFrequency(40); gen.setFrameDuration(1); gen.setSignalDuration(1); // create a pseudo input vector // VectorFloat input; // compute the signal output // VectorFloat output; gen.compute(output, input); // print the input, the output and the generator object to the console // input.debug(L"input:"); gen.debug(L"generator:"); output.debug(L"output:"); // exit gracefully // Integral::exit(); }
// isip include files // #include <Generator.h> int main() { VectorFloat test_generation, dummy; // declare a generator // Generator gen1; // Set the type and parameters for the Lorentz system // gen1.set(Generator::LORENTZ); gen1.setSampleFrequency((float)100); gen1.setGenSampleFrequency((float)100); gen1.setSignalDuration(1); gen1.setFrameDuration(1); gen1.setLorentz((float)0.15, (float)0.2, (float)10, (float)0.5, (float)0.5 , (float)0.5, (float)0.5); gen1.compute(test_generation, dummy); // exit gracefully // Integral::exit(); }