diff --git a/src/projectM-engine/Parser.cpp b/src/projectM-engine/Parser.cpp index d976cb5f4..48ec7c1c1 100755 --- a/src/projectM-engine/Parser.cpp +++ b/src/projectM-engine/Parser.cpp @@ -652,7 +652,7 @@ GenExpr * Parser::parse_gen_expr ( std::istream & fs, TreeExpr * tree_expr, Pre switch (token = parseToken(fs,string)) { /* Left Parentice Case */ case tLPr: - + std::cerr << "token before tLPr:" << string << std::endl; /* CASE 1 (Left Parentice): See if the previous string before this parentice is a function name */ if ((func = BuiltinFuncs::find_func(string)) != NULL) { if (PARSE_DEBUG) { @@ -1228,6 +1228,7 @@ PerFrameEqn * Parser::parse_per_frame_eqn(std::istream & fs, int index, Preset PerFrameEqn * per_frame_eqn; GenExpr * gen_expr; + if (parseToken(fs, string) != tEq) { if (PARSE_DEBUG) printf("parse_per_frame_eqn: no equal sign after string \"%s\" (LINE %d)\n", string, line_count); return NULL; @@ -1237,7 +1238,7 @@ PerFrameEqn * Parser::parse_per_frame_eqn(std::istream & fs, int index, Preset if ((param = ParamUtils::find(string, &preset->builtinParams, &preset->user_param_tree)) == NULL) { return NULL; } - + if (PARSE_DEBUG) std::cerr << "parse_per_frame_eqn: parameter \"" << param->name << "\" retrieved (LINE" << line_count << ")" << std::endl; /* Make sure parameter is writable */ if (param->flags & P_FLAG_READONLY) { if (PARSE_DEBUG) std::cerr << "parse_per_frame_eqn: parameter \"" << param->name << "\" %s is marked as read only (LINE " << line_count << ")" << std::endl; diff --git a/src/projectM-engine/PerPointEqn.cpp b/src/projectM-engine/PerPointEqn.cpp index dd4f64169..105fd8db2 100755 --- a/src/projectM-engine/PerPointEqn.cpp +++ b/src/projectM-engine/PerPointEqn.cpp @@ -24,7 +24,7 @@ #include #include "projectM.hpp" - +#include #include "fatal.h" #include "Common.hpp" @@ -39,47 +39,54 @@ #include "wipemalloc.h" /* Evaluates a per point equation for the current custom wave given by interface_wave ptr */ -void PerPointEqn::evaluate() { - +void PerPointEqn::evaluate() +{ + int size; float * param_matrix; GenExpr * eqn_ptr; -// samples = CustomWave::interface_wave->samples; + // samples = CustomWave::interface_wave->samples; eqn_ptr = gen_expr; - - if (param->matrix == NULL) { - if ((param_matrix = (float*) (param->matrix = wipemalloc(size = samples*sizeof(float)))) == NULL) - return; - - memset(param_matrix, 0, size); + if (param->matrix == NULL) + { + assert(param->matrix_flag == false); + (*(float*)param->engine_val) = eqn_ptr->eval_gen_expr(-1,-1); + return; } - else - param_matrix = (float*)param->matrix; - for (int i = 0; i < samples; i++) { + else + { + param_matrix = (float*)param->matrix; + for (int i = 0; i < samples; i++) + { // -1 is because per points only use one dimension param_matrix[i] = eqn_ptr->eval_gen_expr(i, -1); + } + + /* Now that this parameter has been referenced with a per + point equation, we let the evaluator know by setting + this flag */ + + if (!param->matrix_flag) + param->matrix_flag = true; + } - /* Now that this parameter has been referenced with a per - point equation, we let the evaluator know by setting - this flag */ -if (!param->matrix_flag) - param->matrix_flag = true; } PerPointEqn::PerPointEqn(int _index, Param * _param, GenExpr * _gen_expr, int _samples): - index(_index), - samples(_samples), - param(_param), - gen_expr(_gen_expr) + index(_index), + samples(_samples), + param(_param), + gen_expr(_gen_expr) {} -PerPointEqn::~PerPointEqn() { - delete gen_expr; - } +PerPointEqn::~PerPointEqn() +{ + delete gen_expr; +} diff --git a/src/projectM-engine/PerPointEqn.hpp b/src/projectM-engine/PerPointEqn.hpp index 89ad22b47..a25fbd804 100755 --- a/src/projectM-engine/PerPointEqn.hpp +++ b/src/projectM-engine/PerPointEqn.hpp @@ -40,7 +40,6 @@ public: int samples; // the number of samples to iterate over Param *param; GenExpr * gen_expr; - ~PerPointEqn(); void evaluate(); PerPointEqn( int index, Param *param, GenExpr *gen_expr, int samples);