diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2021-03-24 18:29:20 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2021-03-24 18:29:20 -0400 |
commit | c59fdd88054cb99818d3d9008a447420f66dcbb9 (patch) | |
tree | 5aa777a75511887ab447401eb8311219d191dcb8 /gui/wxmain_mrun_genupload.cpp | |
parent | 5515642bf804870024633c1ad1887f819880b08c (diff) |
found formula library; cleaned up wxmain file split
Diffstat (limited to 'gui/wxmain_mrun_genupload.cpp')
-rw-r--r-- | gui/wxmain_mrun_genupload.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gui/wxmain_mrun_genupload.cpp b/gui/wxmain_mrun_genupload.cpp new file mode 100644 index 0000000..b720e3a --- /dev/null +++ b/gui/wxmain_mrun_genupload.cpp @@ -0,0 +1,28 @@ +#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; +} + |