You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
stmdsp/gui/wxmain_mrun_genupload.cpp

29 lines
731 B
C++

#include "stmdsp.hpp"
#include "exprtk.hpp"
#include <string>
#include <vector>
std::vector<stmdsp::dacsample_t> siggen_formula_parse(const std::string& formulaString)
{
double x = 0;
exprtk::symbol_table<double> symbol_table;
symbol_table.add_variable("x", x);
symbol_table.add_constants();
exprtk::expression<double> expression;
expression.register_symbol_table(symbol_table);
exprtk::parser<double> parser;
parser.compile(formulaString, expression);
std::vector<stmdsp::dacsample_t> samples;
for (x = 0; samples.size() < stmdsp::SAMPLES_MAX; x += 1) {
auto y = static_cast<stmdsp::dacsample_t>(expression.value());
samples.push_back(y);
}
return samples;
}