From 82df72887eea5c35b3ec16f1cc3a7d520d6caf6a Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Tue, 19 Jun 2007 03:53:46 +0000 Subject: [PATCH] refactored code builds! seriously broken however git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/dev-1.0@196 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/BuiltinFuncs.cpp | 157 +++ src/projectM-engine/BuiltinFuncs.hpp | 225 ++++ src/projectM-engine/BuiltinParams.cpp | 191 +-- src/projectM-engine/BuiltinParams.hpp | 21 +- src/projectM-engine/CMakeLists.txt | 6 +- src/projectM-engine/CustomShape.cpp | 51 +- src/projectM-engine/CustomShape.h | 1 + src/projectM-engine/CustomWave.cpp | 74 +- src/projectM-engine/CustomWave.h | 6 +- src/projectM-engine/Eval.cpp | 2 +- src/projectM-engine/Expr.h | 2 +- src/projectM-engine/Func.cpp | 10 +- src/projectM-engine/Func.h | 9 +- src/projectM-engine/Param.cpp | 171 +-- src/projectM-engine/Parser.cpp | 52 +- src/projectM-engine/PerPointEqn.cpp | 4 +- src/projectM-engine/Preset.cpp | 130 +- src/projectM-engine/Preset.hpp | 158 +-- src/projectM-engine/PresetFrameIO.hpp | 160 +++ src/projectM-engine/PresetSwitcher.cpp | 224 ++++ src/projectM-engine/PresetSwitcher.hpp | 37 + src/projectM-engine/builtin_funcs.h | 219 ---- src/projectM-engine/console_interface.cpp | 38 +- src/projectM-engine/editor.cpp | 2 +- src/projectM-engine/menu.cpp | 140 +- src/projectM-engine/projectM.cpp | 1422 ++++++++------------- src/projectM-engine/projectM.h | 58 +- 27 files changed, 1812 insertions(+), 1758 deletions(-) create mode 100644 src/projectM-engine/BuiltinFuncs.cpp create mode 100644 src/projectM-engine/BuiltinFuncs.hpp create mode 100644 src/projectM-engine/PresetFrameIO.hpp create mode 100644 src/projectM-engine/PresetSwitcher.cpp create mode 100644 src/projectM-engine/PresetSwitcher.hpp delete mode 100755 src/projectM-engine/builtin_funcs.h diff --git a/src/projectM-engine/BuiltinFuncs.cpp b/src/projectM-engine/BuiltinFuncs.cpp new file mode 100644 index 000000000..ca302b844 --- /dev/null +++ b/src/projectM-engine/BuiltinFuncs.cpp @@ -0,0 +1,157 @@ +// +// C++ Implementation: BuiltinFuncs +// +// Description: +// +// +// Author: Carmelo Piccione , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +/* Loads all builtin functions */ + + +/* Loads a builtin function */ +#include "BuiltinFuncs.hpp" + +int BuiltinFuncs::load_builtin_func(char * name, float (*func_ptr)(float*), int num_args) { + + Func * func; + int retval; + + /* Create new function */ + func = Func::create_func(name, func_ptr, num_args); + + if (func == NULL) + return PROJECTM_OUTOFMEM_ERROR; + + retval = insert_func( func ); + + return retval; + +} + + + +/* Find a function given its name */ +Func * BuiltinFuncs::find_func(char * name) { + + Func * func = NULL; + + /* First look in the builtin database */ + func = (Func *)builtin_func_tree->splay_find(name); + + return func; + +} + + +/* Remove a function from the database */ +int BuiltinFuncs::remove_func( Func *func ) { + + builtin_func_tree->splay_delete(func->name); + + return PROJECTM_SUCCESS; +} + +int BuiltinFuncs::load_all_builtin_func() { + + if (load_builtin_func("int", FuncWrappers::int_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("abs", FuncWrappers::abs_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("sin", FuncWrappers::sin_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("cos", FuncWrappers::cos_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("tan", FuncWrappers::tan_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("asin", FuncWrappers::asin_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("acos", FuncWrappers::acos_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("atan", FuncWrappers::atan_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("sqr", FuncWrappers::sqr_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("sqrt", FuncWrappers::sqrt_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("pow", FuncWrappers::pow_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("exp", FuncWrappers::exp_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("log", FuncWrappers::log_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("log10", FuncWrappers::log10_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("sign", FuncWrappers::sign_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("min", FuncWrappers::min_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("max", FuncWrappers::max_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("sigmoid", FuncWrappers::sigmoid_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("atan2", FuncWrappers::atan2_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("rand", FuncWrappers::rand_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("band", FuncWrappers::band_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("bor", FuncWrappers::bor_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("bnot", FuncWrappers::bnot_wrapper, 1) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("if", FuncWrappers::if_wrapper, 3) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("equal", FuncWrappers::equal_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("above", FuncWrappers::above_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("below", FuncWrappers::below_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("nchoosek", FuncWrappers::nchoosek_wrapper, 2) < 0) + return PROJECTM_ERROR; + if (load_builtin_func("fact", FuncWrappers::fact_wrapper, 1) < 0) + return PROJECTM_ERROR; + + return PROJECTM_SUCCESS; +} + + +/* Initialize the builtin function database. + Should only be necessary once */ +int BuiltinFuncs::init_builtin_func_db() { + int retval; + + builtin_func_tree = + SplayTree::create_splaytree((int (*)(void*,void*))compare_string, (void*(*)(void*))copy_string, (void(*)(void*))free_string); + + if (builtin_func_tree == NULL) + return PROJECTM_OUTOFMEM_ERROR; + + retval = load_all_builtin_func(); + return PROJECTM_SUCCESS; +} + + + +/* Destroy the builtin function database. + Generally, do this on projectm exit */ +int BuiltinFuncs::destroy_builtin_func_db() { + + builtin_func_tree->splay_traverse((void (*)(void*))free_func_helper); + return PROJECTM_SUCCESS; +} + +/* Insert a function into the database */ +int BuiltinFuncs::insert_func( Func *func ) { + + builtin_func_tree->splay_insert(func, func->name); + + return PROJECTM_SUCCESS; +} + + diff --git a/src/projectM-engine/BuiltinFuncs.hpp b/src/projectM-engine/BuiltinFuncs.hpp new file mode 100644 index 000000000..e8309ff7e --- /dev/null +++ b/src/projectM-engine/BuiltinFuncs.hpp @@ -0,0 +1,225 @@ +// +// C++ Interface: BuiltinFuncs +// +// Description: +// +// +// Author: Carmelo Piccione , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef _BUILTIN_FUNCS_HPP +#define _BUILTIN_FUNCS_HPP + +#include "common.h" +#include "Func.h" +#include +#include +#include "projectM.h" +/* Wrappers for all the builtin functions + The arg_list pointer is a list of floats. Its + size is equal to the number of arguments the parameter + takes */ +class FuncWrappers { + +/* Values to optimize the sigmoid function */ +static const int R = 32767; +static const int RR = 65534; + +public: + +static inline float int_wrapper(float * arg_list) { + +return floor(arg_list[0]); + +} + + +static inline float sqr_wrapper(float * arg_list) { + +return pow(2, arg_list[0]); +} + + +static inline float sign_wrapper(float * arg_list) { + +return -arg_list[0]; +} + +static inline float min_wrapper(float * arg_list) { + +if (arg_list[0] > arg_list[1]) +return arg_list[1]; + +return arg_list[0]; +} + +static inline float max_wrapper(float * arg_list) { + +if (arg_list[0] > arg_list[1]) +return arg_list[0]; + +return arg_list[1]; +} + +/* consult your AI book */ +static inline float sigmoid_wrapper(float * arg_list) { +return (RR / (1 + exp( -(((float)(arg_list[0])) * arg_list[1]) / R) - R)); +} + + +static inline float bor_wrapper(float * arg_list) { + +return (float)((int)arg_list[0] || (int)arg_list[1]); +} + +static inline float band_wrapper(float * arg_list) { +return (float)((int)arg_list[0] && (int)arg_list[1]); +} + +static inline float bnot_wrapper(float * arg_list) { +return (float)(!(int)arg_list[0]); +} + +static inline float if_wrapper(float * arg_list) { + +if ((int)arg_list[0] == 0) +return arg_list[2]; +return arg_list[1]; +} + + +static inline float rand_wrapper(float * arg_list) { +float l=1; + +// printf("RAND ARG:(%d)\n", (int)arg_list[0]); +if ((int)arg_list[0] > 0) +l = (float)((rand()) % ((int)arg_list[0])); +//printf("VAL: %f\n", l); +return l; +} + +static inline float equal_wrapper(float * arg_list) { + return (arg_list[0] == arg_list[1]); +} + + +static inline float above_wrapper(float * arg_list) { + +return (arg_list[0] > arg_list[1]); +} + + +static inline float below_wrapper(float * arg_list) { + +return (arg_list[0] < arg_list[1]); +} + +static inline float sin_wrapper(float * arg_list) { +return (sin (arg_list[0])); +} + + +static inline float cos_wrapper(float * arg_list) { +return (cos (arg_list[0])); +} + +static inline float tan_wrapper(float * arg_list) { +return (tan(arg_list[0])); +} + +static inline float asin_wrapper(float * arg_list) { +return (asin (arg_list[0])); +} + +static inline float acos_wrapper(float * arg_list) { +return (acos (arg_list[0])); +} + +static inline float atan_wrapper(float * arg_list) { +return (atan (arg_list[0])); +} + +static inline float atan2_wrapper(float * arg_list) { +return (atan2 (arg_list[0], arg_list[1])); +} + +static inline float pow_wrapper(float * arg_list) { +return (pow (arg_list[0], arg_list[1])); +} + +static inline float exp_wrapper(float * arg_list) { +return (exp(arg_list[0])); +} + +static inline float abs_wrapper(float * arg_list) { +return (fabs(arg_list[0])); +} + +static inline float log_wrapper(float* arg_list) { +return (log (arg_list[0])); +} + +static inline float log10_wrapper(float * arg_list) { +return (log10 (arg_list[0])); +} + +static inline float sqrt_wrapper(float * arg_list) { +return (sqrt (arg_list[0])); +} + + +static inline float nchoosek_wrapper(float * arg_list) { +unsigned long cnm = 1UL; +int i, f; +int n, m; + +n = (int)arg_list[0]; +m = (int)arg_list[1]; + +if (m*2 >n) m = n-m; +for (i=1 ; i <= m; n--, i++) +{ +if ((f=n) % i == 0) +f /= i; +else cnm /= i; +cnm *= f; +} +return (float)cnm; +} + + +static inline float fact_wrapper(float * arg_list) { + + +int result = 1; + +int n = (int)arg_list[0]; + +while (n > 1) { +result = result * n; +n--; +} +return (float)result; +} +}; + + +class BuiltinFuncs { + +public: + static SplayTree * builtin_func_tree; + static int init_builtin_func_db(); + static int destroy_builtin_func_db(); + static int load_all_builtin_func(); + static int load_builtin_func( char * name, float (*func_ptr)(float*), int num_args ); + + static int insert_func( Func *func ); + static int remove_func( Func *func ); + static Func *find_func( char *name ); + +}; + +#endif diff --git a/src/projectM-engine/BuiltinParams.cpp b/src/projectM-engine/BuiltinParams.cpp index ad0bd093e..0978753cf 100644 --- a/src/projectM-engine/BuiltinParams.cpp +++ b/src/projectM-engine/BuiltinParams.cpp @@ -1,19 +1,21 @@ #include "BuiltinParams.hpp" +#include "projectM.h" +BuiltinParams::BuiltinParams() {} -BuiltinParams::BuiltinParams() { +BuiltinParams::BuiltinParams(const PresetInputs & presetInputs, PresetOutputs & presetOutputs) { int ret; - if ((ret = init_builtin_param_db()) != PROJECTM_SUCCESS) { + if ((ret = init_builtin_param_db(presetInputs, presetOutputs)) != PROJECTM_SUCCESS) { throw ret; } } -~BuiltinParams::BuiltinParams() { +BuiltinParams::~BuiltinParams() { destroy_builtin_param_db(); } @@ -88,7 +90,7 @@ int BuiltinParams::destroy_builtin_param_db() { /* Insert a parameter into the database with an alternate name */ -int BuiltinParams::insert_param_alt_name(BuiltinParams *param, char * alt_name) { +int BuiltinParams::insert_param_alt_name(Param *param, char * alt_name) { if (alt_name == NULL) return PROJECTM_ERROR; @@ -170,7 +172,7 @@ int BuiltinParams::load_builtin_param_bool(char * name, void * engine_val, short } /* Inserts a parameter into the builtin database */ -int BuiltinParams::insert_builtin_param( BuiltinParams *param ) { +int BuiltinParams::insert_builtin_param( Param *param ) { return builtin_param_tree->splay_insert(param, param->name); } @@ -179,7 +181,7 @@ int BuiltinParams::insert_builtin_param( BuiltinParams *param ) { /* Initialize the builtin parameter database. Should only be necessary once */ -int BuiltinParams::init_builtin_param_db() { +int BuiltinParams::init_builtin_param_db(const PresetInputs & presetInputs, PresetOutputs & presetOutputs) { /* Create the builtin parameter splay tree (go Sleator...) */ if ((this->builtin_param_tree = SplayTree::create_splaytree((int (*)(void*,void*))compare_string,(void* (*)(void*)) copy_string, (void (*)(void*))free_string)) == NULL) { @@ -193,7 +195,7 @@ int BuiltinParams::init_builtin_param_db() { } /* Loads all builtin parameters into the database */ - if (BuiltinParams::load_all_builtin_param() < 0) { + if (load_all_builtin_param(presetInputs, presetOutputs) < 0) { if (BUILTIN_PARAMS_DEBUG) printf("failed loading builtin parameters (FATAL)\n"); return PROJECTM_ERROR; } @@ -205,113 +207,116 @@ int BuiltinParams::init_builtin_param_db() { } +void BuiltinParams::traverse(void (*func_ptr)(void*)) { + builtin_param_tree->splay_traverse(func_ptr); +} /* Loads all builtin parameters, limits are also defined here */ -int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, PresetOutputs & presetOutputs) { +int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, PresetOutputs & presetOutputs) { - load_builtin_param_float("fRating", (void*)&presetOutputs->fRating, NULL, P_FLAG_NONE, 0.0 , 5.0, 0.0, NULL); - load_builtin_param_float("fWaveScale", (void*)&presetOutputs->fWaveScale, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("gamma", (void*)&presetOutputs->fGammaAdj, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fGammaAdj"); - load_builtin_param_float("echo_zoom", (void*)&presetOutputs->fVideoEchoZoom, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fVideoEchoZoom"); - load_builtin_param_float("echo_alpha", (void*)&presetOutputs->fVideoEchoAlpha, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fVideoEchoAlpha"); - load_builtin_param_float("wave_a", (void*)&presetOutputs->fWaveAlpha, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fWaveAlpha"); - load_builtin_param_float("fWaveSmoothing", (void*)&presetOutputs->fWaveSmoothing, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - load_builtin_param_float("fModWaveAlphaStart", (void*)&presetOutputs->fModWaveAlphaStart, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - load_builtin_param_float("fModWaveAlphaEnd", (void*)&presetOutputs->fModWaveAlphaEnd, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - load_builtin_param_float("fWarpAnimSpeed", (void*)&presetOutputs->fWarpAnimSpeed, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - // load_builtin_param_float("warp", (void*)&presetOutputs->warp, warp_mesh, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("fRating", (void*)&presetOutputs.fRating, NULL, P_FLAG_NONE, 0.0 , 5.0, 0.0, NULL); + load_builtin_param_float("fWaveScale", (void*)&presetOutputs.fWaveScale, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("gamma", (void*)&presetOutputs.fGammaAdj, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fGammaAdj"); + load_builtin_param_float("echo_zoom", (void*)&presetOutputs.fVideoEchoZoom, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fVideoEchoZoom"); + load_builtin_param_float("echo_alpha", (void*)&presetOutputs.fVideoEchoAlpha, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fVideoEchoAlpha"); + load_builtin_param_float("wave_a", (void*)&presetOutputs.fWaveAlpha, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fWaveAlpha"); + load_builtin_param_float("fWaveSmoothing", (void*)&presetOutputs.fWaveSmoothing, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + load_builtin_param_float("fModWaveAlphaStart", (void*)&presetOutputs.fModWaveAlphaStart, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + load_builtin_param_float("fModWaveAlphaEnd", (void*)&presetOutputs.fModWaveAlphaEnd, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + load_builtin_param_float("fWarpAnimSpeed", (void*)&presetOutputs.fWarpAnimSpeed, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + // load_builtin_param_float("warp", (void*)&presetOutputs.warp, warp_mesh, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("fShader", (void*)&presetOutputs->fShader, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - load_builtin_param_float("decay", (void*)&presetOutputs->decay, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fDecay"); + load_builtin_param_float("fShader", (void*)&presetOutputs.fShader, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + load_builtin_param_float("decay", (void*)&presetOutputs.decay, NULL, P_FLAG_NONE, 0.0, 1.0, 0, "fDecay"); - load_builtin_param_int("echo_orient", (void*)&presetOutputs->nVideoEchoOrientation, P_FLAG_NONE, 0, 3, 0, "nVideoEchoOrientation"); - load_builtin_param_int("wave_mode", (void*)&presetOutputs->nWaveMode, P_FLAG_NONE, 0, 7, 0, "nWaveMode"); + load_builtin_param_int("echo_orient", (void*)&presetOutputs.nVideoEchoOrientation, P_FLAG_NONE, 0, 3, 0, "nVideoEchoOrientation"); + load_builtin_param_int("wave_mode", (void*)&presetOutputs.nWaveMode, P_FLAG_NONE, 0, 7, 0, "nWaveMode"); - load_builtin_param_bool("wave_additive", (void*)&presetOutputs->bAdditiveWaves, P_FLAG_NONE, FALSE, "bAdditiveWaves"); - load_builtin_param_bool("bModWaveAlphaByVolume", (void*)&presetOutputs->bModWaveAlphaByVolume, P_FLAG_NONE, FALSE, NULL); - load_builtin_param_bool("wave_brighten", (void*)&presetOutputs->bMaximizeWaveColor, P_FLAG_NONE, FALSE, "bMaximizeWaveColor"); - load_builtin_param_bool("wrap", (void*)&presetOutputs->bTexWrap, P_FLAG_NONE, FALSE, "bTexWrap"); - load_builtin_param_bool("darken_center", (void*)&presetOutputs->bDarkenCenter, P_FLAG_NONE, FALSE, "bDarkenCenter"); - load_builtin_param_bool("bRedBlueStereo", (void*)&presetOutputs->bRedBlueStereo, P_FLAG_NONE, FALSE, NULL); - load_builtin_param_bool("brighten", (void*)&presetOutputs->bBrighten, P_FLAG_NONE, FALSE, "bBrighten"); - load_builtin_param_bool("darken", (void*)&presetOutputs->bDarken, P_FLAG_NONE, FALSE, "bDarken"); - load_builtin_param_bool("solarize", (void*)&presetOutputs->bSolarize, P_FLAG_NONE, FALSE, "bSolarize"); - load_builtin_param_bool("invert", (void*)&presetOutputs->bInvert, P_FLAG_NONE, FALSE, "bInvert"); - load_builtin_param_bool("bMotionVectorsOn", (void*)&presetOutputs->bMotionVectorsOn, P_FLAG_NONE, FALSE, NULL); - load_builtin_param_bool("wave_dots", (void*)&presetOutputs->bWaveDots, P_FLAG_NONE, FALSE, "bWaveDots"); - load_builtin_param_bool("wave_thick", (void*)&presetOutputs->bWaveThick, P_FLAG_NONE, FALSE, "bWaveThick"); + load_builtin_param_bool("wave_additive", (void*)&presetOutputs.bAdditiveWaves, P_FLAG_NONE, FALSE, "bAdditiveWaves"); + load_builtin_param_bool("bModWaveAlphaByVolume", (void*)&presetOutputs.bModWaveAlphaByVolume, P_FLAG_NONE, FALSE, NULL); + load_builtin_param_bool("wave_brighten", (void*)&presetOutputs.bMaximizeWaveColor, P_FLAG_NONE, FALSE, "bMaximizeWaveColor"); + load_builtin_param_bool("wrap", (void*)&presetOutputs.bTexWrap, P_FLAG_NONE, FALSE, "bTexWrap"); + load_builtin_param_bool("darken_center", (void*)&presetOutputs.bDarkenCenter, P_FLAG_NONE, FALSE, "bDarkenCenter"); + load_builtin_param_bool("bRedBlueStereo", (void*)&presetOutputs.bRedBlueStereo, P_FLAG_NONE, FALSE, NULL); + load_builtin_param_bool("brighten", (void*)&presetOutputs.bBrighten, P_FLAG_NONE, FALSE, "bBrighten"); + load_builtin_param_bool("darken", (void*)&presetOutputs.bDarken, P_FLAG_NONE, FALSE, "bDarken"); + load_builtin_param_bool("solarize", (void*)&presetOutputs.bSolarize, P_FLAG_NONE, FALSE, "bSolarize"); + load_builtin_param_bool("invert", (void*)&presetOutputs.bInvert, P_FLAG_NONE, FALSE, "bInvert"); + load_builtin_param_bool("bMotionVectorsOn", (void*)&presetOutputs.bMotionVectorsOn, P_FLAG_NONE, FALSE, NULL); + load_builtin_param_bool("wave_dots", (void*)&presetOutputs.bWaveDots, P_FLAG_NONE, FALSE, "bWaveDots"); + load_builtin_param_bool("wave_thick", (void*)&presetOutputs.bWaveThick, P_FLAG_NONE, FALSE, "bWaveThick"); - load_builtin_param_float("zoom", (void*)&presetOutputs->zoom, presetOutputs->zoom_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("rot", (void*)&presetOutputs->rot, presetOutputs->rot_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, NULL); - load_builtin_param_float("zoomexp", (void*)&presetOutputs->zoomexp, presetOutputs->zoomexp_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fZoomExponent"); + load_builtin_param_float("zoom", (void*)&presetOutputs.zoom, presetOutputs.zoom_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("rot", (void*)&presetOutputs.rot, presetOutputs.rot_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, NULL); + load_builtin_param_float("zoomexp", (void*)&presetOutputs.zoomexp, presetOutputs.zoomexp_mesh, P_FLAG_PER_PIXEL |P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fZoomExponent"); - load_builtin_param_float("cx", (void*)&presetOutputs->cx, presetOutputs->cx_mesh, P_FLAG_PER_PIXEL | P_FLAG_DONT_FREE_MATRIX, 0.0, 1.0, 0, NULL); - load_builtin_param_float("cy", (void*)&presetOutputs->cy, presetOutputs->cy_mesh, P_FLAG_PER_PIXEL | P_FLAG_DONT_FREE_MATRIX, 0.0, 1.0, 0, NULL); - load_builtin_param_float("dx", (void*)&presetOutputs->dx, presetOutputs->dx_mesh, P_FLAG_PER_PIXEL | P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, NULL); - load_builtin_param_float("dy", (void*)&presetOutputs->dy, presetOutputs->dy_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, NULL); - load_builtin_param_float("sx", (void*)&presetOutputs->sx, presetOutputs->sx_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("sy", (void*)&presetOutputs->sy, presetOutputs->sy_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("cx", (void*)&presetOutputs.cx, presetOutputs.cx_mesh, P_FLAG_PER_PIXEL | P_FLAG_DONT_FREE_MATRIX, 0.0, 1.0, 0, NULL); + load_builtin_param_float("cy", (void*)&presetOutputs.cy, presetOutputs.cy_mesh, P_FLAG_PER_PIXEL | P_FLAG_DONT_FREE_MATRIX, 0.0, 1.0, 0, NULL); + load_builtin_param_float("dx", (void*)&presetOutputs.dx, presetOutputs.dx_mesh, P_FLAG_PER_PIXEL | P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, NULL); + load_builtin_param_float("dy", (void*)&presetOutputs.dy, presetOutputs.dy_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, MIN_DOUBLE_SIZE, NULL); + load_builtin_param_float("sx", (void*)&presetOutputs.sx, presetOutputs.sx_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("sy", (void*)&presetOutputs.sy, presetOutputs.sy_mesh, P_FLAG_PER_PIXEL |P_FLAG_DONT_FREE_MATRIX, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("wave_r", (void*)&presetOutputs->wave_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("wave_g", (void*)&presetOutputs->wave_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("wave_b", (void*)&presetOutputs->wave_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("wave_x", (void*)&presetOutputs->wave_x, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("wave_y", (void*)&presetOutputs->wave_y, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("wave_mystery", (void*)&presetOutputs->wave_mystery, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, "fWaveParam"); + load_builtin_param_float("wave_r", (void*)&presetOutputs.wave_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("wave_g", (void*)&presetOutputs.wave_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("wave_b", (void*)&presetOutputs.wave_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("wave_x", (void*)&presetOutputs.wave_x, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("wave_y", (void*)&presetOutputs.wave_y, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("wave_mystery", (void*)&presetOutputs.wave_mystery, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, "fWaveParam"); - load_builtin_param_float("ob_size", (void*)&presetOutputs->ob_size, NULL, P_FLAG_NONE, 0.0, 0.5, 0, NULL); - load_builtin_param_float("ob_r", (void*)&presetOutputs->ob_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ob_g", (void*)&presetOutputs->ob_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ob_b", (void*)&presetOutputs->ob_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ob_a", (void*)&presetOutputs->ob_a, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ob_size", (void*)&presetOutputs.ob_size, NULL, P_FLAG_NONE, 0.0, 0.5, 0, NULL); + load_builtin_param_float("ob_r", (void*)&presetOutputs.ob_r, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ob_g", (void*)&presetOutputs.ob_g, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ob_b", (void*)&presetOutputs.ob_b, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ob_a", (void*)&presetOutputs.ob_a, NULL, P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ib_size", (void*)&presetOutputs->ib_size, NULL,P_FLAG_NONE, 0.0, .5, 0.0, NULL); - load_builtin_param_float("ib_r", (void*)&presetOutputs->ib_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ib_g", (void*)&presetOutputs->ib_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ib_b", (void*)&presetOutputs->ib_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("ib_a", (void*)&presetOutputs->ib_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ib_size", (void*)&presetOutputs.ib_size, NULL,P_FLAG_NONE, 0.0, .5, 0.0, NULL); + load_builtin_param_float("ib_r", (void*)&presetOutputs.ib_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ib_g", (void*)&presetOutputs.ib_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ib_b", (void*)&presetOutputs.ib_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("ib_a", (void*)&presetOutputs.ib_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("mv_r", (void*)&presetOutputs->mv_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("mv_g", (void*)&presetOutputs->mv_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("mv_b", (void*)&presetOutputs->mv_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("mv_x", (void*)&presetOutputs->mv_x, NULL,P_FLAG_NONE, 0.0, 64.0, 0.0, "nMotionVectorsX"); - load_builtin_param_float("mv_y", (void*)&presetOutputs->mv_y, NULL,P_FLAG_NONE, 0.0, 48.0, 0.0, "nMotionVectorsY"); - load_builtin_param_float("mv_l", (void*)&presetOutputs->mv_l, NULL,P_FLAG_NONE, 0.0, 5.0, 0.0, NULL); - load_builtin_param_float("mv_dy", (void*)&presetOutputs->mv_dy, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - load_builtin_param_float("mv_dx", (void*)&presetOutputs->mv_dx, NULL,P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); - load_builtin_param_float("mv_a", (void*)&presetOutputs->mv_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("mv_r", (void*)&presetOutputs.mv_r, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("mv_g", (void*)&presetOutputs.mv_g, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("mv_b", (void*)&presetOutputs.mv_b, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); + load_builtin_param_float("mv_x", (void*)&presetOutputs.mv_x, NULL,P_FLAG_NONE, 0.0, 64.0, 0.0, "nMotionVectorsX"); + load_builtin_param_float("mv_y", (void*)&presetOutputs.mv_y, NULL,P_FLAG_NONE, 0.0, 48.0, 0.0, "nMotionVectorsY"); + load_builtin_param_float("mv_l", (void*)&presetOutputs.mv_l, NULL,P_FLAG_NONE, 0.0, 5.0, 0.0, NULL); + load_builtin_param_float("mv_dy", (void*)&presetOutputs.mv_dy, NULL, P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + load_builtin_param_float("mv_dx", (void*)&presetOutputs.mv_dx, NULL,P_FLAG_NONE, 0.0, 1.0, -1.0, NULL); + load_builtin_param_float("mv_a", (void*)&presetOutputs.mv_a, NULL,P_FLAG_NONE, 0.0, 1.0, 0.0, NULL); - load_builtin_param_float("time", (void*)&presetInputs->Time, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0.0, NULL); - load_builtin_param_float("bass", (void*)&presetInputs->bass, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0.0, NULL); - load_builtin_param_float("mid", (void*)&bpresetInputs->mid, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("bass_att", (void*)&presetInputs->bass_att, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("mid_att", (void*)&presetInputs->mid_att, NULL, P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_float("treb_att", (void*)&presetInputs->treb_att, NULL, P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); - load_builtin_param_int("frame", (void*)&presetInputs->frame, P_FLAG_READONLY, 0, MAX_INT_SIZE, 0, NULL); - load_builtin_param_float("progress", (void*)&presetInputs->progress, NULL,P_FLAG_READONLY, 0.0, 1, 0, NULL); - load_builtin_param_int("fps", (void*)&presetInputs->fps, P_FLAG_READONLY, 15, MAX_INT_SIZE, 0, NULL); + load_builtin_param_float("time", (void*)&presetInputs.time, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0.0, NULL); + load_builtin_param_float("bass", (void*)&presetInputs.bass, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0.0, NULL); + load_builtin_param_float("mid", (void*)&presetInputs.mid, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("bass_att", (void*)&presetInputs.bass_att, NULL,P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("mid_att", (void*)&presetInputs.mid_att, NULL, P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_float("treb_att", (void*)&presetInputs.treb_att, NULL, P_FLAG_READONLY, 0.0, MAX_DOUBLE_SIZE, 0, NULL); + load_builtin_param_int("frame", (void*)&presetInputs.frame, P_FLAG_READONLY, 0, MAX_INT_SIZE, 0, NULL); + load_builtin_param_float("progress", (void*)&presetInputs.progress, NULL,P_FLAG_READONLY, 0.0, 1, 0, NULL); + load_builtin_param_int("fps", (void*)&presetInputs.fps, P_FLAG_READONLY, 15, MAX_INT_SIZE, 0, NULL); - load_builtin_param_float("x", (void*)&presetInputs>x_per_pixel, presetInputs->x_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, + load_builtin_param_float("x", (void*)&presetInputs.x_per_pixel, presetInputs.x_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("y", (void*)&presetInputs->y_per_pixel, presetInputs->y_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX |P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, + load_builtin_param_float("y", (void*)&presetInputs.y_per_pixel, presetInputs.y_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX |P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("ang", (void*)&presetInputs->ang_per_pixel, presetInputs->theta_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, + load_builtin_param_float("ang", (void*)&presetInputs.ang_per_pixel, presetInputs.theta_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("rad", (void*)&presetInputs->rad_per_pixel, presetInputs->rad_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, + load_builtin_param_float("rad", (void*)&presetInputs.rad_per_pixel, presetInputs.rad_mesh, P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q1", (void*)&presetOutputs->q1, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q2", (void*)&presetOutputs->q2, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q3", (void*)&presetOutputs->q3, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q4", (void*)&presetOutputs->q4, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q5", (void*)&presetOutputs->q5, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q6", (void*)&presetOutputs->q6, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q7", (void*)&presetOutputs->q7, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); - load_builtin_param_float("q8", (void*)&presetOutputs->q8, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q1", (void*)&presetOutputs.q1, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q2", (void*)&presetOutputs.q2, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q3", (void*)&presetOutputs.q3, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q4", (void*)&presetOutputs.q4, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q5", (void*)&presetOutputs.q5, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q6", (void*)&presetOutputs.q6, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q7", (void*)&presetOutputs.q7, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); + load_builtin_param_float("q8", (void*)&presetOutputs.q8, NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, NULL); /* variables added in 1.04 */ - load_builtin_param_int("meshx", (void*)&presetInputs->gx, P_FLAG_READONLY, 32, 96, 8, NULL); - load_builtin_param_int("meshy", (void*)&presetInputs->gy, P_FLAG_READONLY, 24, 72, 6, NULL); + load_builtin_param_int("meshx", (void*)&presetInputs.gx, P_FLAG_READONLY, 32, 96, 8, NULL); + load_builtin_param_int("meshy", (void*)&presetInputs.gy, P_FLAG_READONLY, 24, 72, 6, NULL); return PROJECTM_SUCCESS; diff --git a/src/projectM-engine/BuiltinParams.hpp b/src/projectM-engine/BuiltinParams.hpp index 956a93bb5..60dc3ca54 100644 --- a/src/projectM-engine/BuiltinParams.hpp +++ b/src/projectM-engine/BuiltinParams.hpp @@ -27,20 +27,26 @@ #ifndef _BUILTIN_PARAMS_HPP #define _BUILTIN_PARAMS_HPP -#include "projectM.h" +#include "PresetFrameIO.hpp" +#include "Param.h" + class BuiltinParams { public: - /** Default constructor initalizes the entire builtin database */ + /** Default constructor leaves database in an uninitialized state. */ BuiltinParams(); + /** Construct a new builtin parameter database with variables references given by + * the preset input and output structures */ + BuiltinParams(const struct PresetInputs & presetInputs, struct PresetOutputs & presetOutputs); + ~BuiltinParams(); - /** Param database */ - int load_all_builtin_param(); - int init_builtin_param_db(); + /** Param database initalizer / destructor functions */ + int init_builtin_param_db(const PresetInputs & presetInputs, PresetOutputs & presetOutputs); + int load_all_builtin_param(const PresetInputs & presetInputs, PresetOutputs & presetOutputs); int destroy_builtin_param_db(); int insert_param_alt_name( Param *param, char *alt_name ); @@ -56,9 +62,10 @@ public: int init_val, char *alt_name ); int insert_builtin_param( Param *param ); + void traverse(void (*func_ptr)(void*)); private: - static const bool BUILTIN_PARAM_DEBUG = false; + static const bool BUILTIN_PARAMS_DEBUG = false; SplayTree *builtin_param_tree; }; -#endif \ No newline at end of file +#endif diff --git a/src/projectM-engine/CMakeLists.txt b/src/projectM-engine/CMakeLists.txt index 0e9d13a9e..882445260 100644 --- a/src/projectM-engine/CMakeLists.txt +++ b/src/projectM-engine/CMakeLists.txt @@ -1,12 +1,12 @@ PROJECT(projectM) -ADD_LIBRARY(projectM SHARED projectM.cpp projectM.h pbuffer.cpp pbuffer.h InitCond.cpp InitCond.h console_interface.cpp Expr.cpp PCM.cpp Parser.cpp Preset.cpp common.h BeatDetect.cpp PCM.h PerPixelEqn.cpp Eval.h SplayTree.cpp Param.cpp CustomWave.cpp CustomShape.h CustomShape.cpp Param.h CustomWave.h BeatDetect.h Preset.h menu.cpp console_interface.h Func.h Func.cpp Eval.cpp wipemalloc.h browser.cpp PerFrameEqn.cpp PerPointEqn.cpp editor.cpp fftsg.cpp glConsole.cpp CValue.h Expr.h timer.cpp wipemalloc.cpp PerFrameEqn.h PerPixelEqn.h PerPointEqn.h browser.h builtin_funcs.h compare.h editor.h event.h fatal.h SplayTree.h fftsg.h glConsole.h menu.h timer.h SplayNode.cpp SplayNode.h) +ADD_LIBRARY(projectM SHARED projectM.cpp projectM.h pbuffer.cpp pbuffer.h InitCond.cpp InitCond.h console_interface.cpp Expr.cpp PCM.cpp Parser.cpp Preset.cpp common.h BeatDetect.cpp PCM.h PerPixelEqn.cpp Eval.h SplayTree.cpp Param.cpp CustomWave.cpp CustomShape.h CustomShape.cpp Param.h CustomWave.h BeatDetect.h menu.cpp console_interface.h Func.h Func.cpp Eval.cpp wipemalloc.h browser.cpp PerFrameEqn.cpp PerPointEqn.cpp editor.cpp fftsg.cpp glConsole.cpp CValue.h Expr.h timer.cpp wipemalloc.cpp PerFrameEqn.h PerPixelEqn.h PerPointEqn.h browser.h BuiltinFuncs.hpp BuiltinFuncs.cpp compare.h editor.h event.h fatal.h SplayTree.h fftsg.h glConsole.h menu.h timer.h SplayNode.cpp SplayNode.h BuiltinParams.hpp BuiltinParams.cpp Preset.hpp PresetSwitcher.hpp PresetSwitcher.cpp) OPTION(USE_FTGL "Use FTGL for on-screen fonts" ON) ADD_DEFINITIONS(-DLINUX -DFBO) FIND_PACKAGE(OpenGL) - + INCLUDE(FindPkgConfig.cmake) IF(USE_FTGL) @@ -19,7 +19,7 @@ ENDIF(USE_FTGL) TARGET_LINK_LIBRARIES(projectM GLEW m) INSTALL(TARGETS projectM DESTINATION lib) -INSTALL(FILES projectM.h pbuffer.h PCM.h BeatDetect.h Preset.h event.h console_interface.h dlldefs.h fatal.h PCM.h DESTINATION include/libprojectM) +INSTALL(FILES projectM.h pbuffer.h PCM.h BeatDetect.h Preset.hpp event.h console_interface.h dlldefs.h fatal.h PCM.h DESTINATION include/libprojectM) INSTALL(FILES config DESTINATION share/projectM) FILE(GLOB presets "presets/*.milk") INSTALL(FILES ${presets} DESTINATION share/projectM/presets) diff --git a/src/projectM-engine/CustomShape.cpp b/src/projectM-engine/CustomShape.cpp index ce44dd64a..1731bf142 100755 --- a/src/projectM-engine/CustomShape.cpp +++ b/src/projectM-engine/CustomShape.cpp @@ -32,7 +32,7 @@ #include "InitCond.h" #include "Param.h" #include "PerFrameEqn.h" -#include "Preset.h" +#include "Preset.hpp" #include "SplayTree.h" #include "wipemalloc.h" @@ -298,8 +298,55 @@ void CustomShape::eval_custom_shape_init_conds() { } void CustomShape::load_unspecified_init_conds_shape() { - interface_shape = this; + param_tree->splay_traverse((void (*)(void*))load_unspec_init_cond_shape_helper); interface_shape = NULL; } +void CustomShape::load_unspec_init_cond_shape() { +abort(); +#if 0 + InitCond * init_cond; + CValue init_val; + + /* Don't count read only parameters as initial conditions */ + if (flags & P_FLAG_READONLY) + return; + if (flags & P_FLAG_QVAR) + return; + if (flags & P_FLAG_TVAR) + return; + if (flags & P_FLAG_USERDEF) + return; + + /* If initial condition was not defined by the preset file, force a default one + with the following code */ + if ((init_cond =(InitCond*)CustomShape::interface_shape->init_cond_tree->splay_find(name)) == NULL) { + + /* Make sure initial condition does not exist in the set of per frame initial equations */ + if ((init_cond = (InitCond*)CustomShape::interface_shape->per_frame_init_eqn_tree->splay_find(name)) != NULL) + return; + + if (type == P_TYPE_BOOL) + init_val.bool_val = 0; + + else if (type == P_TYPE_INT) + init_val.int_val = *(int*)engine_val; + + else if (type == P_TYPE_DOUBLE) + init_val.float_val = *(float*)engine_val; + + //printf("%s\n", param->name); + /* Create new initial condition */ + if ((init_cond = new InitCond(this, init_val)) == NULL) + return; + + /* Insert the initial condition into this presets tree */ + if (CustomShape::interface_shape->init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { + delete init_cond; + return; + } + + } +#endif +} diff --git a/src/projectM-engine/CustomShape.h b/src/projectM-engine/CustomShape.h index 367cefc4d..73cebfe05 100755 --- a/src/projectM-engine/CustomShape.h +++ b/src/projectM-engine/CustomShape.h @@ -111,6 +111,7 @@ public: void load_custom_shape_init(); void load_unspecified_init_conds_shape(); void eval_custom_shape_init_conds(); + void load_unspec_init_cond_shape(); }; /** Splaytree traversal helpers */ diff --git a/src/projectM-engine/CustomWave.cpp b/src/projectM-engine/CustomWave.cpp index e32ce1e8f..692280e79 100755 --- a/src/projectM-engine/CustomWave.cpp +++ b/src/projectM-engine/CustomWave.cpp @@ -35,14 +35,14 @@ #include "Param.h" #include "PerFrameEqn.h" #include "PerPointEqn.h" -#include "Preset.h" +#include "Preset.hpp" #include "SplayTree.h" #include "wipemalloc.h" #define MAX_SAMPLE_SIZE 4096 -CustomWave *CustomWave::interface_wave = NULL; + int interface_id = 0; CustomWave * CustomWave::new_custom_wave(int id) { @@ -553,10 +553,10 @@ CustomWave * CustomWave::find_custom_wave(int id, Preset * preset, int create_fl return custom_wave; } -void CustomWave::eval_custom_wave_init_conds() { - init_cond_tree->splay_traverse((void (*)(void*))eval_init_cond_helper ); - per_frame_init_eqn_tree->splay_traverse((void (*)(void*))eval_init_cond_helper ); -} +void CustomWave::eval_custom_wave_init_conds() { + init_cond_tree->splay_traverse((void (*)(void*))eval_init_cond_helper ); + per_frame_init_eqn_tree->splay_traverse((void (*)(void*))eval_init_cond_helper ); +} /** Evaluate per-point equations */ void CustomWave::evalPerPointEqns() { @@ -577,18 +577,66 @@ void CustomWave::evalPerPointEqns() { y_mesh[x] = y; - /* Evaluate per pixel equations */ - interface_wave = this; - per_point_eqn_tree->splay_traverse((void (*)(void*))eval_per_point_eqn_helper); - interface_wave = NULL; + /* Evaluate per pixel equations */ + abort(); + per_point_eqn_tree->splay_traverse((void (*)(void*))eval_per_point_eqn_helper); + /* Reset index */ projectM::currentEngine->mesh_i = -1; } void CustomWave::load_unspecified_init_conds_wave() { - interface_wave = this; - param_tree->splay_traverse((void (*)(void*))load_unspec_init_cond_helper); - interface_wave = NULL; +// interface_wave = this; + param_tree->splay_traverse((void (*)(void*))load_unspec_init_cond_helper); +// interface_wave = NULL; } + +void CustomWave::load_unspec_init_cond() { +abort(); +#if 0 + InitCond * init_cond; + CValue init_val; + + /* Don't count these parameters as initial conditions */ + if (flags & P_FLAG_READONLY) + return; + if (flags & P_FLAG_QVAR) + return; + if (flags & P_FLAG_TVAR) + return; + if (flags & P_FLAG_USERDEF) + return; + + /* If initial condition was not defined by the preset file, force a default one + with the following code */ + if ((init_cond = (InitCond*)init_cond_tree->splay_find(name)) == NULL) { + + /* Make sure initial condition does not exist in the set of per frame initial equations */ + if ((init_cond = (InitCond*)per_frame_init_eqn_tree->splay_find(name)) != NULL) + return; + + if (type == P_TYPE_BOOL) + init_val.bool_val = 0; + + else if (type == P_TYPE_INT) + init_val.int_val = *(int*)engine_val; + + else if (type == P_TYPE_DOUBLE) + init_val.float_val = *(float*)engine_val; + + //printf("%s\n", param->name); + /* Create new initial condition */ + if ((init_cond = new InitCond(this, init_val)) == NULL) + return; + + /* Insert the initial condition into this presets tree */ + if (init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { + delete init_cond; + return; + } + + } +#endif +} diff --git a/src/projectM-engine/CustomWave.h b/src/projectM-engine/CustomWave.h index 37e04b447..f10eae9ef 100755 --- a/src/projectM-engine/CustomWave.h +++ b/src/projectM-engine/CustomWave.h @@ -45,6 +45,7 @@ class PerPointEqn; class Preset; #include "common.h" +#include "Param.h" class SplayTree; @@ -53,9 +54,6 @@ public: /* Numerical id */ int id; int per_frame_count; - - /** Current wave being processed */ - static CustomWave *interface_wave; /* Parameter tree associated with this custom wave */ SplayTree * param_tree; @@ -130,7 +128,7 @@ public: void evalPerPointEqns(); CustomWave *nextCustomWave( Preset *preset); void load_unspecified_init_conds_wave(); - + void load_unspec_init_cond() ; void eval_custom_wave_init_conds(); void load_unspec_init_cond(Param * param); void destroy_per_point_eqn_tree(SplayTree * tree); diff --git a/src/projectM-engine/Eval.cpp b/src/projectM-engine/Eval.cpp index 7698d700f..b64ab5eb5 100755 --- a/src/projectM-engine/Eval.cpp +++ b/src/projectM-engine/Eval.cpp @@ -31,7 +31,7 @@ #include "Expr.h" #include "Param.h" #include "Func.h" -#include "builtin_funcs.h" +#include "BuiltinFuncs.hpp" #include "wipemalloc.h" InfixOp *Eval::infix_add = NULL; diff --git a/src/projectM-engine/Expr.h b/src/projectM-engine/Expr.h index aa8633304..e3c687032 100755 --- a/src/projectM-engine/Expr.h +++ b/src/projectM-engine/Expr.h @@ -54,7 +54,7 @@ public: float constant; /* static variable */ Param *param; /* pointer to a changing variable */ - Term() { this->constant = 0; this->param = NULL; } + Term() { this->constant = 0; this->param = 0; } }; /* General Expression Type */ diff --git a/src/projectM-engine/Func.cpp b/src/projectM-engine/Func.cpp index 9ae0c8a2f..a8f3b23d6 100755 --- a/src/projectM-engine/Func.cpp +++ b/src/projectM-engine/Func.cpp @@ -24,7 +24,6 @@ #include #include -#include "builtin_funcs.h" #include "common.h" #include "fatal.h" @@ -32,11 +31,12 @@ #include "SplayTree.h" #include "wipemalloc.h" - -SplayTree *Func::builtin_func_tree = NULL; + + + /* Private function prototypes */ -void *copy_func_key(char * string) { +void *Func::copy_func_key(char * string) { char * clone_string; @@ -49,7 +49,7 @@ void *copy_func_key(char * string) { } /* Compare string name with function name */ -int compare_func(char * name, char * name2) { +int Func::compare_func(char * name, char * name2) { int cmpval; diff --git a/src/projectM-engine/Func.h b/src/projectM-engine/Func.h index 2fb74b8c2..4de82e89d 100755 --- a/src/projectM-engine/Func.h +++ b/src/projectM-engine/Func.h @@ -40,16 +40,19 @@ public: char name[MAX_TOKEN_SIZE]; float (*func_ptr)(float*); int num_args; - static SplayTree *builtin_func_tree; + + Func() {} /* Public Prototypes */ DLLEXPORT ~Func(); static Func *create_func ( char *name, float (*func_ptr)(float*), int num_args ); + static void * copy_func_key(char * string); + int compare_func(char * name, char * name2); }; /** Splay traversal */ inline void free_func_helper( void *func ) { delete (Func *)func; - } - +} + #endif /** !_FUNC_H */ diff --git a/src/projectM-engine/Param.cpp b/src/projectM-engine/Param.cpp index 960194f7d..fa99eb01e 100755 --- a/src/projectM-engine/Param.cpp +++ b/src/projectM-engine/Param.cpp @@ -35,7 +35,7 @@ #include "Expr.h" #include "InitCond.h" #include "Param.h" -#include "Preset.h" +#include "Preset.hpp" #include "SplayTree.h" #include "wipemalloc.h" @@ -56,8 +56,8 @@ Param::Param( char * name, short int type, short int flags, void * engine_val, v strncpy(this->name, name, MAX_TOKEN_SIZE-1); /** @@FIX THIS */ - this->gx = projectM::currentEngine->gx; - this->gy = projectM::currentEngine->gy; + //this->gx = projectM::currentEngine->gx; + //this->gy = projectM::currentEngine->gy; } @@ -82,8 +82,8 @@ Param::Param(char * name) : /** @@FIX THIS */ - this->gx = projectM::currentEngine->gx; - this->gy = projectM::currentEngine->gy; + //this->gx = projectM::currentEngine->gx; + //this->gy = projectM::currentEngine->gy; } /* Free's a parameter type */ @@ -91,7 +91,7 @@ Param::~Param() { int x; if (flags & P_FLAG_USERDEF) { - delete(engine_val); + free(engine_val); } //if (!(param->flags & P_FLAG_DONT_FREE_MATRIX)) { @@ -191,53 +191,6 @@ void Param::set_param( float val) { return; } -/* Find a parameter given its name, will create one if not found */ -Param * Param::find_param(char * name, Preset * preset, int flags) { - - Param * param = NULL; - - /* Null argument checks */ - if (name == NULL) - return NULL; - if (preset == NULL) - return NULL; - - /* First look in the builtin database */ - param = (Param *)projectM::currentEngine->builtin_param_tree->splay_find(name); - - /* If the search failed, check the user database */ - if (param == NULL) { - param = (Param*)preset->user_param_tree->splay_find(name); - } - /* If it doesn't exist in the user (or builtin) database and - create_flag is set, then make it and insert into the database - */ - - if ((param == NULL) && (flags & P_CREATE)) { - - /* Check if string is valid */ - if (!is_valid_param_string(name)) { - if (PARAM_DEBUG) printf("find_param: invalid parameter name:\"%s\"\n", name); - return NULL; - } - /* Now, create the user defined parameter given the passed name */ - if ((param = new Param(name)) == NULL) { - if (PARAM_DEBUG) printf("find_param: failed to create a new user parameter!\n"); - return NULL; - } - /* Finally, insert the new parameter into this preset's proper splaytree */ - if (preset->user_param_tree->splay_insert(param, param->name) < 0) { - if (PARAM_DEBUG) printf("PARAM \"%s\" already exists in user parameter tree!\n", param->name); - delete param; - return NULL; - } - - } - - /* Return the found (or created) parameter. Note that if P_CREATE is not set, this could be null */ - return param; - -} /* Loads a float parameter into the builtin database */ Param * Param::new_param_float(char * name, short int flags, void * engine_val, void * matrix, @@ -296,9 +249,15 @@ Param * Param::new_param_bool(char * name, short int flags, void * engine_val, /* Finished, return success */ return param; } + + +/// @bug this is fucked void Param::load_init_cond() { + // bullshit + int type; + void *engine_val; InitCond * init_cond; CValue init_val; @@ -308,10 +267,12 @@ void Param::load_init_cond() { /* If initial condition was not defined by the preset file, force a default one with the following code */ - if ((init_cond = (InitCond*)(Preset::active_preset->init_cond_tree->splay_find(name))) == NULL) { +abort(); + +// if ((init_cond = (InitCond*)(init_cond_tree->splay_find(name))) == NULL) { /* Make sure initial condition does not exist in the set of per frame initial equations */ - if ((init_cond = (InitCond*)(Preset::active_preset->per_frame_init_eqn_tree->splay_find(name))) != NULL) +// if ((init_cond = (InitCond*)(per_frame_init_eqn_tree->splay_find(name))) != NULL) return; if (type == P_TYPE_BOOL) @@ -328,105 +289,11 @@ void Param::load_init_cond() { return; /* Insert the initial condition into this presets tree */ - if (Preset::active_preset->init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { +// if (this->init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { delete init_cond; return; - } + // } - } - -} - -void Param::load_unspec_init_cond() { - - InitCond * init_cond; - CValue init_val; - - /* Don't count these parameters as initial conditions */ - if (flags & P_FLAG_READONLY) - return; - if (flags & P_FLAG_QVAR) - return; - if (flags & P_FLAG_TVAR) - return; - if (flags & P_FLAG_USERDEF) - return; - - /* If initial condition was not defined by the preset file, force a default one - with the following code */ - if ((init_cond = (InitCond*)CustomWave::interface_wave->init_cond_tree->splay_find(name)) == NULL) { - - /* Make sure initial condition does not exist in the set of per frame initial equations */ - if ((init_cond = (InitCond*)CustomWave::interface_wave->per_frame_init_eqn_tree->splay_find(name)) != NULL) - return; - - if (type == P_TYPE_BOOL) - init_val.bool_val = 0; - - else if (type == P_TYPE_INT) - init_val.int_val = *(int*)engine_val; - - else if (type == P_TYPE_DOUBLE) - init_val.float_val = *(float*)engine_val; - - //printf("%s\n", param->name); - /* Create new initial condition */ - if ((init_cond = new InitCond(this, init_val)) == NULL) - return; - - /* Insert the initial condition into this presets tree */ - if (CustomWave::interface_wave->init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { - delete init_cond; - return; - } - - } - -} - -void Param::load_unspec_init_cond_shape() { - - InitCond * init_cond; - CValue init_val; - - /* Don't count read only parameters as initial conditions */ - if (flags & P_FLAG_READONLY) - return; - if (flags & P_FLAG_QVAR) - return; - if (flags & P_FLAG_TVAR) - return; - if (flags & P_FLAG_USERDEF) - return; - - /* If initial condition was not defined by the preset file, force a default one - with the following code */ - if ((init_cond =(InitCond*)CustomShape::interface_shape->init_cond_tree->splay_find(name)) == NULL) { - - /* Make sure initial condition does not exist in the set of per frame initial equations */ - if ((init_cond = (InitCond*)CustomShape::interface_shape->per_frame_init_eqn_tree->splay_find(name)) != NULL) - return; - - if (type == P_TYPE_BOOL) - init_val.bool_val = 0; - - else if (type == P_TYPE_INT) - init_val.int_val = *(int*)engine_val; - - else if (type == P_TYPE_DOUBLE) - init_val.float_val = *(float*)engine_val; - - //printf("%s\n", param->name); - /* Create new initial condition */ - if ((init_cond = new InitCond(this, init_val)) == NULL) - return; - - /* Insert the initial condition into this presets tree */ - if (CustomShape::interface_shape->init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { - delete init_cond; - return; - } - - } +// } } diff --git a/src/projectM-engine/Parser.cpp b/src/projectM-engine/Parser.cpp index 9f778be22..1985ba35f 100755 --- a/src/projectM-engine/Parser.cpp +++ b/src/projectM-engine/Parser.cpp @@ -27,7 +27,7 @@ #include "common.h" #include "fatal.h" -#include "builtin_funcs.h" +#include "BuiltinFuncs.hpp" #include "CustomWave.h" #include "CustomShape.h" #include "Expr.h" @@ -35,7 +35,7 @@ #include "Func.h" #include "InitCond.h" #include "Param.h" -#include "Preset.h" +#include "Preset.hpp" #include "Parser.h" #include "PerFrameEqn.h" #include "PerPixelEqn.h" @@ -260,9 +260,9 @@ if (init_string != 0) { /* Add the per pixel equation */ if (preset->add_per_pixel_eqn(string, gen_expr) < 0) { - if (PARSE_DEBUG) { - DWRITE( "parse_per_pixel: no param associated with \"%s\" (LINE %d)", string, line_count); - + if (PARSE_DEBUG) { + DWRITE( "parse_per_pixel: no param associated with \"%s\" (LINE %d)", string, line_count); + } delete gen_expr; return PROJECTM_PARSE_ERROR; @@ -602,18 +602,18 @@ GenExpr * Parser::parse_gen_expr ( FILE * fs, TreeExpr * tree_expr, Preset * pre case tLPr: /* CASE 1 (Left Parentice): See if the previous string before this parentice is a function name */ - if ((func = projectM::currentEngine->find_func(string)) != NULL) { - if (PARSE_DEBUG) { - DWRITE( "parse_gen_expr: found prefix function (name = %s) (LINE %d)\n", func->name, line_count); - + if ((func = BuiltinFuncs::find_func(string)) != NULL) { + if (PARSE_DEBUG) { + DWRITE( "parse_gen_expr: found prefix function (name = %s) (LINE %d)\n", func->name, line_count); + } /* Parse the functions arguments */ if ((expr_list = parse_prefix_args(fs, func->num_args, preset)) == NULL) { - if (PARSE_DEBUG) { - DWRITE( "parse_prefix_args: failed to generate an expresion list! (LINE %d) \n", line_count); - - } + if (PARSE_DEBUG) { + DWRITE( "parse_prefix_args: failed to generate an expresion list! (LINE %d) \n", line_count); + + } if ( tree_expr != NULL ) { delete tree_expr; } @@ -707,9 +707,9 @@ GenExpr * Parser::parse_gen_expr ( FILE * fs, TreeExpr * tree_expr, Preset * pre /* CASE 0: Empty string, parse error */ if (*string == 0) { - if (PARSE_DEBUG) { - DWRITE( "parse_gen_expr: empty string coupled with infix op (ERROR!) (LINE %d) \n", line_count); - + if (PARSE_DEBUG) { + DWRITE( "parse_gen_expr: empty string coupled with infix op (ERROR!) (LINE %d) \n", line_count); + } delete tree_expr; return NULL; @@ -721,17 +721,17 @@ GenExpr * Parser::parse_gen_expr ( FILE * fs, TreeExpr * tree_expr, Preset * pre delete tree_expr; return NULL; } - + /* Parse the rest of the line */ - return parse_infix_op(fs, token, insert_gen_expr(gen_expr, &tree_expr), preset); - + return parse_infix_op(fs, token, insert_gen_expr(gen_expr, &tree_expr), preset); + } - + /* CASE 4: custom shape variable */ if (current_shape != NULL) { if ((param = current_shape->param_tree->find_param_db(string, FALSE)) == NULL) { - if ((param = projectM::currentEngine->find_builtin_param(string)) == NULL) + if ((param = preset->builtinParams.find_builtin_param(string)) == NULL) if ((param = current_shape->param_tree->find_param_db(string, TRUE)) == NULL) { delete tree_expr; return NULL; @@ -758,7 +758,7 @@ GenExpr * Parser::parse_gen_expr ( FILE * fs, TreeExpr * tree_expr, Preset * pre /* CASE 5: custom wave variable */ if (current_wave != NULL) { if ((param = current_wave->param_tree->find_param_db(string, FALSE)) == NULL) { - if ((param = projectM::currentEngine->find_builtin_param(string)) == NULL) + if ((param = preset->builtinParams.find_builtin_param(string)) == NULL) if ((param = current_wave->param_tree->find_param_db(string, TRUE)) == NULL) { delete tree_expr; return NULL; @@ -792,7 +792,7 @@ GenExpr * Parser::parse_gen_expr ( FILE * fs, TreeExpr * tree_expr, Preset * pre } - /* Convert parameter to an expression */ + /* Convert parameter to an expression */ if ((gen_expr = GenExpr::param_to_expr(param)) == NULL) { delete tree_expr; return NULL; @@ -806,9 +806,9 @@ GenExpr * Parser::parse_gen_expr ( FILE * fs, TreeExpr * tree_expr, Preset * pre } /* CASE 7: Bad string, give up */ - if (PARSE_DEBUG) { - DWRITE( "parse_gen_expr: syntax error [string = \"%s\"] (LINE %d)\n", string, line_count); - + if (PARSE_DEBUG) { + DWRITE( "parse_gen_expr: syntax error [string = \"%s\"] (LINE %d)\n", string, line_count); + } delete tree_expr; return NULL; diff --git a/src/projectM-engine/PerPointEqn.cpp b/src/projectM-engine/PerPointEqn.cpp index b4631f08f..3868a4212 100755 --- a/src/projectM-engine/PerPointEqn.cpp +++ b/src/projectM-engine/PerPointEqn.cpp @@ -44,8 +44,8 @@ void PerPointEqn::evalPerPointEqn() { int samples, size; float * param_matrix; GenExpr * eqn_ptr; - - samples = CustomWave::interface_wave->samples; +abort(); +// samples = CustomWave::interface_wave->samples; eqn_ptr = gen_expr; if (param->matrix == NULL) { diff --git a/src/projectM-engine/Preset.cpp b/src/projectM-engine/Preset.cpp index b9d7e3136..d2a864bb8 100755 --- a/src/projectM-engine/Preset.cpp +++ b/src/projectM-engine/Preset.cpp @@ -30,17 +30,16 @@ #include #include "Preset.hpp" - - +#include "Parser.h" Preset::Preset() {} -Preset::Preset(const std::string & filename) { +Preset::Preset(const PresetInputs * presetInputs, PresetOutputs * presetOutputs, const std::string & filename): + builtinParams(*presetInputs, *presetOutputs) +{ -int ret; +initialize(filename); -if ((ret = load_preset_file(filename.c_str())) != PROJECTM_SUCCESS) - throw ret; } @@ -52,25 +51,25 @@ Preset::~Preset() { init_cond_tree->splay_traverse((void (*)(void*))free_init_cond_helper); delete init_cond_tree; - + per_frame_init_eqn_tree->splay_traverse((void (*)(void*))free_init_cond_helper); delete per_frame_init_eqn_tree; - + per_pixel_eqn_tree->splay_traverse((void (*)(void*))free_per_pixel_eqn_helper); delete per_pixel_eqn_tree; - + per_frame_eqn_tree->splay_traverse((void (*)(void*))free_per_frame_eqn_helper); delete per_frame_eqn_tree; - + user_param_tree->splay_traverse((void (*)(void*))free_param_helper); delete user_param_tree; - + custom_wave_tree->splay_traverse((void (*)(void*))free_custom_wave_helper); delete custom_wave_tree; custom_shape_tree->splay_traverse((void (*)(void*))free_custom_shape_helper); delete custom_shape_tree; - + #if defined(PRESET_DEBUG) && defined(DEBUG) DWRITE( "~Preset(): out\n" ); #endif @@ -200,7 +199,7 @@ printf( "reloadPerFrame()\n" ); } -void Preset::initalize() { +void Preset::initialize(const std::string & pathname) { /* Initialize equation trees */ init_cond_tree = SplayTree::create_splaytree((int (*)(void*,void*))compare_string, (void* (*)(void*))copy_string, (void (*)(void*))free_string); @@ -222,13 +221,14 @@ void Preset::initalize() { memset(this->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE); memset(this->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE); memset(this->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE); - - if (Preset::currentEngine->load_preset_file(pathname, preset) < 0) { + int retval; + if ((retval = load_preset_file(pathname.c_str())) < 0) { #ifdef PRESET_DEBUG if (PRESET_DEBUG) printf("load_preset: failed to load file \"%s\"\n", pathname); #endif - this->close_preset(); - return NULL; + //this->close_preset(); + /// @bug how should we handle this problem? a well define exception? + throw retval; } /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */ @@ -406,7 +406,8 @@ void Preset::load_custom_wave_init_conditions() { } void Preset::load_custom_shape_init_conditions() { - custom_shape_tree->splay_traverse((void (*)(void*))load_custom_shape_init_helper); + abort(); + //custom_shape_tree->splay_traverse((void (*)(void*))load_custom_shape_init_helper); } /** Returns the next custom waveform in the wave database */ @@ -449,12 +450,13 @@ CustomShape * Preset::nextCustomShape() { /** Evaluates all per-pixel equations */ void Preset::evalPerPixelEqns() { + /* Evaluate all per pixel equations using splay traversal */ per_pixel_eqn_tree->splay_traverse((void (*)(void*))eval_per_pixel_eqn_helper); /* Set mesh i / j values to -1 so engine vars are used by default again */ - Preset::currentEngine->mesh_i = -1; - Preset::currentEngine->mesh_j = -1; + this->mesh_i = -1; + this->mesh_j = -1; } /** Is the opcode a per-pixel equation? */ @@ -472,7 +474,7 @@ int Preset::resetPerPixelEqnFlags() { } return PROJECTM_SUCCESS; - } +} /* Adds a per pixel equation according to its string name. This will be used only by the parser */ @@ -564,7 +566,7 @@ InitCond * Preset::get_init_cond( Param *param ) { if (param->type == P_TYPE_BOOL) init_val.bool_val = 0; - + else if (param->type == P_TYPE_INT) init_val.int_val = *(int*)param->engine_val; @@ -574,7 +576,7 @@ InitCond * Preset::get_init_cond( Param *param ) { /* Create new initial condition */ if ((init_cond = new InitCond(param, init_val)) == NULL) return NULL; - + /* Insert the initial condition into this presets tree */ if (init_cond_tree->splay_insert(init_cond, init_cond->param->name) < 0) { delete init_cond; @@ -592,19 +594,17 @@ int Preset::load_preset_file(const char * pathname) { FILE * fs; int retval; - int lineno; - line_mode_t line_mode; + int lineno; + line_mode_t line_mode; if (pathname == NULL) return PROJECTM_FAILURE; - if (preset == NULL) - return PROJECTM_FAILURE; /* Open the file corresponding to pathname */ if ((fs = fopen(pathname, "rb")) == 0) { #if defined(PRESET_DEBUG) && defined(DEBUG) DWRITE( "load_preset_file: loading of file %s failed!\n", pathname); -#endif +#endif return PROJECTM_ERROR; } @@ -620,15 +620,18 @@ int Preset::load_preset_file(const char * pathname) { fclose(fs); return PROJECTM_FAILURE; } - + /* Parse the preset name and a left bracket */ - if (Parser::parse_preset_name(fs, this->name) < 0) { + char tmp_name[MAX_TOKEN_SIZE]; + + if (Parser::parse_preset_name(fs, tmp_name) < 0) { #if defined(PRESET_DEBUG) && defined(DEBUG) DWRITE( "load_preset_file: loading of preset name in file \"%s\" failed\n", pathname); #endif fclose(fs); return PROJECTM_ERROR; } + name = std::string(tmp_name); #if defined(PRESET_DEBUG) && defined(DEBUG) DWRITE( "load_preset_file: preset \"%s\" parsed\n", this->name); @@ -664,25 +667,56 @@ int Preset::load_preset_file(const char * pathname) { return PROJECTM_SUCCESS; } -/* Returns nonzero if string 'name' contains .milk or - (the better) .prjm extension. Not a very strong function currently */ -int Preset::is_valid_extension(const struct dirent* ent) { - const char* ext = 0; - - if (!ent) return FALSE; - - ext = strrchr(ent->d_name, '.'); - if (!ext) ext = ent->d_name; - - if (0 == strcasecmp(ext, MILKDROP_FILE_EXTENSION)) return TRUE; - if (0 == strcasecmp(ext, PROJECTM_FILE_EXTENSION)) return TRUE; - - return FALSE; -} - - void Preset::load_init_conditions() { - builtin_param_tree->splay_traverse( (void (*)(void*))load_init_cond_helper); + builtinParams.traverse(load_init_cond_helper); + } + +/* Find a parameter given its name, will create one if not found */ +Param * Preset::find_param(char * name, int flags) { + + Param * param = NULL; + + /* Null argument checks */ + if (name == NULL) + return NULL; + + /* First look in the builtin database */ + param = (Param *)this->builtinParams.find_builtin_param(name); + + /* If the search failed, check the user database */ + if (param == NULL) { + param = (Param*)this->user_param_tree->splay_find(name); + } + /* If it doesn't exist in the user (or builtin) database and + create_flag is set, then make it and insert into the database + */ + + if ((param == NULL) && (flags & P_CREATE)) { + + /* Check if string is valid */ + if (!Param::is_valid_param_string(name)) { + if (PARAM_DEBUG) printf("find_param: invalid parameter name:\"%s\"\n", name); + return NULL; + } + /* Now, create the user defined parameter given the passed name */ + if ((param = new Param(name)) == NULL) { + if (PARAM_DEBUG) printf("find_param: failed to create a new user parameter!\n"); + return NULL; + } + /* Finally, insert the new parameter into this preset's proper splaytree */ + if (this->user_param_tree->splay_insert(param, param->name) < 0) { + if (PARAM_DEBUG) printf("PARAM \"%s\" already exists in user parameter tree!\n", param->name); + delete param; + return NULL; + } + + } + + /* Return the found (or created) parameter. Note that if P_CREATE is not set, this could be null */ + return param; + +} + diff --git a/src/projectM-engine/Preset.hpp b/src/projectM-engine/Preset.hpp index 52ca7dde6..0ee58413f 100644 --- a/src/projectM-engine/Preset.hpp +++ b/src/projectM-engine/Preset.hpp @@ -40,130 +40,14 @@ #include "Expr.h" #include "PerPixelEqn.h" #include "PerFrameEqn.h" +#include "BuiltinParams.hpp" +#include "PresetFrameIO.hpp" +#include "SplayTree.h" +#include "InitCond.h" class CustomWave; class InitCond; -class SplayTree; - - -/** Container for all engine variables. It's a struct - * so that it's light weight. Access is done directly on - * members for Mr. Sperl's convenience */ -struct EngineVars { - - /// @bug should this exist / be here? - int mesh_i, mesh_j; - - /* PER FRAME CONSTANTS BEGIN */ - float zoom; - float zoomexp; - float rot; - float warp; - - float sx; - float sy; - float dx; - float dy; - float cx; - float cy; - - float decay; - - float wave_r; - float wave_g; - float wave_b; - float wave_o; - float wave_x; - float wave_y; - float wave_mystery; - - float ob_size; - float ob_r; - float ob_g; - float ob_b; - float ob_a; - - float ib_size; - float ib_r; - float ib_g; - float ib_b; - float ib_a; - - float mv_a ; - float mv_r ; - float mv_g ; - float mv_b ; - float mv_l; - float mv_x; - float mv_y; - float mv_dy; - float mv_dx; - - /* PER_FRAME CONSTANTS END */ - - float fRating; - float fGammaAdj; - float fVideoEchoZoom; - float fVideoEchoAlpha; - - int nVideoEchoOrientation; - int nWaveMode; - int bAdditiveWaves; - int bWaveDots; - int bWaveThick; - int bModWaveAlphaByVolume; - int bMaximizeWaveColor; - int bTexWrap; - int bDarkenCenter; - int bRedBlueStereo; - int bBrighten; - int bDarken; - int bSolarize; - int bInvert; - int bMotionVectorsOn; - - - float fWaveAlpha ; - float fWaveScale; - float fWaveSmoothing; - float fWaveParam; - float fModWaveAlphaStart; - float fModWaveAlphaEnd; - float fWarpAnimSpeed; - float fWarpScale; - float fShader; - - /* Q VARIABLES START */ - - float q1; - float q2; - float q3; - float q4; - float q5; - float q6; - float q7; - float q8; - - - /* Q VARIABLES END */ - - float **zoom_mesh; - float **zoomexp_mesh; - float **rot_mesh; - - float **sx_mesh; - float **sy_mesh; - float **dx_mesh; - float **dy_mesh; - float **cx_mesh; - float **cy_mesh; - - float **x_mesh; - float **y_mesh; - float **rad_mesh; - float **theta_mesh; - -}; +//class SplayTree; class Preset { @@ -173,27 +57,32 @@ protected: /// allocate separately) /// Benefits: lighter weight presets, but "heavier" ones are still supported too /// Negatives: heap is slower, extra pointer dereference - EngineVars engineVars; + //PresetOutputs * presetOutputs; + //PresetOutputs * presetOutputs; /* preset name as parsed in file */ public: - /** Default constructor is *not* a properly initalized preset **/ Preset(); - /** Load a preset by filename. Most common way to allocate new preset */ - Preset(const std::string & filename); + + + /** Load a preset by filename with input and output buffers specified. + * Most common way to allocate new preset */ + Preset(const PresetInputs * presetInputs, PresetOutputs * presetOutputs, const std::string & filename); ~Preset(); + BuiltinParams builtinParams; + std::string name; std::string file_path; + int mesh_i,mesh_j; /** IDs of current waves/shapes */ - int interface_id, - cwave_interface_id; - CustomWave *active_wave; - CustomShape *active_shape; + int interface_id, cwave_interface_id; + CustomWave * active_wave; + CustomShape * active_shape; void load_init_conditions(); @@ -218,7 +107,7 @@ public: SplayTree * user_param_tree; /* user parameter splay tree */ SplayTree * custom_wave_tree; /* custom wave forms for this preset */ SplayTree * custom_shape_tree; /* custom shapes for this preset */ - + /** Methods */ void evalInitConditions(); void evalCustomWaveInitConditions(); @@ -243,11 +132,12 @@ public: void load_custom_wave_init( CustomWave *customWave ); void load_custom_shape_init_conditions(); void load_custom_shape_init( CustomShape *customShape ); + void initialize(const std::string & pathname); void reloadPerFrame(char * s); void reloadPerFrameInit(char *s); void reloadPerPixel(char *s); - + int load_preset_file(const char * pathname); static Preset *load_preset( const char *pathname ); void savePreset(char * name); int write_preset_name( FILE *fs ); @@ -256,14 +146,16 @@ public: int write_per_frame_init_equations( FILE *fs ); int write_per_frame_equations( FILE *fs ); int write_per_pixel_equations( FILE *fs ); - + Param * find_param(char * name, int flags) ; int destroy(); - +void load_init_cond(char *name, int flags); /** Splaytree traversal helpers */ inline void load_custom_shape_init_helper( void *custom_shape ) { ((CustomShape *)custom_shape)->load_custom_shape_init(); + } + }; #endif /** !_PRESET_HPP */ diff --git a/src/projectM-engine/PresetFrameIO.hpp b/src/projectM-engine/PresetFrameIO.hpp new file mode 100644 index 000000000..fc2ca48f9 --- /dev/null +++ b/src/projectM-engine/PresetFrameIO.hpp @@ -0,0 +1,160 @@ +#ifndef PRESET_FRAME_IO_HPP +#define PRESET_FRAME_IO_HPP + +/** Container for all preset writeable engine variables. It's a struct + * so that it's light weight. Access is done directly on + * members for Mr. Sperl's convenience */ +class PresetOutputs { +public: + /// @bug should this be here? + //int mesh_i, mesh_j; + + /* PER FRAME CONSTANTS BEGIN */ + float zoom; + float zoomexp; + float rot; + float warp; + + float sx; + float sy; + float dx; + float dy; + float cx; + float cy; + + float decay; + + float wave_r; + float wave_g; + float wave_b; + float wave_o; + float wave_x; + float wave_y; + float wave_mystery; + + float ob_size; + float ob_r; + float ob_g; + float ob_b; + float ob_a; + + float ib_size; + float ib_r; + float ib_g; + float ib_b; + float ib_a; + + float mv_a ; + float mv_r ; + float mv_g ; + float mv_b ; + float mv_l; + float mv_x; + float mv_y; + float mv_dy; + float mv_dx; + + /* PER_FRAME CONSTANTS END */ + + float fRating; + float fGammaAdj; + float fVideoEchoZoom; + float fVideoEchoAlpha; + + int nVideoEchoOrientation; + int nWaveMode; + int bAdditiveWaves; + int bWaveDots; + int bWaveThick; + int bModWaveAlphaByVolume; + int bMaximizeWaveColor; + int bTexWrap; + int bDarkenCenter; + int bRedBlueStereo; + int bBrighten; + int bDarken; + int bSolarize; + int bInvert; + int bMotionVectorsOn; + + + float fWaveAlpha ; + float fWaveScale; + float fWaveSmoothing; + float fWaveParam; + float fModWaveAlphaStart; + float fModWaveAlphaEnd; + float fWarpAnimSpeed; + float fWarpScale; + float fShader; + + /* Q VARIABLES START */ + + float q1; + float q2; + float q3; + float q4; + float q5; + float q6; + float q7; + float q8; + + + /* Q VARIABLES END */ + + float **zoom_mesh; + float **zoomexp_mesh; + float **rot_mesh; + + float **sx_mesh; + float **sy_mesh; + float **dx_mesh; + float **dy_mesh; + float **cx_mesh; + float **cy_mesh; + + + +}; + +/** Container for all *read only* engine variables. It's a struct + * so that it's light weight. Access is done directly on + * members for Mr. Sperl's convenience */ +class PresetInputs { + +public: + /* PER_PIXEL CONSTANTS BEGIN */ + + float x_per_pixel; + float y_per_pixel; + float rad_per_pixel; + float ang_per_pixel; + + /* PER_PIXEL CONSTANT END */ + + int fps; + + + float time; + float bass; + float mid; + float bass_att; + float mid_att; + float treb_att; + int frame; + float progress; + + + /* variables added in 1.04 */ + int gx,gy; + + /// @bug are these in use? + //int meshx; + //int meshy; +float **x_mesh; + float **y_mesh; + float **rad_mesh; + float **theta_mesh; +}; + +#endif diff --git a/src/projectM-engine/PresetSwitcher.cpp b/src/projectM-engine/PresetSwitcher.cpp new file mode 100644 index 000000000..d199abd5a --- /dev/null +++ b/src/projectM-engine/PresetSwitcher.cpp @@ -0,0 +1,224 @@ +// +// C++ Implementation: PresetSwitcher +// +// Description: +// +// +// Author: Carmelo Piccione , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "PresetSwitcher.hpp" + +int PresetSwitcher::destroyPresetLoader() { + + //if ((Preset::active_preset != NULL) && (Preset::active_preset != Preset::idle_preset)) { + // Preset::active_preset->close_preset(); + //} + + ///Preset::active_preset = NULL; + //Preset::destroy_idle_preset(); + //destroy_builtin_param_db(); + //destroy_builtin_func_db(); + //Eval::destroy_infix_ops(); + + return PROJECTM_SUCCESS; + +} + +/* Loads a specific preset by absolute path */ +int PresetSwitcher::loadPresetByFile(char * filename) { + + Preset * new_preset; + + /* Finally, load the preset using its actual path */ + if ((new_preset = Preset::load_preset(filename)) == NULL) { +#ifdef PRESET_DEBUG + printf("loadPresetByFile: failed to load preset!\n"); +#endif + return PROJECTM_ERROR; + } +abort(); + + /* Closes a preset currently loaded, if any */ +// if ((this->activePreset != NULL) && (this->activePreset != Preset::idle_preset)) + // this->activePreset->close_preset(); + + /* Sets active preset global pointer */ + //this->activePreset = new_preset; + + /* Reinitialize engine variables */ +// PresetSwitcher_resetengine(); + + + /* Add any missing initial conditions for each wave */ +// this->activePreset->load_custom_wave_init_conditions(); + + /* Add any missing initial conditions for each wave */ +// this->activePreset->load_custom_shape_init_conditions(); + + /* Add any missing initial conditions */ +// load_init_conditions(); + + /* Need to do this once for menu */ + //this->activePreset->evalInitConditions(); + // evalPerFrameInitEquations(); + + + return PROJECTM_SUCCESS; +} + + +/* switchPreset: loads the next preset from the directory stream. + loadPresetDir() must be called first. This is a + sequential load function */ + +int PresetSwitcher::switchPreset(switch_mode_t switch_mode, int cut_type) { + + Preset * new_preset = 0; + + int switch_index; + int sindex = 0; + int slen = 0; + + DWRITE( "switchPreset(): in\n" ); +// DWRITE( "switchPreset(): %s\n", presetURL ); + + switch (switch_mode) { + case ALPHA_NEXT: +// preset_index = switch_index = preset_index + 1; + break; + case ALPHA_PREVIOUS: +// preset_index = switch_index = preset_index - 1; + break; + case RANDOM_NEXT: + switch_index = rand(); + break; + case RESTART_ACTIVE: +// switch_index = preset_index; + break; + default: + return PROJECTM_FAILURE; + } + + DWRITE( "switch_index: %d\n", switch_index ); + + // iterate through the presetURL directory looking for the next entry + { + struct dirent** entries; +// int dir_size = scandir(presetURL, &entries, /* is_valid_extension */ NULL, alphasort); +// DWRITE( "dir_size: %d\n", dir_size ); +// if (dir_size > 0) { + int i; + +// DWRITE( "nentries: %d\n", dir_size ); + +// switch_index %= dir_size; +// if (switch_index < 0) switch_index += dir_size +// for (i = 0; i < dir_size; ++i) { +// if (switch_index == i) { + // matching entry +// const size_t len = strlen(presetURL); +// char* path = (char *) malloc(len + strlen(entries[i]->d_name) + 2); +// if (path) { +// strcpy(path, presetURL); +// if (len && ((path[len - 1] != '/')||(path[len - 1] != '\\'))) { +//#ifdef WIN32 +// strcat(path + len, "\\"); +//#else +// strcat(path + len, "/"); +//#endif +// } +// strcat(path + len, entries[i]->d_name); +// +// new_preset = Preset::load_preset(path); +// free(path); + +// // we must keep iterating to free the remaining entries +// } +// } +// free(entries[i]); +// } +// free(entries); +// } + } + +#ifdef WIN32 + new_preset = Preset::load_preset( "c:\\tmp\\PresetSwitcher-1.00\\presets_test\\C.milk" ); +#else +// new_preset = Preset::load_preset( "/Users/descarte/tmp/PresetSwitcher-1.00/presets_test/B.milk" ); +// new_preset = NULL; +#endif + + if (!new_preset) { + return PROJECTM_ERROR; + } + + + /* Closes a preset currently loaded, if any */ +// if ((this->activePreset != NULL) && (this->activePreset != Preset::idle_preset)) { + // this->activePreset->close_preset(); + // } + + /* Sets global this->activePreset pointer */ + //this->activePreset = new_preset; + +#if 0 +#ifndef PANTS + /** Split out the preset name from the path */ + slen = strlen( new_preset->file_path ); + sindex = slen; + while ( new_preset->file_path[sindex] != WIN32_PATH_SEPARATOR && + new_preset->file_path[sindex] != UNIX_PATH_SEPARATOR && sindex > 0 ) { + sindex--; + } + sindex++; + if ( presetName != NULL ) { + free( presetName ); + presetName = NULL; + } + presetName = (char *)wipemalloc( sizeof( char ) * (slen - sindex + 1) ); + strncpy( presetName, new_preset->file_path + sindex, slen - sindex ); + presetName[slen - sindex] = '\0'; +#endif + + /* Reinitialize the engine variables to sane defaults */ + PresetSwitcher_resetengine(); + + /* Add any missing initial conditions */ + load_init_conditions(); + + /* Add any missing initial conditions for each wave */ + this->activePreset->load_custom_wave_init_conditions(); + +/* Add any missing initial conditions for each shape */ + this->activePreset->load_custom_shape_init_conditions(); + + /* Need to evaluate the initial conditions once */ + this->activePreset->evalInitConditions(); + this->activePreset->evalCustomWaveInitConditions(); + this->activePreset->evalCustomShapeInitConditions(); + // evalInitPerFrameEquations(); +#endif + return PROJECTM_SUCCESS; +} + + +/* Returns nonzero if string 'name' contains .milk or + (the better) .prjm extension. Not a very strong function currently */ +int PresetSwitcher::is_valid_extension(const struct dirent* ent) { + const char* ext = 0; + + if (!ent) return FALSE; + + ext = strrchr(ent->d_name, '.'); + if (!ext) ext = ent->d_name; + + if (0 == strcasecmp(ext, MILKDROP_FILE_EXTENSION)) return TRUE; + if (0 == strcasecmp(ext, PROJECTM_FILE_EXTENSION)) return TRUE; + + return FALSE; +} + diff --git a/src/projectM-engine/PresetSwitcher.hpp b/src/projectM-engine/PresetSwitcher.hpp new file mode 100644 index 000000000..7c431e226 --- /dev/null +++ b/src/projectM-engine/PresetSwitcher.hpp @@ -0,0 +1,37 @@ +#ifndef PRESET_SWITCHER_HPP +#define PRESET_SWITCHER_HPP +#include "Preset.hpp" + +#include "projectM.h" + +typedef enum { + ALPHA_NEXT, + ALPHA_PREVIOUS, + RANDOM_NEXT, + RESTART_ACTIVE, +} switch_mode_t; + + +typedef enum { +SOFT_CUT, +HARD_CUT +} cut_type; + +class PresetSwitcher { + +public: + + /** Preset switching */ + static int loadPresetDir( char *dir ); + static int closePresetDir(); + static int switchPreset( switch_mode_t switch_mode, int cut_type ); + static void switchToIdlePreset(); + static int loadPresetByFile( char *filename ); + static int initPresetLoader(); + static int destroyPresetLoader(); +int is_valid_extension(const struct dirent* ent); +/* destroyPresetLoader: closes the preset + loading library. This should be done when + PresetSwitcher does cleanup */ +}; +#endif diff --git a/src/projectM-engine/builtin_funcs.h b/src/projectM-engine/builtin_funcs.h deleted file mode 100755 index 6f34062bb..000000000 --- a/src/projectM-engine/builtin_funcs.h +++ /dev/null @@ -1,219 +0,0 @@ -/** - * projectM -- Milkdrop-esque visualisation SDK - * Copyright (C)2003-2007 projectM Team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * See 'LICENSE.txt' included within this release - * - */ -/** - * $Id$ - * - * $Log$ - */ - -/* Wrappers for all the builtin functions - The arg_list pointer is a list of floats. Its - size is equal to the number of arguments the parameter - takes */ - -#ifndef _BUILTIN_FUNCS_H -#define _BUILTIN_FUNCS_H - -#include "projectM.h" - - -/* Values to optimize the sigmoid function */ -#define R 32767 -#define RR 65534 - - - -inline float int_wrapper(float * arg_list) { - -return floor(arg_list[0]); - -} - - -inline float sqr_wrapper(float * arg_list) { - -return pow(2, arg_list[0]); -} - - -inline float sign_wrapper(float * arg_list) { - -return -arg_list[0]; -} - -inline float min_wrapper(float * arg_list) { - -if (arg_list[0] > arg_list[1]) -return arg_list[1]; - -return arg_list[0]; -} - -inline float max_wrapper(float * arg_list) { - -if (arg_list[0] > arg_list[1]) -return arg_list[0]; - -return arg_list[1]; -} - -/* consult your AI book */ -inline float sigmoid_wrapper(float * arg_list) { -return (RR / (1 + exp( -(((float)(arg_list[0])) * arg_list[1]) / R) - R)); -} - - -inline float bor_wrapper(float * arg_list) { - -return (float)((int)arg_list[0] || (int)arg_list[1]); -} - -inline float band_wrapper(float * arg_list) { -return (float)((int)arg_list[0] && (int)arg_list[1]); -} - -inline float bnot_wrapper(float * arg_list) { -return (float)(!(int)arg_list[0]); -} - -inline float if_wrapper(float * arg_list) { - -if ((int)arg_list[0] == 0) -return arg_list[2]; -return arg_list[1]; -} - - -inline float rand_wrapper(float * arg_list) { -float l=1; - -// printf("RAND ARG:(%d)\n", (int)arg_list[0]); -if ((int)arg_list[0] > 0) -l = (float)((rand()) % ((int)arg_list[0])); -//printf("VAL: %f\n", l); -return l; -} - -inline float equal_wrapper(float * arg_list) { - return (arg_list[0] == arg_list[1]); -} - - -inline float above_wrapper(float * arg_list) { - -return (arg_list[0] > arg_list[1]); -} - - -inline float below_wrapper(float * arg_list) { - -return (arg_list[0] < arg_list[1]); -} - -inline float sin_wrapper(float * arg_list) { -return (sin (arg_list[0])); -} - - -inline float cos_wrapper(float * arg_list) { -return (cos (arg_list[0])); -} - -inline float tan_wrapper(float * arg_list) { -return (tan(arg_list[0])); -} - -inline float asin_wrapper(float * arg_list) { -return (asin (arg_list[0])); -} - -inline float acos_wrapper(float * arg_list) { -return (acos (arg_list[0])); -} - -inline float atan_wrapper(float * arg_list) { -return (atan (arg_list[0])); -} - -inline float atan2_wrapper(float * arg_list) { -return (atan2 (arg_list[0], arg_list[1])); -} - -inline float pow_wrapper(float * arg_list) { -return (pow (arg_list[0], arg_list[1])); -} - -inline float exp_wrapper(float * arg_list) { -return (exp(arg_list[0])); -} - -inline float abs_wrapper(float * arg_list) { -return (fabs(arg_list[0])); -} - -inline float log_wrapper(float* arg_list) { -return (log (arg_list[0])); -} - -inline float log10_wrapper(float * arg_list) { -return (log10 (arg_list[0])); -} - -inline float sqrt_wrapper(float * arg_list) { -return (sqrt (arg_list[0])); -} - - -inline float nchoosek_wrapper(float * arg_list) { -unsigned long cnm = 1UL; -int i, f; -int n, m; - -n = (int)arg_list[0]; -m = (int)arg_list[1]; - -if (m*2 >n) m = n-m; -for (i=1 ; i <= m; n--, i++) -{ -if ((f=n) % i == 0) -f /= i; -else cnm /= i; -cnm *= f; -} -return (float)cnm; -} - - -inline float fact_wrapper(float * arg_list) { - - -int result = 1; - -int n = (int)arg_list[0]; - -while (n > 1) { -result = result * n; -n--; -} -return (float)result; -} - -#endif /** !_BUILTIN_FUNCS_H */ diff --git a/src/projectM-engine/console_interface.cpp b/src/projectM-engine/console_interface.cpp index f0f636b1c..a6e5e8210 100755 --- a/src/projectM-engine/console_interface.cpp +++ b/src/projectM-engine/console_interface.cpp @@ -26,15 +26,16 @@ #include "fatal.h" #include "menu.h" #include "console_interface.h" -#include "Preset.h" +#include "Preset.hpp" #include "browser.h" #include "editor.h" #include "event.h" #include "BeatDetect.h" +#include "PresetSwitcher.hpp" Preset *active_preset; -interface_t current_interface = DEFAULT_INTERFACE; +interface_t current_interface;// = DEFAULT_INTERFACE; void refreshConsole() { @@ -70,7 +71,7 @@ void projectM::key_handler( projectMEvent event, //default_key_handler(); switch (current_interface) { - + case MENU_INTERFACE: // menu_key_handler(this, event, keycode); break; @@ -89,20 +90,17 @@ void projectM::key_handler( projectMEvent event, default: default_key_handler(event,keycode); break; - + } break; } } void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode) { - - switch( event ) { case PROJECTM_KEYDOWN: - switch( keycode ) { case PROJECTM_K_UP: @@ -157,21 +155,21 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode case PROJECTM_K_b: break; case PROJECTM_K_n: - if (switchPreset(ALPHA_NEXT, HARD_CUT) < 0) { - printf("WARNING: Bad preset file, loading idle preset\n"); - switchToIdlePreset(); + if (PresetSwitcher::switchPreset(ALPHA_NEXT, HARD_CUT) < 0) { + printf("WARNING: Bad preset file, not handling this..aborting!\n"); + abort(); } break; case PROJECTM_K_r: - if (switchPreset(RANDOM_NEXT, HARD_CUT) < 0) { + if (PresetSwitcher::switchPreset(RANDOM_NEXT, HARD_CUT) < 0) { printf("WARNING: Bad preset file, loading idle preset\n"); - switchToIdlePreset(); + abort(); } break; case PROJECTM_K_p: - if ((switchPreset(ALPHA_PREVIOUS, HARD_CUT)) < 0){ + if ((PresetSwitcher::switchPreset(ALPHA_PREVIOUS, HARD_CUT)) < 0){ printf("WARNING: Bad preset file, loading idle preset\n"); - switchToIdlePreset(); + abort(); } break; case PROJECTM_K_l: @@ -179,7 +177,7 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode // current_interface = BROWSER_INTERFACE; // loadBrowser(); break; - case PROJECTM_K_e: + case PROJECTM_K_e: current_interface = EDITOR_INTERFACE; // loadEditor(active_preset->per_frame_eqn_string_buffer,(void (*)()) reloadPerFrame, // 80, 24, 140, 60, 0, 0); @@ -193,16 +191,16 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode DWRITE( "PROJECTM_K_i\n" ); doIterative = !doIterative; break; - case PROJECTM_K_z: + case PROJECTM_K_z: break; - case PROJECTM_K_0: - nWaveMode=0; + case PROJECTM_K_0: +// nWaveMode=0; break; case PROJECTM_K_6: - nWaveMode=6; +// nWaveMode=6; break; case PROJECTM_K_7: - nWaveMode=7; +// nWaveMode=7; break; case PROJECTM_K_m: showhelp=0; diff --git a/src/projectM-engine/editor.cpp b/src/projectM-engine/editor.cpp index d91a2b614..a16ced62c 100755 --- a/src/projectM-engine/editor.cpp +++ b/src/projectM-engine/editor.cpp @@ -35,7 +35,7 @@ #include "event.h" //#include "preset_types.h" -#include "Preset.h" +#include "Preset.hpp" #include "glConsole.h" diff --git a/src/projectM-engine/menu.cpp b/src/projectM-engine/menu.cpp index af8dee83f..06e233d9a 100755 --- a/src/projectM-engine/menu.cpp +++ b/src/projectM-engine/menu.cpp @@ -39,7 +39,7 @@ #include "glConsole.h" -#include "Preset.h" +#include "Preset.hpp" #include "editor.h" #include "menu.h" #include "wipemalloc.h" @@ -48,7 +48,7 @@ #define DEFAULT_COLOR 0 #define LOCKED_COLOR 2 -extern Preset *active_preset; +extern Preset *activePreset; extern interface_t current_interface; menu_t * load_waveform_menu(); @@ -227,28 +227,28 @@ menu_t * load_waveform_menu() { if ((waveform_menu = new_menu(main_menu)) == NULL) return NULL; - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("wave type", Param::find_param("nWaveMode", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("size", Param::find_param("fWaveScale", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("smoothing", Param::find_param("fWaveSmoothing", active_preset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("wave type", Param::find_param("nWaveMode", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("size", Param::find_param("fWaveScale", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("smoothing", Param::find_param("fWaveSmoothing", activePreset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("mystery parameter", Param::find_param("wave_mystery", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("opacity", Param::find_param("fWaveAlpha", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("position (x)", Param::find_param("wave_x", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("position (y)", Param::find_param("wave_y", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (red)", Param::find_param("wave_r", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (green)", Param::find_param("wave_g", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (blue)", Param::find_param("wave_b", active_preset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("mystery parameter", Param::find_param("wave_mystery", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("opacity", Param::find_param("fWaveAlpha", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("position (x)", Param::find_param("wave_x", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("position (y)", Param::find_param("wave_y", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (red)", Param::find_param("wave_r", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (green)", Param::find_param("wave_g", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (blue)", Param::find_param("wave_b", activePreset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("use dots", Param::find_param("bWaveDots", active_preset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("use dots", Param::find_param("bWaveDots", activePreset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("draw thick", Param::find_param("bWaveThick", active_preset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("draw thick", Param::find_param("bWaveThick", activePreset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("modulate opacity by volume", Param::find_param("bModWaveAlphaByVolume", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("mod. lower threshold", Param::find_param("fModWaveAlphaStart", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("mod. uppper threshold", Param::find_param("fModWaveAlphaEnd", active_preset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("modulate opacity by volume", Param::find_param("bModWaveAlphaByVolume", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("mod. lower threshold", Param::find_param("fModWaveAlphaStart", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("mod. uppper threshold", Param::find_param("fModWaveAlphaEnd", activePreset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("additive drawing", Param::find_param("bAdditiveWaves", active_preset, P_CREATE)))); - append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color brightening", Param::find_param("bMaximizeWaveColor", active_preset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("additive drawing", Param::find_param("bAdditiveWaves", activePreset, P_CREATE)))); + append_menu_item(waveform_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color brightening", Param::find_param("bMaximizeWaveColor", activePreset, P_CREATE)))); waveform_menu->selected_item = waveform_menu->start_item; return waveform_menu; @@ -261,28 +261,28 @@ menu_t * load_augmentations_menu() { if ((augmentations_menu = new_menu(main_menu)) == NULL) return NULL; - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("outer border thickness", Param::find_param("ob_size", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (red)", Param::find_param("ob_r", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (green)", Param::find_param("ob_g", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (blue)", Param::find_param("ob_b", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" opacity", Param::find_param("ob_a", active_preset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("outer border thickness", Param::find_param("ob_size", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (red)", Param::find_param("ob_r", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (green)", Param::find_param("ob_g", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (blue)", Param::find_param("ob_b", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" opacity", Param::find_param("ob_a", activePreset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("inner border thickness", Param::find_param("ib_size", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (red)", Param::find_param("ib_r", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (green)", Param::find_param("ib_g", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (blue)", Param::find_param("ib_b", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" opacity", Param::find_param("ib_a", active_preset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("inner border thickness", Param::find_param("ib_size", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (red)", Param::find_param("ib_r", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (green)", Param::find_param("ib_g", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" color (blue)", Param::find_param("ib_b", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj(" opacity", Param::find_param("ib_a", activePreset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("motion vector opacity", Param::find_param("mv_a", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("num. mot. vector (X)", Param::find_param("mv_x", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("num. mot. vector (Y)", Param::find_param("mv_y", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("offset (X)", Param::find_param("mv_dx", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("offset (Y)", Param::find_param("mv_dy", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("trail length", Param::find_param("mv_l", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (red)", Param::find_param("mv_r", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (green)", Param::find_param("mv_g", active_preset, P_CREATE)))); - append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (blue)", Param::find_param("mv_b", active_preset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("motion vector opacity", Param::find_param("mv_a", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("num. mot. vector (X)", Param::find_param("mv_x", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("num. mot. vector (Y)", Param::find_param("mv_y", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("offset (X)", Param::find_param("mv_dx", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("offset (Y)", Param::find_param("mv_dy", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("trail length", Param::find_param("mv_l", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (red)", Param::find_param("mv_r", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (green)", Param::find_param("mv_g", activePreset, P_CREATE)))); + append_menu_item(augmentations_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("color (blue)", Param::find_param("mv_b", activePreset, P_CREATE)))); augmentations_menu->selected_item = augmentations_menu->start_item; @@ -298,15 +298,15 @@ menu_t * load_motion_menu() { return NULL; - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("zoom amount", Param::find_param("zoom", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("zoom exponent", Param::find_param("zoomexp", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("rotation amount", Param::find_param("rot", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("rot., center of (X)", Param::find_param("cx", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("rot., center of (Y)", Param::find_param("cy", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("translation (X)", Param::find_param("dx", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("translation (Y)", Param::find_param("dy", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("scaling (X)", Param::find_param("sx", active_preset, P_CREATE)))); - append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("scaling (Y)", Param::find_param("sy", active_preset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("zoom amount", Param::find_param("zoom", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("zoom exponent", Param::find_param("zoomexp", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("rotation amount", Param::find_param("rot", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("rot., center of (X)", Param::find_param("cx", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("rot., center of (Y)", Param::find_param("cy", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("translation (X)", Param::find_param("dx", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("translation (Y)", Param::find_param("dy", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("scaling (X)", Param::find_param("sx", activePreset, P_CREATE)))); + append_menu_item(motion_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("scaling (Y)", Param::find_param("sy", activePreset, P_CREATE)))); motion_menu->selected_item = motion_menu->start_item; @@ -319,19 +319,19 @@ menu_t * load_postprocessing_menu() { if ((postprocessing_menu = new_menu(main_menu)) == NULL) return NULL; - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("sustain level", Param::find_param("fDecay", active_preset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("sustain level", Param::find_param("fDecay", activePreset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("darken center", Param::find_param("bDarkenCenter", active_preset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("darken center", Param::find_param("bDarkenCenter", activePreset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("gamma adjustment", Param::find_param("fDecay", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("video echo: alpha", Param::find_param("fVideoEchoAlpha", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("video echo: scale", Param::find_param("fVideoEchoZoom", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("video echo: orientation", Param::find_param("nVideoEchoOrientation", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("texture wrapping", Param::find_param("bTexWrap", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("darken filter", Param::find_param("bDarken", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("brighten filter", Param::find_param("bBrighten", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("solarize filter", Param::find_param("bSolarize", active_preset, P_CREATE)))); - append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("invert filter", Param::find_param("bInvert", active_preset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("gamma adjustment", Param::find_param("fDecay", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("video echo: alpha", Param::find_param("fVideoEchoAlpha", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("video echo: scale", Param::find_param("fVideoEchoZoom", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("video echo: orientation", Param::find_param("nVideoEchoOrientation", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("texture wrapping", Param::find_param("bTexWrap", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("darken filter", Param::find_param("bDarken", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("brighten filter", Param::find_param("bBrighten", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("solarize filter", Param::find_param("bSolarize", activePreset, P_CREATE)))); + append_menu_item(postprocessing_menu, new_menu_item(PARAM_ADJ_TYPE, new_param_adj("invert filter", Param::find_param("bInvert", activePreset, P_CREATE)))); postprocessing_menu->selected_item = postprocessing_menu->start_item; @@ -431,7 +431,7 @@ int print_menu_item(menu_item_t * menu_item) { case P_TYPE_BOOL: - if ((init_cond = Preset::active_preset->get_init_cond(param_adj.param)) == NULL) + if ((init_cond = projectM::activePreset->get_init_cond(param_adj.param)) == NULL) sprintf(string, "%s ?", param_adj.print_string); else if (init_cond->init_val.bool_val) sprintf(string, "%s [ON]", param_adj.print_string); @@ -439,13 +439,13 @@ int print_menu_item(menu_item_t * menu_item) { sprintf(string, "%s [OFF]", param_adj.print_string); break; case P_TYPE_INT: - if ((init_cond = Preset::active_preset->get_init_cond(param_adj.param)) == NULL) + if ((init_cond = projectM::activePreset->get_init_cond(param_adj.param)) == NULL) sprintf(string, "%s ?", param_adj.print_string); else sprintf(string, "%s %d", param_adj.print_string, init_cond->init_val.int_val); break; case P_TYPE_DOUBLE: - if ((init_cond = Preset::active_preset->get_init_cond(param_adj.param)) == NULL) + if ((init_cond = projectM::activePreset->get_init_cond(param_adj.param)) == NULL) sprintf(string, "%s ?", param_adj.print_string); else sprintf(string, "%s %f", param_adj.print_string, init_cond->init_val.float_val); @@ -549,7 +549,7 @@ int switchMenuState(dir_t dir) { if (active_menu->locked_item == NULL) { - if ((init_cond = Preset::active_preset->get_init_cond(param_adj.param)) == NULL) + if ((init_cond = projectM::activePreset->get_init_cond(param_adj.param)) == NULL) return PROJECTM_FAILURE; @@ -804,21 +804,21 @@ int pursue_menu_link(menu_link_t * menu_link) { int edit_per_pixel_eqn() { hideMenu(); current_interface = EDITOR_INTERFACE; -// loadEditor(active_preset->per_pixel_eqn_string_buffer,(void (*)()) reloadPerPixel, 80, 24, 140, 60, 0, 0); +// loadEditor(activePreset->per_pixel_eqn_string_buffer,(void (*)()) reloadPerPixel, 80, 24, 140, 60, 0, 0); return PROJECTM_SUCCESS; } int edit_per_frame_eqn() { hideMenu(); current_interface = EDITOR_INTERFACE; -// loadEditor(active_preset->per_frame_eqn_string_buffer, (void (*)())reloadPerFrame,80,24,140,60,0,0); +// loadEditor(activePreset->per_frame_eqn_string_buffer, (void (*)())reloadPerFrame,80,24,140,60,0,0); return PROJECTM_SUCCESS; } int edit_per_frame_init() { hideMenu(); current_interface = EDITOR_INTERFACE; -// loadEditor(active_preset->per_frame_init_eqn_string_buffer,(void (*)()) reloadPerFrameInit,80,24,140,60,0,0); +// loadEditor(activePreset->per_frame_init_eqn_string_buffer,(void (*)()) reloadPerFrameInit,80,24,140,60,0,0); return PROJECTM_SUCCESS; } @@ -848,7 +848,7 @@ int adj_float_param(Param * param, adj_t adj) { if (param->type == P_TYPE_INT) return (adj_int_param(param, adj)); - if ((init_cond = (InitCond*)Preset::active_preset->init_cond_tree->splay_find(param->name)) == NULL) + if ((init_cond = (InitCond*)projectM::activePreset->init_cond_tree->splay_find(param->name)) == NULL) return PROJECTM_FAILURE; switch (adj) { @@ -904,7 +904,7 @@ int adj_int_param(Param * param, adj_t adj) { if (param == NULL) return PROJECTM_FAILURE; - if ((init_cond = (InitCond*)active_preset->init_cond_tree->splay_find(param->name)) == NULL) + if ((init_cond = (InitCond*)activePreset->init_cond_tree->splay_find(param->name)) == NULL) return PROJECTM_FAILURE; switch (adj) { @@ -971,13 +971,13 @@ void menu_key_handler( projectMEvent event, projectMKeycode key ) { break; case PROJECTM_K_n: - projectM::currentEngine->switchPreset(ALPHA_NEXT, HARD_CUT); + //projectM::currentEngine->switchPreset(ALPHA_NEXT, HARD_CUT); break; case PROJECTM_K_r: - projectM::currentEngine->switchPreset(RANDOM_NEXT, HARD_CUT); + //projectM::currentEngine->switchPreset(RANDOM_NEXT, HARD_CUT); break; case PROJECTM_K_p: - projectM::currentEngine->switchPreset(ALPHA_PREVIOUS, HARD_CUT); + //projectM::currentEngine->switchPreset(ALPHA_PREVIOUS, HARD_CUT); break; case PROJECTM_K_a: break; diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 9e5151c64..8da1b1a97 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -27,7 +27,7 @@ #endif /** USE_FTGL */ #include "wipemalloc.h" -#include "builtin_funcs.h" +#include "BuiltinFuncs.hpp" #include "fatal.h" #include "common.h" #include "compare.h" @@ -84,7 +84,7 @@ int x, y; // printf("Start of loop at %d\n",timestart); - mspf=(int)(1000.0/(float)fps); //milliseconds per frame + mspf=(int)(1000.0/(float)presetInputs.fps); //milliseconds per frame totalframes++; //total amount of frames since startup #ifndef WIN32 @@ -93,19 +93,19 @@ int x, y; Time = getTicks( startTime ) * 0.001; #endif /** !WIN32 */ - frame++; //number of frames for current preset - progress= frame/(float)avgtime; + presetInputs.frame++; //number of frames for current preset + presetInputs.progress= presetInputs.frame/(float)avgtime; DWRITE( "frame: %d\ttime: %f\tprogress: %f\tavgtime: %d\tang: %f\trot: %f\n", - this->frame, Time, this->progress, this->avgtime, this->ang_per_pixel, - this->rot ); - if (progress>1.0) progress=1.0; + this->presetInputs.frame, Time, this->presetInputs.progress, this->avgtime, this->presetInputs.ang_per_pixel, + this->presetOutputs.rot ); + if (presetInputs.progress>1.0) presetInputs.progress=1.0; // printf("start:%d at:%d min:%d stop:%d on:%d %d\n",startframe, frame frame-startframe,avgtime, noSwitch,progress); -// Preset::active_preset->evalInitConditions(); - Preset::active_preset->evalPerFrameEquations(); +// this->activePreset->evalInitConditions(); + this->activePreset->evalPerFrameEquations(); -// Preset::active_preset->evalCustomWaveInitConditions(); -// Preset::active_preset->evalCustomShapeInitConditions(); +// this->activePreset->evalCustomWaveInitConditions(); +// this->activePreset->evalCustomShapeInitConditions(); // printf("%f %d\n",Time,frame); @@ -124,7 +124,7 @@ int x, y; { // printf("%f %d %d\n", beatDetect->bass-beatDetect->bass_old,this->frame,this->avgtime); // switchPreset(RANDOM_NEXT, HARD_CUT); - nohard=fps*5; + nohard=presetInputs.fps*5; } } @@ -199,7 +199,7 @@ int x, y; draw_shapes(); draw_custom_waves(); draw_waveform(); - if(this->bDarkenCenter)darken_center(); + if(this->presetOutputs.bDarkenCenter)darken_center(); draw_borders(); //draw borders /** Restore original view state */ @@ -212,10 +212,9 @@ int x, y; /** Restore all original attributes */ // glPopAttrib(); glFlush(); - - + unlockPBuffer( this->renderTarget ); - + #ifdef DEBUG GLint msd = 0, @@ -300,7 +299,7 @@ int x, y; DLLEXPORT void projectM::projectM_reset() { DWRITE( "projectM_reset(): in\n" ); - Preset::active_preset = NULL; + this->activePreset = NULL; this->presetURL = NULL; this->fontURL = NULL; @@ -350,8 +349,8 @@ DLLEXPORT void projectM::projectM_reset() { this->fullscreen = 0; /** Configurable mesh size */ - this->gx = 48; - this->gy = 36; + this->presetInputs.gx = 48; + this->presetInputs.gy = 36; /** Frames per preset */ this->avgtime = 500; @@ -414,10 +413,7 @@ DLLEXPORT void projectM::projectM_init() { beatDetect = new BeatDetect(); /* Preset loading function */ - initPresetLoader(); - if ( loadPresetDir( presetURL ) == PROJECTM_ERROR ) { - switchToIdlePreset(); - } + initPresetTools(); /* Load default preset directory */ #ifdef MACOS2 @@ -479,7 +475,7 @@ DLLEXPORT void projectM::projectM_init() { strcpy( fontURL, "/Users/descarte/tmp/projectM/fonts" ); this->fontURL[34] = '\0'; // loadPresetDir( "../../presets/" ); - loadPresetDir( "/Users/descarte/tmp/projectM-1.00/presets_projectM" ); +// loadPresetDir( "/Users/descarte/tmp/projectM-1.00/presets_projectM" ); } else { printf( "PresetDir: %s\n", this->presetURL ); loadPresetDir( presetURL ); @@ -499,13 +495,13 @@ DLLEXPORT void projectM::projectM_init() { #endif DWRITE( "loading font URL directly: %s\n", this->fontURL ); #ifdef WIN32 - loadPresetDir( "c:\\tmp\\projectM\\presets_projectM" ); + // loadPresetDir( "c:\\tmp\\projectM\\presets_projectM" ); #else - loadPresetDir( "/Users/descarte/tmp/projectM-1.00/presets_projectM" ); + // loadPresetDir( "/Users/descarte/tmp/projectM-1.00/presets_projectM" ); #endif } else { printf( "PresetDir: %s\n", this->presetURL ); - loadPresetDir( presetURL ); + //loadPresetDir( presetURL ); } #endif @@ -514,7 +510,7 @@ printf( "pre init_display()\n" ); printf( "post init_display()\n" ); - mspf=(int)(1000.0/(float)fps); + mspf=(int)(1000.0/(float)presetInputs.fps); @@ -528,7 +524,7 @@ printf( "post CreaterenderTarget\n" ); initMenu(); //DWRITE( "post initMenu()\n" ); - printf("mesh: %d %d\n", this->gx,this->gy ); + printf("mesh: %d %d\n", this->presetInputs.gx,this->presetInputs.gy ); #ifdef PANTS printf( "maxsamples: %d\n", this->maxsamples ); @@ -536,7 +532,7 @@ printf( "post CreaterenderTarget\n" ); DWRITE( "post PCM init\n" ); #endif - this->avgtime=this->fps*20; + this->avgtime=this->presetInputs.fps*20; this->hasInit = 1; @@ -550,7 +546,7 @@ void projectM::free_per_pixel_matrices() { int x; - for(x = 0; x < this->gx; x++) + for(x = 0; x < this->presetInputs.gx; x++) { free(this->gridx[x]); @@ -561,10 +557,10 @@ void projectM::free_per_pixel_matrices() { free(this->origy[x]); free(this->origx2[x]); free(this->origy2[x]); - free(this->x_mesh[x]); - free(this->y_mesh[x]); - free(this->rad_mesh[x]); - free(this->theta_mesh[x]); + free(this->presetInputs.x_mesh[x]); + free(this->presetInputs.y_mesh[x]); + free(this->presetInputs.rad_mesh[x]); + free(this->presetInputs.theta_mesh[x]); } @@ -575,10 +571,10 @@ void projectM::free_per_pixel_matrices() { free(this->origy2); free(this->gridx); free(this->gridy); - free(this->x_mesh); - free(this->y_mesh); - free(this->rad_mesh); - free(this->theta_mesh); + free(this->presetInputs.x_mesh); + free(this->presetInputs.y_mesh); + free(this->presetInputs.rad_mesh); + free(this->presetInputs.theta_mesh); this->origx = NULL; this->origy = NULL; @@ -586,10 +582,10 @@ void projectM::free_per_pixel_matrices() { this->origy2 = NULL; this->gridx = NULL; this->gridy = NULL; - this->x_mesh = NULL; - this->y_mesh = NULL; - this->rad_mesh = NULL; - this->theta_mesh = NULL; + this->presetInputs.x_mesh = NULL; + this->presetInputs.y_mesh = NULL; + this->presetInputs.rad_mesh = NULL; + this->presetInputs.theta_mesh = NULL; } @@ -597,122 +593,122 @@ void projectM::init_per_pixel_matrices() { int x,y; - this->gridx=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->gridx=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->gridx[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->gridx[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->gridy=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->gridy=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->gridy[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->gridy[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->origtheta=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->origtheta=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->origtheta[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->origtheta[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->origrad=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->origrad=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->origrad[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->origrad[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->origx=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->origx=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->origx[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->origx[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->origy=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->origy=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->origy[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->origy[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->origx2=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->origx2=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->origx2[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->origx2[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } -this->origy2=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) +this->origy2=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->origy2[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->origy2[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->x_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetInputs.x_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->x_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetInputs.x_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->y_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetInputs.y_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->y_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetInputs.y_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->rad_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetInputs.rad_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->rad_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetInputs.rad_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->theta_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetInputs.theta_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->theta_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetInputs.theta_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->sx_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.sx_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->sx_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.sx_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->sy_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.sy_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->sy_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.sy_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->dx_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.dx_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->dx_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.dx_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->dy_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.dy_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->dy_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.dy_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->cx_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.cx_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->cx_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.cx_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->cy_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.cy_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->cy_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.cy_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->zoom_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.zoom_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->zoom_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.zoom_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->zoomexp_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.zoomexp_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->zoomexp_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.zoomexp_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } - this->rot_mesh=(float **)wipemalloc(this->gx * sizeof(float *)); - for(x = 0; x < this->gx; x++) + this->presetOutputs.rot_mesh=(float **)wipemalloc(this->presetInputs.gx * sizeof(float *)); + for(x = 0; x < this->presetInputs.gx; x++) { - this->rot_mesh[x] = (float *)wipemalloc(this->gy * sizeof(float)); + this->presetOutputs.rot_mesh[x] = (float *)wipemalloc(this->presetInputs.gy * sizeof(float)); } //initialize reference grid values - for (x=0;xgx;x++) + for (x=0;xpresetInputs.gx;x++) { - for(y=0;ygy;y++) + for(y=0;ypresetInputs.gy;y++) { - this->origx[x][y]=x/(float)(this->gx-1); - this->origy[x][y]=-((y/(float)(this->gy-1))-1); + this->origx[x][y]=x/(float)(this->presetInputs.gx-1); + this->origy[x][y]=-((y/(float)(this->presetInputs.gy-1))-1); this->origrad[x][y]=hypot((this->origx[x][y]-.5)*2,(this->origy[x][y]-.5)*2) * .7071067; this->origtheta[x][y]=atan2(((this->origy[x][y]-.5)*2),((this->origx[x][y]-.5)*2)); this->gridx[x][y]=this->origx[x][y]*this->renderTarget->texsize; @@ -730,132 +726,132 @@ void projectM::do_per_pixel_math() { int x,y; float fZoom2,fZoom2Inv; - Preset::active_preset->evalPerPixelEqns(); + this->activePreset->evalPerPixelEqns(); - if(!Preset::active_preset->isPerPixelEqn(CX_OP)) + if(!this->activePreset->isPerPixelEqn(CX_OP)) { - for (x=0;xgx;x++){ + for (x=0;xpresetInputs.gx;x++){ - for(y=0;ygy;y++){ - this->cx_mesh[x][y]=this->cx; + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.cx_mesh[x][y]=this->presetOutputs.cx; } } } - if(!Preset::active_preset->isPerPixelEqn(CY_OP)) + if(!this->activePreset->isPerPixelEqn(CY_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->cy_mesh[x][y]=this->cy; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.cy_mesh[x][y]=this->presetOutputs.cy; }} } - if(!Preset::active_preset->isPerPixelEqn(SX_OP)) + if(!this->activePreset->isPerPixelEqn(SX_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->sx_mesh[x][y]=this->sx; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.sx_mesh[x][y]=this->presetOutputs.sx; }} } - if(!Preset::active_preset->isPerPixelEqn(SY_OP)) + if(!this->activePreset->isPerPixelEqn(SY_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->sy_mesh[x][y]=this->sy; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.sy_mesh[x][y]=this->presetOutputs.sy; }} } - if(!Preset::active_preset->isPerPixelEqn(ZOOM_OP)) + if(!this->activePreset->isPerPixelEqn(ZOOM_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->zoom_mesh[x][y]=this->zoom; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.zoom_mesh[x][y]=this->presetOutputs.zoom; }} } - if(!Preset::active_preset->isPerPixelEqn(ZOOMEXP_OP)) + if(!this->activePreset->isPerPixelEqn(ZOOMEXP_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->zoomexp_mesh[x][y]=this->zoomexp; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.zoomexp_mesh[x][y]=this->presetOutputs.zoomexp; }} } - if(!Preset::active_preset->isPerPixelEqn(ROT_OP)) + if(!this->activePreset->isPerPixelEqn(ROT_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->rot_mesh[x][y]=this->rot; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetOutputs.rot_mesh[x][y]=this->presetOutputs.rot; } } } /* - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->x_mesh[x][y]=(this->x_mesh[x][y]-.5)*2; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetInputs.x_mesh[x][y]=(this->presetInputs.x_mesh[x][y]-.5)*2; } } - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->y_mesh[x][y]=(this->y_mesh[x][y]-.5)*2; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetInputs.y_mesh[x][y]=(this->presetInputs.y_mesh[x][y]-.5)*2; } } */ - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - fZoom2 = powf( this->zoom_mesh[x][y], powf( this->zoomexp_mesh[x][y], this->rad_mesh[x][y]*2.0f - 1.0f)); + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + fZoom2 = powf( this->presetOutputs.zoom_mesh[x][y], powf( this->presetOutputs.zoomexp_mesh[x][y], this->presetInputs.rad_mesh[x][y]*2.0f - 1.0f)); fZoom2Inv = 1.0f/fZoom2; - this->x_mesh[x][y]= this->origx2[x][y]*0.5f*fZoom2Inv + 0.5f; - this->y_mesh[x][y]= this->origy2[x][y]*0.5f*fZoom2Inv + 0.5f; + this->presetInputs.x_mesh[x][y]= this->origx2[x][y]*0.5f*fZoom2Inv + 0.5f; + this->presetInputs.y_mesh[x][y]= this->origy2[x][y]*0.5f*fZoom2Inv + 0.5f; } } - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->x_mesh[x][y] = ( this->x_mesh[x][y] - this->cx_mesh[x][y])/this->sx_mesh[x][y] + this->cx_mesh[x][y]; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetInputs.x_mesh[x][y] = ( this->presetInputs.x_mesh[x][y] - this->presetOutputs.cx_mesh[x][y])/this->presetOutputs.sx_mesh[x][y] + this->presetOutputs.cx_mesh[x][y]; } } - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->y_mesh[x][y] = ( this->y_mesh[x][y] - this->cy_mesh[x][y])/this->sy_mesh[x][y] + this->cy_mesh[x][y]; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetInputs.y_mesh[x][y] = ( this->presetInputs.y_mesh[x][y] - this->presetOutputs.cy_mesh[x][y])/this->presetOutputs.sy_mesh[x][y] + this->presetOutputs.cy_mesh[x][y]; } } - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - float u2 = this->x_mesh[x][y] - this->cx_mesh[x][y]; - float v2 = this->y_mesh[x][y] - this->cy_mesh[x][y]; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + float u2 = this->presetInputs.x_mesh[x][y] - this->presetOutputs.cx_mesh[x][y]; + float v2 = this->presetInputs.y_mesh[x][y] - this->presetOutputs.cy_mesh[x][y]; - float cos_rot = cosf(this->rot_mesh[x][y]); - float sin_rot = sinf(this->rot_mesh[x][y]); + float cos_rot = cosf(this->presetOutputs.rot_mesh[x][y]); + float sin_rot = sinf(this->presetOutputs.rot_mesh[x][y]); - this->x_mesh[x][y] = u2*cos_rot - v2*sin_rot + this->cx_mesh[x][y]; - this->y_mesh[x][y] = u2*sin_rot + v2*cos_rot + this->cy_mesh[x][y]; + this->presetInputs.x_mesh[x][y] = u2*cos_rot - v2*sin_rot + this->presetOutputs.cx_mesh[x][y]; + this->presetInputs.y_mesh[x][y] = u2*sin_rot + v2*cos_rot + this->presetOutputs.cy_mesh[x][y]; } } - if(Preset::active_preset->isPerPixelEqn(DX_OP)) + if(this->activePreset->isPerPixelEqn(DX_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->x_mesh[x][y] -= this->dx_mesh[x][y]; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetInputs.x_mesh[x][y] -= this->presetOutputs.dx_mesh[x][y]; } } } - if(Preset::active_preset->isPerPixelEqn(DY_OP)) + if(this->activePreset->isPerPixelEqn(DY_OP)) { - for (x=0;xgx;x++){ - for(y=0;ygy;y++){ - this->y_mesh[x][y] -= this->dy_mesh[x][y]; + for (x=0;xpresetInputs.gx;x++){ + for(y=0;ypresetInputs.gy;y++){ + this->presetInputs.y_mesh[x][y] -= this->presetOutputs.dy_mesh[x][y]; } } @@ -867,47 +863,47 @@ void projectM::reset_per_pixel_matrices() { int x,y; /* - for (x=0;xgx;x++) + for (x=0;xpresetInputs.gx;x++) { - memcpy(this->x_mesh[x],this->origx[x],sizeof(float)*this->gy); + memcpy(this->presetInputs.x_mesh[x],this->origx[x],sizeof(float)*this->presetInputs.gy); } - for (x=0;xgx;x++) + for (x=0;xpresetInputs.gx;x++) { - memcpy(this->y_mesh[x],this->origy[x],sizeof(float)*this->gy); + memcpy(this->presetInputs.y_mesh[x],this->origy[x],sizeof(float)*this->presetInputs.gy); } - for (x=0;xgx;x++) + for (x=0;xpresetInputs.gx;x++) { - memcpy(this->rad_mesh[x],this->origrad[x],sizeof(float)*this->gy); + memcpy(this->presetInputs.rad_mesh[x],this->origrad[x],sizeof(float)*this->presetInputs.gy); } - for (x=0;xgx;x++) + for (x=0;xpresetInputs.gx;x++) { - memcpy(this->theta_mesh[x],this->origtheta[x],sizeof(float)*this->gy); + memcpy(this->presetInputs.theta_mesh[x],this->origtheta[x],sizeof(float)*this->presetInputs.gy); } */ - for (x=0;xgx;x++) + for (x=0;xpresetInputs.gx;x++) { - for(y=0;ygy;y++) + for(y=0;ypresetInputs.gy;y++) { - this->x_mesh[x][y]=this->origx[x][y]; - this->y_mesh[x][y]=this->origy[x][y]; - this->rad_mesh[x][y]=this->origrad[x][y]; - this->theta_mesh[x][y]=this->origtheta[x][y]; + this->presetInputs.x_mesh[x][y]=this->origx[x][y]; + this->presetInputs.y_mesh[x][y]=this->origy[x][y]; + this->presetInputs.rad_mesh[x][y]=this->origrad[x][y]; + this->presetInputs.theta_mesh[x][y]=this->origtheta[x][y]; } } - //memcpy(this->x_mesh,this->origx,sizeof(float)*this->gy*this->gx); - //memcpy(this->y_mesh,this->origy,sizeof(float)*this->gy*this->gx); - //memcpy(this->rad_mesh,this->origrad,sizeof(float)*this->gy*this->gx); - //memcpy(this->theta_mesh,this->origtheta,sizeof(float)*this->gy*this->gx); + //memcpy(this->presetInputs.x_mesh,this->origx,sizeof(float)*this->presetInputs.gy*this->presetInputs.gx); + //memcpy(this->presetInputs.y_mesh,this->origy,sizeof(float)*this->presetInputs.gy*this->presetInputs.gx); + //memcpy(this->presetInputs.rad_mesh,this->origrad,sizeof(float)*this->presetInputs.gy*this->presetInputs.gx); + //memcpy(this->presetInputs.theta_mesh,this->origtheta,sizeof(float)*this->presetInputs.gy*this->presetInputs.gx); } void projectM::rescale_per_pixel_matrices() { int x, y; - for ( x = 0 ; x < this->gx ; x++ ) { - for ( y = 0 ; y < this->gy ; y++ ) { + for ( x = 0 ; x < this->presetInputs.gx ; x++ ) { + for ( y = 0 ; y < this->presetInputs.gy ; y++ ) { this->gridx[x][y]=this->origx[x][y]; this->gridy[x][y]=this->origy[x][y]; @@ -926,7 +922,7 @@ void projectM::draw_custom_waves() { glPointSize(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); - while ((wavecode = Preset::active_preset->nextCustomWave()) != NULL) + while ((wavecode = this->activePreset->nextCustomWave()) != NULL) { if(wavecode->enabled==1) @@ -941,7 +937,7 @@ void projectM::draw_custom_waves() { // printf("%f\n",pcmL[0]); - float mult=wavecode->scaling*this->fWaveScale*(wavecode->bSpectrum ? 0.015f :1.0f); + float mult=wavecode->scaling*this->presetOutputs.fWaveScale*(wavecode->bSpectrum ? 0.015f :1.0f); for(x=0;xsamples;x++) {wavecode->value1[x]*=mult;} @@ -1023,7 +1019,7 @@ void projectM::draw_shapes() { glPushMatrix(); glTranslatef( 0, 0, -1 ); - while ((shapecode = Preset::active_preset->nextCustomShape()) != NULL) + while ((shapecode = this->activePreset->nextCustomShape()) != NULL) { if(shapecode->enabled==1) @@ -1128,7 +1124,7 @@ void projectM::draw_shapes() { } - if (this->bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); + if (this->presetOutputs.bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); glBegin(GL_LINE_LOOP); glColor4f(shapecode->border_r,shapecode->border_g,shapecode->border_b,shapecode->border_a); for ( i=1;isides+1;i++) @@ -1141,7 +1137,7 @@ void projectM::draw_shapes() { //glVertex3f(shapecode->radius*cos(theta)+xval,shapecode->radius*sin(theta)+yval,-1); } glEnd(); - if (this->bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); + if (this->presetOutputs.bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); glPopMatrix(); } @@ -1169,7 +1165,7 @@ void projectM::draw_waveform() { float cos_rot; float sin_rot; - DWRITE( "draw_waveform: %d\n", this->nWaveMode ); + DWRITE( "draw_waveform: %d\n", this->presetOutputs.nWaveMode ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); @@ -1177,28 +1173,28 @@ void projectM::draw_waveform() { modulate_opacity_by_volume(); maximize_colors(); - if(this->bWaveDots==1) glEnable(GL_LINE_STIPPLE); + if(this->presetOutputs.bWaveDots==1) glEnable(GL_LINE_STIPPLE); - offset=this->wave_x-.5; + offset=this->presetOutputs.wave_x-.5; scale=505.0/512.0; //Thick wave drawing - if (this->bWaveThick==1) glLineWidth( (this->renderTarget->texsize < 512 ) ? 2 : 2*this->renderTarget->texsize/512); + if (this->presetOutputs.bWaveThick==1) glLineWidth( (this->renderTarget->texsize < 512 ) ? 2 : 2*this->renderTarget->texsize/512); //Additive wave drawing (vice overwrite) - if (this->bAdditiveWaves==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (this->presetOutputs.bAdditiveWaves==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else glBlendFunc(GL_SRC_ALPHA, GL_ONE); - switch(this->nWaveMode) + switch(this->presetOutputs.nWaveMode) { case 8://monitor glTranslatef(0.5,0.5, 0); - glRotated(-this->wave_mystery*90,0,0,1); + glRotated(-this->presetOutputs.wave_mystery*90,0,0,1); glTranslatef(-0.5,-0.825, 0); glTranslatef( 0, 0, -1 ); @@ -1208,11 +1204,11 @@ void projectM::draw_waveform() { { glBegin(GL_LINE_STRIP); glColor4f(1.0-(x/15.0),.5,x/15.0,1.0); - glVertex3f((this->totalframes%256)*2*scale, -this->beat_val[x]*this->fWaveScale+renderTarget->texsize*wave_y,-1); + glVertex3f((this->totalframes%256)*2*scale, -this->beat_val[x]*this->presetOutputs.fWaveScale+renderTarget->texsize*wave_y,-1); glColor4f(.5,.5,.5,1.0); - glVertex3f((this->totalframes%256)*2*scale, this->renderTarget->texsize*this->wave_y,-1); + glVertex3f((this->totalframes%256)*2*scale, this->renderTarget->texsize*this->presetOutputs.wave_y,-1); glColor4f(1.0,1.0,0,1.0); - //glVertex3f((this->totalframes%256)*scale*2, this->beat_val_att[x]*this->fWaveScale+this->renderTarget->texsize*this->wave_y,-1); + //glVertex3f((this->totalframes%256)*scale*2, this->beat_val_att[x]*this->presetOutputs.fWaveScale+this->renderTarget->texsize*this->presetOutputs.wave_y,-1); glEnd(); glTranslatef(0,this->renderTarget->texsize*(1/36.0), 0); @@ -1224,32 +1220,32 @@ void projectM::draw_waveform() { glBegin(GL_LINE_STRIP); glColor4f(1.0,1.0,0.5,1.0); - glVertex2f((this->totalframes%256)*2*scale, beatDetect->treb_att*5*this->fWaveScale+this->wave_y); + glVertex2f((this->totalframes%256)*2*scale, beatDetect->treb_att*5*this->presetOutputs.fWaveScale+this->presetOutputs.wave_y); glColor4f(.2,.2,.2,1.0); - glVertex2f((this->totalframes%256)*2*scale, this->wave_y); + glVertex2f((this->totalframes%256)*2*scale, this->presetOutputs.wave_y); glColor4f(1.0,1.0,0,1.0); - glVertex2f((this->totalframes%256)*scale*2, beatDetect->treb*-5*this->fWaveScale+this->wave_y); + glVertex2f((this->totalframes%256)*scale*2, beatDetect->treb*-5*this->presetOutputs.fWaveScale+this->presetOutputs.wave_y); glEnd(); glTranslatef(0,.075, 0); glBegin(GL_LINE_STRIP); glColor4f(0,1.0,0.0,1.0); - glVertex2f((this->totalframes%256)*2*scale, beatDetect->mid_att*5*this->fWaveScale+this->wave_y); + glVertex2f((this->totalframes%256)*2*scale, beatDetect->mid_att*5*this->presetOutputs.fWaveScale+this->presetOutputs.wave_y); glColor4f(.2,.2,.2,1.0); - glVertex2f((this->totalframes%256)*2*scale, this->wave_y); + glVertex2f((this->totalframes%256)*2*scale, this->presetOutputs.wave_y); glColor4f(.5,1.0,.5,1.0); - glVertex2f((this->totalframes%256)*scale*2, beatDetect->mid*-5*this->fWaveScale+this->wave_y); + glVertex2f((this->totalframes%256)*scale*2, beatDetect->mid*-5*this->presetOutputs.fWaveScale+this->presetOutputs.wave_y); glEnd(); glTranslatef(0,.075, 0); glBegin(GL_LINE_STRIP); glColor4f(1.0,0,0,1.0); - glVertex2f((this->totalframes%256)*2*scale, beatDetect->bass_att*5*this->fWaveScale+this->wave_y); + glVertex2f((this->totalframes%256)*2*scale, beatDetect->bass_att*5*this->presetOutputs.fWaveScale+this->presetOutputs.wave_y); glColor4f(.2,.2,.2,1.0); - glVertex2f((this->totalframes%256)*2*scale, this->wave_y); + glVertex2f((this->totalframes%256)*2*scale, this->presetOutputs.wave_y); glColor4f(1.0,.5,.5,1.0); - glVertex2f((this->totalframes%256)*scale*2, beatDetect->bass*-5*this->fWaveScale+this->wave_y); + glVertex2f((this->totalframes%256)*scale*2, beatDetect->bass*-5*this->presetOutputs.fWaveScale+this->presetOutputs.wave_y); glEnd(); break; @@ -1268,7 +1264,7 @@ void projectM::draw_waveform() { glTranslatef( 0, 0, -1 ); - this->wave_y=-1*(this->wave_y-1.0); + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); glBegin(GL_LINE_STRIP); @@ -1279,29 +1275,29 @@ void projectM::draw_waveform() { //co= -(fabs(x-((beatDetect->pcm->numsamples*.5)-1))/beatDetect->pcm->numsamples)+1; // printf("%d %f\n",x,co); //theta=x*(6.28/beatDetect->pcm->numsamples); - //r= ((1+2*this->wave_mystery)*(this->renderTarget->texsize/5.0)+ + //r= ((1+2*this->presetOutputs.wave_mystery)*(this->renderTarget->texsize/5.0)+ // ( co*beatDetect->pcm->pcmdataL[x]+ (1-co)*beatDetect->pcm->pcmdataL[-(x-(beatDetect->pcm->numsamples-1))]) - // *25*this->fWaveScale); - r=(0.5 + 0.4f*.12*beatDetect->pcm->pcmdataR[x]*this->fWaveScale + this->wave_mystery)*.5; + // *25*this->presetOutputs.fWaveScale); + r=(0.5 + 0.4f*.12*beatDetect->pcm->pcmdataR[x]*this->presetOutputs.fWaveScale + this->presetOutputs.wave_mystery)*.5; theta=(x)*inv_nverts_minus_one*6.28f + this->Time*0.2f; /* if (x < 51) { float mix = x/51.0; mix = 0.5f - 0.5f*cosf(mix * 3.1416f); - float rad_2 = 0.5f + 0.4f*.12*beatDetect->pcm->pcmdataR[x]*this->fWaveScale + this->wave_mystery; + float rad_2 = 0.5f + 0.4f*.12*beatDetect->pcm->pcmdataR[x]*this->presetOutputs.fWaveScale + this->presetOutputs.wave_mystery; r = rad_2*(1.0f-mix) + r*(mix); } */ - glVertex2f((r*cos(theta)*(this->correction ? this->aspect : 1.0)+this->wave_x), (r*sin(theta)+this->wave_y)); + glVertex2f((r*cos(theta)*(this->correction ? this->aspect : 1.0)+this->presetOutputs.wave_x), (r*sin(theta)+this->presetOutputs.wave_y)); } - // r= ( (1+2*this->wave_mystery)*(this->renderTarget->texsize/5.0)+ + // r= ( (1+2*this->presetOutputs.wave_mystery)*(this->renderTarget->texsize/5.0)+ // (0.5*beatDetect->pcm->pcmdataL[0]+ 0.5*beatDetect->pcm->pcmdataL[beatDetect->pcm->numsamples-1]) - // *20*this->fWaveScale); + // *20*this->presetOutputs.fWaveScale); - //glVertex3f(r*cos(0)+(this->wave_x*this->renderTarget->texsize),r*sin(0)+(this->wave_y*this->renderTarget->texsize),-1); + //glVertex3f(r*cos(0)+(this->presetOutputs.wave_x*this->renderTarget->texsize),r*sin(0)+(this->presetOutputs.wave_y*this->renderTarget->texsize),-1); glEnd(); /* @@ -1310,9 +1306,9 @@ void projectM::draw_waveform() { for ( x=0;x<(512/pcmbreak);x++) { theta=(blockstart+x)*((6.28*pcmbreak)/512.0); - r= ((1+2*this->wave_mystery)*(this->renderTarget->texsize/5.0)+fdata_buffer[fbuffer][0][blockstart+x]*.0025*this->fWaveScale); + r= ((1+2*this->presetOutputs.wave_mystery)*(this->renderTarget->texsize/5.0)+fdata_buffer[fbuffer][0][blockstart+x]*.0025*this->presetOutputs.fWaveScale); - glVertex3f(r*cos(theta)+(this->wave_x*this->renderTarget->texsize),r*sin(theta)+(wave_y*this->renderTarget->texsize),-1); + glVertex3f(r*cos(theta)+(this->presetOutputs.wave_x*this->renderTarget->texsize),r*sin(theta)+(wave_y*this->renderTarget->texsize),-1); } glEnd(); */ @@ -1328,7 +1324,7 @@ void projectM::draw_waveform() { glTranslatef((-.5) ,(-.5),0); glTranslatef( 0, 0, -1 ); - this->wave_y=-1*(this->wave_y-1.0); + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); glBegin(GL_LINE_STRIP); //theta=(frame%512)*(6.28/512.0); @@ -1337,20 +1333,20 @@ void projectM::draw_waveform() { { //co= -(abs(x-255)/512.0)+1; // printf("%d %f\n",x,co); - //theta=((this->frame%256)*(2*6.28/512.0))+beatDetect->pcm->pcmdataL[x]*.2*this->fWaveScale; - //r= ((1+2*this->wave_mystery)*(this->renderTarget->texsize/5.0)+ - // (beatDetect->pcm->pcmdataL[x]-beatDetect->pcm->pcmdataL[x-1])*80*this->fWaveScale); - theta=beatDetect->pcm->pcmdataL[x+32]*0.06*this->fWaveScale * 1.57 + this->Time*2.3; - r=(0.53 + 0.43*beatDetect->pcm->pcmdataR[x]*0.12*this->fWaveScale+ this->wave_mystery)*.5; + //theta=((this->frame%256)*(2*6.28/512.0))+beatDetect->pcm->pcmdataL[x]*.2*this->presetOutputs.fWaveScale; + //r= ((1+2*this->presetOutputs.wave_mystery)*(this->renderTarget->texsize/5.0)+ + // (beatDetect->pcm->pcmdataL[x]-beatDetect->pcm->pcmdataL[x-1])*80*this->presetOutputs.fWaveScale); + theta=beatDetect->pcm->pcmdataL[x+32]*0.06*this->presetOutputs.fWaveScale * 1.57 + this->Time*2.3; + r=(0.53 + 0.43*beatDetect->pcm->pcmdataR[x]*0.12*this->presetOutputs.fWaveScale+ this->presetOutputs.wave_mystery)*.5; - glVertex2f((r*cos(theta)*(this->correction ? this->aspect : 1.0)+this->wave_x),(r*sin(theta)+this->wave_y)); + glVertex2f((r*cos(theta)*(this->correction ? this->aspect : 1.0)+this->presetOutputs.wave_x),(r*sin(theta)+this->presetOutputs.wave_y)); } glEnd(); /* - this->wave_y=-1*(this->wave_y-1.0); - wave_x_temp=(this->wave_x*.75)+.125; + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); + wave_x_temp=(this->presetOutputs.wave_x*.75)+.125; wave_x_temp=-(wave_x_temp-1); glBegin(GL_LINE_STRIP); @@ -1359,9 +1355,9 @@ void projectM::draw_waveform() { for (x=0; x<512-32; x++) { - float rad = (.53 + 0.43*beatDetect->pcm->pcmdataR[x]) + this->wave_mystery; + float rad = (.53 + 0.43*beatDetect->pcm->pcmdataR[x]) + this->presetOutputs.wave_mystery; float ang = beatDetect->pcm->pcmdataL[x+32] * 1.57f + this->Time*2.3f; - glVertex3f((rad*cosf(ang)*.2*scale*this->fWaveScale + wave_x_temp)*this->renderTarget->texsize,(rad*sinf(ang)*this->fWaveScale*.2*scale + this->wave_y)*this->renderTarget->texsize,-1); + glVertex3f((rad*cosf(ang)*.2*scale*this->presetOutputs.fWaveScale + wave_x_temp)*this->renderTarget->texsize,(rad*sinf(ang)*this->presetOutputs.fWaveScale*.2*scale + this->presetOutputs.wave_y)*this->renderTarget->texsize,-1); } glEnd(); @@ -1372,7 +1368,7 @@ void projectM::draw_waveform() { case 2://EXPERIMENTAL glTranslatef( 0, 0, -1 ); - this->wave_y=-1*(this->wave_y-1.0); + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); glBegin(GL_LINE_STRIP); @@ -1380,7 +1376,7 @@ void projectM::draw_waveform() { for (x=0; x<512-32; x++) { - glVertex2f((beatDetect->pcm->pcmdataR[x]*this->fWaveScale*0.5*(this->correction ? this->aspect : 1.0) + this->wave_x),( (beatDetect->pcm->pcmdataL[x+32]*this->fWaveScale*0.5 + this->wave_y))); + glVertex2f((beatDetect->pcm->pcmdataR[x]*this->presetOutputs.fWaveScale*0.5*(this->correction ? this->aspect : 1.0) + this->presetOutputs.wave_x),( (beatDetect->pcm->pcmdataL[x+32]*this->presetOutputs.fWaveScale*0.5 + this->presetOutputs.wave_y))); } glEnd(); @@ -1389,8 +1385,8 @@ void projectM::draw_waveform() { case 3://EXPERIMENTAL glTranslatef( 0, 0, -9 ); - this->wave_y=-1*(this->wave_y-1.0); - //wave_x_temp=(this->wave_x*.75)+.125; + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); + //wave_x_temp=(this->presetOutputs.wave_x*.75)+.125; //wave_x_temp=-(wave_x_temp-1); @@ -1400,7 +1396,7 @@ void projectM::draw_waveform() { for (x=0; x<512-32; x++) { - glVertex2f((beatDetect->pcm->pcmdataR[x] * this->fWaveScale*0.5 + this->wave_x),( (beatDetect->pcm->pcmdataL[x+32]*this->fWaveScale*0.5 + this->wave_y))); + glVertex2f((beatDetect->pcm->pcmdataR[x] * this->presetOutputs.fWaveScale*0.5 + this->presetOutputs.wave_x),( (beatDetect->pcm->pcmdataL[x+32]*this->presetOutputs.fWaveScale*0.5 + this->presetOutputs.wave_y))); } glEnd(); @@ -1409,22 +1405,22 @@ void projectM::draw_waveform() { case 4://single x-axis derivative waveform { - this->wave_y=-1*(this->wave_y-1.0); + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); glTranslatef(.5,.5, 0); - glRotated(-this->wave_mystery*90,0,0,1); + glRotated(-this->presetOutputs.wave_mystery*90,0,0,1); glTranslatef(-.5,-.5, 0); glTranslatef( 0, 0, -1 ); - float w1 = 0.45f + 0.5f*(this->wave_mystery*0.5f + 0.5f); + float w1 = 0.45f + 0.5f*(this->presetOutputs.wave_mystery*0.5f + 0.5f); float w2 = 1.0f - w1; float xx[512],yy[512]; glBegin(GL_LINE_STRIP); for (int i=0; i<512; i++) { - xx[i] = -1.0f + 2.0f*(i/512.0) + this->wave_x; - yy[i] =0.4* beatDetect->pcm->pcmdataL[i]*0.47f*this->fWaveScale + this->wave_y; - xx[i] += 0.4*beatDetect->pcm->pcmdataR[i]*0.44f*this->fWaveScale; + xx[i] = -1.0f + 2.0f*(i/512.0) + this->presetOutputs.wave_x; + yy[i] =0.4* beatDetect->pcm->pcmdataL[i]*0.47f*this->presetOutputs.fWaveScale + this->presetOutputs.wave_y; + xx[i] += 0.4*beatDetect->pcm->pcmdataR[i]*0.44f*this->presetOutputs.fWaveScale; if (i>1) { @@ -1437,14 +1433,14 @@ void projectM::draw_waveform() { glEnd(); /* - this->wave_x=(this->wave_x*.75)+.125; - this->wave_x=-(this->wave_x-1); + this->presetOutputs.wave_x=(this->presetOutputs.wave_x*.75)+.125; + this->presetOutputs.wave_x=-(this->presetOutputs.wave_x-1); glBegin(GL_LINE_STRIP); for ( x=1;x<512;x++) { - dy_adj= beatDetect->pcm->pcmdataL[x]*20*this->fWaveScale-beatDetect->pcm->pcmdataL[x-1]*20*this->fWaveScale; - glVertex3f((x*(this->renderTarget->texsize/512))+dy_adj, beatDetect->pcm->pcmdataL[x]*20*this->fWaveScale+this->renderTarget->texsize*this->wave_x,-1); + dy_adj= beatDetect->pcm->pcmdataL[x]*20*this->presetOutputs.fWaveScale-beatDetect->pcm->pcmdataL[x-1]*20*this->presetOutputs.fWaveScale; + glVertex3f((x*(this->renderTarget->texsize/512))+dy_adj, beatDetect->pcm->pcmdataL[x]*20*this->presetOutputs.fWaveScale+this->renderTarget->texsize*this->presetOutputs.wave_x,-1); } glEnd(); */ @@ -1455,7 +1451,7 @@ void projectM::draw_waveform() { glTranslatef( 0, 0, -5 ); - this->wave_y=-1*(this->wave_y-1.0); + this->presetOutputs.wave_y=-1*(this->presetOutputs.wave_y-1.0); cos_rot = cosf(this->Time*0.3f); sin_rot = sinf(this->Time*0.3f); @@ -1467,7 +1463,7 @@ void projectM::draw_waveform() { float x0 = (beatDetect->pcm->pcmdataR[x]*beatDetect->pcm->pcmdataL[x+32] + beatDetect->pcm->pcmdataL[x+32]*beatDetect->pcm->pcmdataR[x]); float y0 = (beatDetect->pcm->pcmdataR[x]*beatDetect->pcm->pcmdataR[x] - beatDetect->pcm->pcmdataL[x+32]*beatDetect->pcm->pcmdataL[x+32]); - glVertex2f(((x0*cos_rot - y0*sin_rot)*this->fWaveScale*0.5*(this->correction ? this->aspect : 1.0) + this->wave_x),( (x0*sin_rot + y0*cos_rot)*this->fWaveScale*0.5 + this->wave_y)); + glVertex2f(((x0*cos_rot - y0*sin_rot)*this->presetOutputs.fWaveScale*0.5*(this->correction ? this->aspect : 1.0) + this->presetOutputs.wave_x),( (x0*sin_rot + y0*cos_rot)*this->presetOutputs.fWaveScale*0.5 + this->presetOutputs.wave_y)); } glEnd(); @@ -1482,13 +1478,13 @@ void projectM::draw_waveform() { // glLoadIdentity(); glTranslatef(.5,.5, 0); - glRotated(-this->wave_mystery*90,0,0,1); + glRotated(-this->presetOutputs.wave_mystery*90,0,0,1); glTranslatef(0,0, -1); - wave_x_temp=-2*0.4142*(fabs(fabs(this->wave_mystery)-.5)-.5); + wave_x_temp=-2*0.4142*(fabs(fabs(this->presetOutputs.wave_mystery)-.5)-.5); glScalef(1.0+wave_x_temp,1.0,1.0); glTranslatef(-.5,-.5, 0); - wave_x_temp=-1*(this->wave_x-1.0); + wave_x_temp=-1*(this->presetOutputs.wave_x-1.0); glBegin(GL_LINE_STRIP); // wave_x_temp=(wave_x*.75)+.125; @@ -1497,7 +1493,7 @@ void projectM::draw_waveform() { { //glVertex3f(x*scale, fdata_buffer[fbuffer][0][blockstart+x]*.0012*fWaveScale+renderTarget->texsize*wave_x_temp,-1); - glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataR[x]*.04*this->fWaveScale+wave_x_temp); + glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataR[x]*.04*this->presetOutputs.fWaveScale+wave_x_temp); //glVertex3f(x*scale, renderTarget->texsize*wave_y_temp,-1); } @@ -1508,21 +1504,21 @@ void projectM::draw_waveform() { case 7://dual waveforms glTranslatef(.5,.5, 0); - glRotated(-this->wave_mystery*90,0,0,1); + glRotated(-this->presetOutputs.wave_mystery*90,0,0,1); - wave_x_temp=-2*0.4142*(fabs(fabs(this->wave_mystery)-.5)-.5); + wave_x_temp=-2*0.4142*(fabs(fabs(this->presetOutputs.wave_mystery)-.5)-.5); glScalef(1.0+wave_x_temp,1.0,1.0); glTranslatef(-.5,-.5, -1); glTranslatef( 0, 0, -1 ); - wave_y_temp=-1*(this->wave_x-1); + wave_y_temp=-1*(this->presetOutputs.wave_x-1); glBegin(GL_LINE_STRIP); for ( x=0;xpcm->numsamples;x++) { - glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataL[x]*.04*this->fWaveScale+(wave_y_temp+(this->wave_y*this->wave_y*.5))); + glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataL[x]*.04*this->presetOutputs.fWaveScale+(wave_y_temp+(this->presetOutputs.wave_y*this->presetOutputs.wave_y*.5))); } glEnd(); @@ -1532,7 +1528,7 @@ void projectM::draw_waveform() { for ( x=0;xpcm->numsamples;x++) { - glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataR[x]*.04*this->fWaveScale+(wave_y_temp-(this->wave_y*this->wave_y*.5))); + glVertex2f(x/(float)beatDetect->pcm->numsamples, beatDetect->pcm->pcmdataR[x]*.04*this->presetOutputs.fWaveScale+(wave_y_temp-(this->presetOutputs.wave_y*this->presetOutputs.wave_y*.5))); } glEnd(); glPopMatrix(); @@ -1547,7 +1543,7 @@ void projectM::draw_waveform() { theta=(x)*(6.28/512.0); r= (0.2+beatDetect->pcm->pcmdataL[x]*.002); - glVertex2f(r*cos(theta)+this->wave_x,r*sin(theta)+this->wave_y); + glVertex2f(r*cos(theta)+this->presetOutputs.wave_x,r*sin(theta)+this->presetOutputs.wave_y); } glEnd(); @@ -1555,7 +1551,7 @@ glBegin(GL_LINE_STRIP); for ( x=0;x<512;x++) { - glVertex3f(x*scale, beatDetect->pcm->pcmdataL[x]*.04*this->fWaveScale+((this->wave_x+.1)),-1); + glVertex3f(x*scale, beatDetect->pcm->pcmdataL[x]*.04*this->presetOutputs.fWaveScale+((this->presetOutputs.wave_x+.1)),-1); } glEnd(); @@ -1563,12 +1559,12 @@ glBegin(GL_LINE_STRIP); for ( x=0;x<512;x++) { - glVertex3f(x*scale, beatDetect->pcm->pcmdataR[x]*.04*this->fWaveScale+((this->wave_x-.1)),-1); + glVertex3f(x*scale, beatDetect->pcm->pcmdataR[x]*.04*this->presetOutputs.fWaveScale+((this->presetOutputs.wave_x-.1)),-1); } glEnd(); break; - if (this->bWaveThick==1) glLineWidth( (this->renderTarget->texsize < 512) ? 1 : 2*this->renderTarget->texsize/512); + if (this->presetOutputs.bWaveThick==1) glLineWidth( (this->renderTarget->texsize < 512) ? 1 : 2*this->renderTarget->texsize/512); } glLineWidth( this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); glDisable(GL_LINE_STIPPLE); @@ -1583,59 +1579,59 @@ void projectM::maximize_colors() { // //forces max color value to 1.0 and scales // the rest accordingly - if(this->nWaveMode==2 || this->nWaveMode==5) + if(this->presetOutputs.nWaveMode==2 || this->presetOutputs.nWaveMode==5) { switch(this->renderTarget->texsize) { - case 256: this->wave_o *= 0.07f; break; - case 512: this->wave_o *= 0.09f; break; - case 1024: this->wave_o *= 0.11f; break; - case 2048: this->wave_o *= 0.13f; break; + case 256: this->presetOutputs.wave_o *= 0.07f; break; + case 512: this->presetOutputs.wave_o *= 0.09f; break; + case 1024: this->presetOutputs.wave_o *= 0.11f; break; + case 2048: this->presetOutputs.wave_o *= 0.13f; break; } } - else if(this->nWaveMode==3) + else if(this->presetOutputs.nWaveMode==3) { switch(this->renderTarget->texsize) { - case 256: this->wave_o *= 0.075f; break; - case 512: this->wave_o *= 0.15f; break; - case 1024: this->wave_o *= 0.22f; break; - case 2048: this->wave_o *= 0.33f; break; + case 256: this->presetOutputs.wave_o *= 0.075f; break; + case 512: this->presetOutputs.wave_o *= 0.15f; break; + case 1024: this->presetOutputs.wave_o *= 0.22f; break; + case 2048: this->presetOutputs.wave_o *= 0.33f; break; } - this->wave_o*=1.3f; - this->wave_o*=powf(beatDetect->treb ,2.0f); + this->presetOutputs.wave_o*=1.3f; + this->presetOutputs.wave_o*=powf(beatDetect->treb ,2.0f); } - if (this->bMaximizeWaveColor==1) + if (this->presetOutputs.bMaximizeWaveColor==1) { - if(this->wave_r>=this->wave_g && this->wave_r>=this->wave_b) //red brightest + if(this->presetOutputs.wave_r>=this->presetOutputs.wave_g && this->presetOutputs.wave_r>=this->presetOutputs.wave_b) //red brightest { - wave_b_switch=this->wave_b*(1/this->wave_r); - wave_g_switch=this->wave_g*(1/this->wave_r); + wave_b_switch=this->presetOutputs.wave_b*(1/this->presetOutputs.wave_r); + wave_g_switch=this->presetOutputs.wave_g*(1/this->presetOutputs.wave_r); wave_r_switch=1.0; } - else if (this->wave_b>=this->wave_g && this->wave_b>=this->wave_r) //blue brightest + else if (this->presetOutputs.wave_b>=this->presetOutputs.wave_g && this->presetOutputs.wave_b>=this->presetOutputs.wave_r) //blue brightest { - wave_r_switch=this->wave_r*(1/this->wave_b); - wave_g_switch=this->wave_g*(1/this->wave_b); + wave_r_switch=this->presetOutputs.wave_r*(1/this->presetOutputs.wave_b); + wave_g_switch=this->presetOutputs.wave_g*(1/this->presetOutputs.wave_b); wave_b_switch=1.0; } - else if (this->wave_g>=this->wave_b && this->wave_g>=this->wave_r) //green brightest + else if (this->presetOutputs.wave_g>=this->presetOutputs.wave_b && this->presetOutputs.wave_g>=this->presetOutputs.wave_r) //green brightest { - wave_b_switch=this->wave_b*(1/this->wave_g); - wave_r_switch=this->wave_r*(1/this->wave_g); + wave_b_switch=this->presetOutputs.wave_b*(1/this->presetOutputs.wave_g); + wave_r_switch=this->presetOutputs.wave_r*(1/this->presetOutputs.wave_g); wave_g_switch=1.0; } - glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, this->wave_o); + glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, this->presetOutputs.wave_o); } else { - glColor4f(this->wave_r, this->wave_g, this->wave_b, this->wave_o); + glColor4f(this->presetOutputs.wave_r, this->presetOutputs.wave_g, this->presetOutputs.wave_b, this->presetOutputs.wave_o); } } @@ -1650,33 +1646,33 @@ void projectM::modulate_opacity_by_volume() { //based on current volume - if (this->bModWaveAlphaByVolume==1) - {if (beatDetect->vol<=this->fModWaveAlphaStart) this->wave_o=0.0; - else if (beatDetect->vol>=this->fModWaveAlphaEnd) this->wave_o=this->fWaveAlpha; - else this->wave_o=this->fWaveAlpha*((beatDetect->vol-this->fModWaveAlphaStart)/(this->fModWaveAlphaEnd-this->fModWaveAlphaStart));} - else this->wave_o=this->fWaveAlpha; + if (this->presetOutputs.bModWaveAlphaByVolume==1) + {if (beatDetect->vol<=this->presetOutputs.fModWaveAlphaStart) this->presetOutputs.wave_o=0.0; + else if (beatDetect->vol>=this->presetOutputs.fModWaveAlphaEnd) this->presetOutputs.wave_o=this->presetOutputs.fWaveAlpha; + else this->presetOutputs.wave_o=this->presetOutputs.fWaveAlpha*((beatDetect->vol-this->presetOutputs.fModWaveAlphaStart)/(this->presetOutputs.fModWaveAlphaEnd-this->presetOutputs.fModWaveAlphaStart));} + else this->presetOutputs.wave_o=this->presetOutputs.fWaveAlpha; } void projectM::draw_motion_vectors() { int x,y; - float offsetx=this->mv_dx, intervalx=1.0/(float)this->mv_x; - float offsety=this->mv_dy, intervaly=1.0/(float)this->mv_y; + float offsetx=this->presetOutputs.mv_dx, intervalx=1.0/(float)this->presetOutputs.mv_x; + float offsety=this->presetOutputs.mv_dy, intervaly=1.0/(float)this->presetOutputs.mv_y; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPointSize(this->mv_l); - glColor4f(this->mv_r, this->mv_g, this->mv_b, this->mv_a); + glPointSize(this->presetOutputs.mv_l); + glColor4f(this->presetOutputs.mv_r, this->presetOutputs.mv_g, this->presetOutputs.mv_b, this->presetOutputs.mv_a); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef( 0, 0, -1 ); glBegin(GL_POINTS); - for (x=0;xmv_x;x++){ - for(y=0;ymv_y;y++){ + for (x=0;xpresetOutputs.mv_x;x++){ + for(y=0;ypresetOutputs.mv_y;y++){ float lx, ly, lz; lx = offsetx+x*intervalx; ly = offsety+y*intervaly; @@ -1694,14 +1690,14 @@ void projectM::draw_motion_vectors() { void projectM::draw_borders() { //Draw Borders - float of=this->ob_size*.5; - float iff=this->ib_size*.5; + float of=this->presetOutputs.ob_size*.5; + float iff=this->presetOutputs.ib_size*.5; float texof=1.0-of; //no additive drawing for borders glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4d(this->ob_r,this->ob_g,this->ob_b,this->ob_a); + glColor4d(this->presetOutputs.ob_r,this->presetOutputs.ob_g,this->presetOutputs.ob_b,this->presetOutputs.ob_a); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); @@ -1711,7 +1707,7 @@ void projectM::draw_borders() { glRectd(of,0,texof,of); glRectd(texof,0,1,1); glRectd(of,1,texof,texof); - glColor4d(this->ib_r,this->ib_g,this->ib_b,this->ib_a); + glColor4d(this->presetOutputs.ib_r,this->presetOutputs.ib_g,this->presetOutputs.ib_b,this->presetOutputs.ib_a); glRectd(of,of,of+iff,texof); glRectd(of+iff,of,texof-iff,of+iff); glRectd(texof-iff,of,texof,texof); @@ -1927,7 +1923,7 @@ sprintf( buffer, " (%f)", this->aspect); other_font->Render((this->renderTarget->usePbuffers ? " FBO: on" : " FBO: off")); glRasterPos2f(0, -.21+offset); - sprintf( buffer, " mesh: %d x %d", this->gx,this->gy); + sprintf( buffer, " mesh: %d x %d", this->presetInputs.gx,this->presetInputs.gy); other_font->Render(buffer); @@ -1967,7 +1963,7 @@ void projectM::render_interpolation() { // glLoadIdentity(); glTranslated( 0, 0, -1 ); - glColor4f(0.0, 0.0, 0.0,this->decay); + glColor4f(0.0, 0.0, 0.0,this->presetOutputs.decay); glEnable(GL_TEXTURE_2D); //glBindTexture( GL_TEXTURE_2D, this->renderTarget->textureID[0] ); @@ -1985,12 +1981,12 @@ void projectM::render_interpolation() { } #endif - for (x=0;xgx - 1;x++){ + for (x=0;xpresetInputs.gx - 1;x++){ glBegin(GL_TRIANGLE_STRIP); - for(y=0;ygy;y++){ - glTexCoord2f(this->x_mesh[x][y], this->y_mesh[x][y]); + for(y=0;ypresetInputs.gy;y++){ + glTexCoord2f(this->presetInputs.x_mesh[x][y], this->presetInputs.y_mesh[x][y]); glVertex2f(this->gridx[x][y], this->gridy[x][y]); - glTexCoord2f(this->x_mesh[x+1][y], this->y_mesh[x+1][y]); + glTexCoord2f(this->presetInputs.x_mesh[x+1][y], this->presetInputs.y_mesh[x+1][y]); glVertex2f(this->gridx[x+1][y], this->gridy[x+1][y]); } glEnd(); @@ -2015,7 +2011,7 @@ void projectM::do_per_frame() { glTranslated(0, 0, -9); //Texture wrapping( clamp vs. wrap) - if (this->bTexWrap==0){ + if (this->presetOutputs.bTexWrap==0){ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);} else{ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -2037,22 +2033,22 @@ void projectM::do_per_frame() { glLoadIdentity(); /* - glTranslatef(this->cx,this->cy, 0); + glTranslatef(this->presetOutputs.cx,this->presetOutputs.cy, 0); if(this->correction) glScalef(1,this->vw/(float)this->vh,1); if(!isPerPixelEqn(ROT_OP)) { // printf("ROTATING: rot = %f\n", rot); - glRotatef(this->rot*90, 0, 0, 1); + glRotatef(this->presetOutputs.rot*90, 0, 0, 1); } - if(!isPerPixelEqn(SX_OP)) glScalef(1/this->sx,1,1); - if(!isPerPixelEqn(SY_OP)) glScalef(1,1/this->sy,1); + if(!isPerPixelEqn(SX_OP)) glScalef(1/this->presetOutputs.sx,1,1); + if(!isPerPixelEqn(SY_OP)) glScalef(1,1/this->presetOutputs.sy,1); if(this->correction)glScalef(1,this->vh/(float)this->vw,1); - glTranslatef((-this->cx) ,(-this->cy),0); + glTranslatef((-this->presetOutputs.cx) ,(-this->presetOutputs.cy),0); */ - if(!Preset::active_preset->isPerPixelEqn(DX_OP)) glTranslatef(-this->dx,0,0); - if(!Preset::active_preset->isPerPixelEqn(DY_OP)) glTranslatef(0 ,-this->dy,0); + if(!this->activePreset->isPerPixelEqn(DX_OP)) glTranslatef(-this->presetOutputs.dx,0,0); + if(!this->activePreset->isPerPixelEqn(DY_OP)) glTranslatef(0 ,-this->presetOutputs.dy,0); } @@ -2115,12 +2111,12 @@ void projectM::render_texture_to_screen() { glMatrixMode(GL_TEXTURE); //draw video echo - glColor4f(0.0, 0.0, 0.0,this->fVideoEchoAlpha); + glColor4f(0.0, 0.0, 0.0,this->presetOutputs.fVideoEchoAlpha); glTranslatef(.5,.5,0); - glScalef(1.0/this->fVideoEchoZoom,1.0/this->fVideoEchoZoom,1); + glScalef(1.0/this->presetOutputs.fVideoEchoZoom,1.0/this->presetOutputs.fVideoEchoZoom,1); glTranslatef(-.5,-.5,0); - switch (((int)this->nVideoEchoOrientation)) + switch (((int)this->presetOutputs.nVideoEchoOrientation)) { case 0: flipx=1;flipy=1;break; case 1: flipx=-1;flipy=1;break; @@ -2140,7 +2136,7 @@ void projectM::render_texture_to_screen() { glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - if (this->bBrighten==1) + if (this->presetOutputs.bBrighten==1) { glColor4f(1.0, 1.0, 1.0,1.0); glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO); @@ -2169,7 +2165,7 @@ void projectM::render_texture_to_screen() { } - if (this->bDarken==1) + if (this->presetOutputs.bDarken==1) { glColor4f(1.0, 1.0, 1.0,1.0); @@ -2188,7 +2184,7 @@ void projectM::render_texture_to_screen() { } - if (this->bSolarize==1) + if (this->presetOutputs.bSolarize) { glColor4f(1.0, 1.0, 1.0,1.0); @@ -2212,7 +2208,7 @@ void projectM::render_texture_to_screen() { } - if (this->bInvert==1) + if (this->presetOutputs.bInvert) { glColor4f(1.0, 1.0, 1.0,1.0); glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO); @@ -2293,12 +2289,12 @@ void projectM::render_texture_to_studio() { glMatrixMode(GL_TEXTURE); //draw video echo - glColor4f(0.0, 0.0, 0.0,this->fVideoEchoAlpha); + glColor4f(0.0, 0.0, 0.0,this->presetOutputs.fVideoEchoAlpha); glTranslated(.5,.5,0); - glScaled(1/this->fVideoEchoZoom,1/this->fVideoEchoZoom,1); + glScaled(1/this->presetOutputs.fVideoEchoZoom,1/this->presetOutputs.fVideoEchoZoom,1); glTranslated(-.5,-.5,0); - switch (((int)this->nVideoEchoOrientation)) + switch (((int)this->presetOutputs.nVideoEchoOrientation)) { case 0: flipx=1;flipy=1;break; case 1: flipx=-1;flipy=1;break; @@ -2320,7 +2316,7 @@ void projectM::render_texture_to_studio() { // if (bDarken==1) { glAccum(GL_ACCUM,fVideoEchoAlpha); glAccum(GL_RETURN,1);} - if (this->bInvert==1) + if (this->presetOutputs.bInvert) { glColor4f(1.0, 1.0, 1.0,1.0); glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO); @@ -2349,19 +2345,19 @@ void projectM::render_texture_to_studio() { glScalef(.5,.5,1); glColor4f(1.0,1.0,1.0,1.0); - for (x=0;xgx;x++){ + for (x=0;xpresetInputs.gx;x++){ glBegin(GL_LINE_STRIP); - for(y=0;ygy;y++){ - glVertex4f((this->x_mesh[x][y]-.5), (this->y_mesh[x][y]-.5),-1,1); + for(y=0;ypresetInputs.gy;y++){ + glVertex4f((this->presetInputs.x_mesh[x][y]-.5), (this->presetInputs.y_mesh[x][y]-.5),-1,1); //glVertex4f((origx[x+1][y]-.5) * vw, (origy[x+1][y]-.5) *vh ,-1,1); } glEnd(); } - for (y=0;ygy;y++){ + for (y=0;ypresetInputs.gy;y++){ glBegin(GL_LINE_STRIP); - for(x=0;xgx;x++){ - glVertex4f((this->x_mesh[x][y]-.5), (this->y_mesh[x][y]-.5),-1,1); + for(x=0;xpresetInputs.gx;x++){ + glVertex4f((this->presetInputs.x_mesh[x][y]-.5), (this->presetInputs.y_mesh[x][y]-.5),-1,1); //glVertex4f((origx[x+1][y]-.5) * vw, (origy[x+1][y]-.5) *vh ,-1,1); } glEnd(); @@ -2370,9 +2366,9 @@ void projectM::render_texture_to_studio() { glEnable( GL_TEXTURE_2D ); /* - for (x=0;xgx-1;x++){ + for (x=0;xpresetInputs.gx-1;x++){ glBegin(GL_POINTS); - for(y=0;ygy;y++){ + for(y=0;ypresetInputs.gy;y++){ glVertex4f((this->origx[x][y]-.5)* this->vw, (this->origy[x][y]-.5)*this->vh,-1,1); glVertex4f((this->origx[x+1][y]-.5) * this->vw, (this->origy[x+1][y]-.5) *this->vh ,-1,1); } @@ -2436,132 +2432,132 @@ void projectM::render_texture_to_studio() { DLLEXPORT void projectM::projectM_initengine() { /* PER FRAME CONSTANTS BEGIN */ - this->zoom=1.0; - this->zoomexp= 1.0; - this->rot= 0.0; - this->warp= 0.0; + this->presetOutputs.zoom=1.0; + this->presetOutputs.zoomexp= 1.0; + this->presetOutputs.rot= 0.0; + this->presetOutputs.warp= 0.0; - this->sx= 1.0; - this->sy= 1.0; - this->dx= 0.0; - this->dy= 0.0; - this->cx= 0.5; - this->cy= 0.5; + this->presetOutputs.sx= 1.0; + this->presetOutputs.sy= 1.0; + this->presetOutputs.dx= 0.0; + this->presetOutputs.dy= 0.0; + this->presetOutputs.cx= 0.5; + this->presetOutputs.cy= 0.5; - this->decay=.98; + this->presetOutputs.decay=.98; - this->wave_r= 1.0; - this->wave_g= 0.2; - this->wave_b= 0.0; - this->wave_x= 0.5; - this->wave_y= 0.5; - this->wave_mystery= 0.0; + this->presetOutputs.wave_r= 1.0; + this->presetOutputs.wave_g= 0.2; + this->presetOutputs.wave_b= 0.0; + this->presetOutputs.wave_x= 0.5; + this->presetOutputs.wave_y= 0.5; + this->presetOutputs.wave_mystery= 0.0; - this->ob_size= 0.0; - this->ob_r= 0.0; - this->ob_g= 0.0; - this->ob_b= 0.0; - this->ob_a= 0.0; + this->presetOutputs.ob_size= 0.0; + this->presetOutputs.ob_r= 0.0; + this->presetOutputs.ob_g= 0.0; + this->presetOutputs.ob_b= 0.0; + this->presetOutputs.ob_a= 0.0; - this->ib_size = 0.0; - this->ib_r = 0.0; - this->ib_g = 0.0; - this->ib_b = 0.0; - this->ib_a = 0.0; + this->presetOutputs.ib_size = 0.0; + this->presetOutputs.ib_r = 0.0; + this->presetOutputs.ib_g = 0.0; + this->presetOutputs.ib_b = 0.0; + this->presetOutputs.ib_a = 0.0; - this->mv_a = 0.0; - this->mv_r = 0.0; - this->mv_g = 0.0; - this->mv_b = 0.0; - this->mv_l = 1.0; - this->mv_x = 16.0; - this->mv_y = 12.0; - this->mv_dy = 0.02; - this->mv_dx = 0.02; + this->presetOutputs.mv_a = 0.0; + this->presetOutputs.mv_r = 0.0; + this->presetOutputs.mv_g = 0.0; + this->presetOutputs.mv_b = 0.0; + this->presetOutputs.mv_l = 1.0; + this->presetOutputs.mv_x = 16.0; + this->presetOutputs.mv_y = 12.0; + this->presetOutputs.mv_dy = 0.02; + this->presetOutputs.mv_dx = 0.02; - this->meshx = 0; - this->meshy = 0; + //this->presetInputs.meshx = 0; + //this->presetInputs.meshy = 0; this->Time = 0; - this->progress = 0; - this->frame = 0; + this->presetInputs.progress = 0; + this->presetInputs.frame = 0; this->avgtime = 600; //bass_thresh = 0; /* PER_FRAME CONSTANTS END */ - this->fRating = 0; - this->fGammaAdj = 1.0; - this->fVideoEchoZoom = 1.0; - this->fVideoEchoAlpha = 0; - this->nVideoEchoOrientation = 0; + this->presetOutputs.fRating = 0; + this->presetOutputs.fGammaAdj = 1.0; + this->presetOutputs.fVideoEchoZoom = 1.0; + this->presetOutputs.fVideoEchoAlpha = 0; + this->presetOutputs.nVideoEchoOrientation = 0; - this->nWaveMode = 7; - this->bAdditiveWaves = 0; - this->bWaveDots = 0; - this->bWaveThick = 0; - this->bModWaveAlphaByVolume = 0; - this->bMaximizeWaveColor = 0; - this->bTexWrap = 0; - this->bDarkenCenter = 0; - this->bRedBlueStereo = 0; - this->bBrighten = 0; - this->bDarken = 0; - this->bSolarize = 0; - this->bInvert = 0; - this->bMotionVectorsOn = 1; + this->presetOutputs.nWaveMode = 7; + this->presetOutputs.bAdditiveWaves = 0; + this->presetOutputs.bWaveDots = 0; + this->presetOutputs.bWaveThick = 0; + this->presetOutputs.bModWaveAlphaByVolume = 0; + this->presetOutputs.bMaximizeWaveColor = 0; + this->presetOutputs.bTexWrap = 0; + this->presetOutputs.bDarkenCenter = 0; + this->presetOutputs.bRedBlueStereo = 0; + this->presetOutputs.bBrighten = 0; + this->presetOutputs.bDarken = 0; + this->presetOutputs.bSolarize = 0; + this->presetOutputs.bInvert = 0; + this->presetOutputs.bMotionVectorsOn = 1; - this->fWaveAlpha =1.0; - this->fWaveScale = 1.0; - this->fWaveSmoothing = 0; - this->fWaveParam = 0; - this->fModWaveAlphaStart = 0; - this->fModWaveAlphaEnd = 0; - this->fWarpAnimSpeed = 0; - this->fWarpScale = 0; - this->fShader = 0; + this->presetOutputs.fWaveAlpha =1.0; + this->presetOutputs.fWaveScale = 1.0; + this->presetOutputs.fWaveSmoothing = 0; + this->presetOutputs.fWaveParam = 0; + this->presetOutputs.fModWaveAlphaStart = 0; + this->presetOutputs.fModWaveAlphaEnd = 0; + this->presetOutputs.fWarpAnimSpeed = 0; + this->presetOutputs.fWarpScale = 0; + this->presetOutputs.fShader = 0; /* PER_PIXEL CONSTANTS BEGIN */ -this->x_per_pixel = 0; -this->y_per_pixel = 0; -this->rad_per_pixel = 0; -this->ang_per_pixel = 0; +this->presetInputs.x_per_pixel = 0; +this->presetInputs.y_per_pixel = 0; +this->presetInputs.rad_per_pixel = 0; +this->presetInputs.ang_per_pixel = 0; /* PER_PIXEL CONSTANT END */ /* Q AND T VARIABLES START */ -this->q1 = 0; -this->q2 = 0; -this->q3 = 0; -this->q4 = 0; -this->q5 = 0; -this->q6 = 0; -this->q7 = 0; -this->q8 = 0; +this->presetOutputs.q1 = 0; +this->presetOutputs.q2 = 0; +this->presetOutputs.q3 = 0; +this->presetOutputs.q4 = 0; +this->presetOutputs.q5 = 0; +this->presetOutputs.q6 = 0; +this->presetOutputs.q7 = 0; +this->presetOutputs.q8 = 0; /* Q AND T VARIABLES END */ //per pixel meshes - this->zoom_mesh = NULL; - this->zoomexp_mesh = NULL; - this->rot_mesh = NULL; + this->presetOutputs.zoom_mesh = NULL; + this->presetOutputs.zoomexp_mesh = NULL; + this->presetOutputs.rot_mesh = NULL; - this->sx_mesh = NULL; - this->sy_mesh = NULL; - this->dx_mesh = NULL; - this->dy_mesh = NULL; - this->cx_mesh = NULL; - this->cy_mesh = NULL; + this->presetOutputs.sx_mesh = NULL; + this->presetOutputs.sy_mesh = NULL; + this->presetOutputs.dx_mesh = NULL; + this->presetOutputs.dy_mesh = NULL; + this->presetOutputs.cx_mesh = NULL; + this->presetOutputs.cy_mesh = NULL; - this->x_mesh = NULL; - this->y_mesh = NULL; - this->rad_mesh = NULL; - this->theta_mesh = NULL; + this->presetInputs.x_mesh = NULL; + this->presetInputs.y_mesh = NULL; + this->presetInputs.rad_mesh = NULL; + this->presetInputs.theta_mesh = NULL; //custom wave per point meshes } @@ -2572,113 +2568,114 @@ DLLEXPORT void projectM::projectM_resetengine() { this->doPerPixelEffects = 1; this->doIterative = 1; - this->zoom=1.0; - this->zoomexp= 1.0; - this->rot= 0.0; - this->warp= 0.0; + this->presetOutputs.zoom=1.0; + this->presetOutputs.zoomexp= 1.0; + this->presetOutputs.rot= 0.0; + this->presetOutputs.warp= 0.0; - this->sx= 1.0; - this->sy= 1.0; - this->dx= 0.0; - this->dy= 0.0; - this->cx= 0.5; - this->cy= 0.5; + this->presetOutputs.sx= 1.0; + this->presetOutputs.sy= 1.0; + this->presetOutputs.dx= 0.0; + this->presetOutputs.dy= 0.0; + this->presetOutputs.cx= 0.5; + this->presetOutputs.cy= 0.5; - this->decay=.98; + this->presetOutputs.decay=.98; - this->wave_r= 1.0; - this->wave_g= 0.2; - this->wave_b= 0.0; - this->wave_x= 0.5; - this->wave_y= 0.5; - this->wave_mystery= 0.0; + this->presetOutputs.wave_r= 1.0; + this->presetOutputs.wave_g= 0.2; + this->presetOutputs.wave_b= 0.0; + this->presetOutputs.wave_x= 0.5; + this->presetOutputs.wave_y= 0.5; + this->presetOutputs.wave_mystery= 0.0; - this->ob_size= 0.0; - this->ob_r= 0.0; - this->ob_g= 0.0; - this->ob_b= 0.0; - this->ob_a= 0.0; + this->presetOutputs.ob_size= 0.0; + this->presetOutputs.ob_r= 0.0; + this->presetOutputs.ob_g= 0.0; + this->presetOutputs.ob_b= 0.0; + this->presetOutputs.ob_a= 0.0; - this->ib_size = 0.0; - this->ib_r = 0.0; - this->ib_g = 0.0; - this->ib_b = 0.0; - this->ib_a = 0.0; + this->presetOutputs.ib_size = 0.0; + this->presetOutputs.ib_r = 0.0; + this->presetOutputs.ib_g = 0.0; + this->presetOutputs.ib_b = 0.0; + this->presetOutputs.ib_a = 0.0; - this->mv_a = 0.0; - this->mv_r = 0.0; - this->mv_g = 0.0; - this->mv_b = 0.0; - this->mv_l = 1.0; - this->mv_x = 16.0; - this->mv_y = 12.0; - this->mv_dy = 0.02; - this->mv_dx = 0.02; + this->presetOutputs.mv_a = 0.0; + this->presetOutputs.mv_r = 0.0; + this->presetOutputs.mv_g = 0.0; + this->presetOutputs.mv_b = 0.0; + this->presetOutputs.mv_l = 1.0; + this->presetOutputs.mv_x = 16.0; + this->presetOutputs.mv_y = 12.0; + this->presetOutputs.mv_dy = 0.02; + this->presetOutputs.mv_dx = 0.02; - this->meshx = 0; - this->meshy = 0; + /// @bug think these are just gx/gy + //this->meshx = 0; + //this->meshy = 0; this->Time = 0; if ( beatDetect != NULL ) { beatDetect->reset(); } - this->progress = 0; - this->frame = 0; + this->presetInputs.progress = 0; + this->presetInputs.frame = 0; // bass_thresh = 0; /* PER_FRAME CONSTANTS END */ - this->fRating = 0; - this->fGammaAdj = 1.0; - this->fVideoEchoZoom = 1.0; - this->fVideoEchoAlpha = 0; - this->nVideoEchoOrientation = 0; + this->presetOutputs.fRating = 0; + this->presetOutputs.fGammaAdj = 1.0; + this->presetOutputs.fVideoEchoZoom = 1.0; + this->presetOutputs.fVideoEchoAlpha = 0; + this->presetOutputs.nVideoEchoOrientation = 0; - this->nWaveMode = 7; - this->bAdditiveWaves = 0; - this->bWaveDots = 0; - this->bWaveThick = 0; - this->bModWaveAlphaByVolume = 0; - this->bMaximizeWaveColor = 0; - this->bTexWrap = 0; - this->bDarkenCenter = 0; - this->bRedBlueStereo = 0; - this->bBrighten = 0; - this->bDarken = 0; - this->bSolarize = 0; - this->bInvert = 0; - this->bMotionVectorsOn = 1; + this->presetOutputs.nWaveMode = 7; + this->presetOutputs.bAdditiveWaves = 0; + this->presetOutputs.bWaveDots = 0; + this->presetOutputs.bWaveThick = 0; + this->presetOutputs.bModWaveAlphaByVolume = 0; + this->presetOutputs.bMaximizeWaveColor = 0; + this->presetOutputs.bTexWrap = 0; + this->presetOutputs.bDarkenCenter = 0; + this->presetOutputs.bRedBlueStereo = 0; + this->presetOutputs.bBrighten = 0; + this->presetOutputs.bDarken = 0; + this->presetOutputs.bSolarize = 0; + this->presetOutputs.bInvert = 0; + this->presetOutputs.bMotionVectorsOn = 1; - this->fWaveAlpha =1.0; - this->fWaveScale = 1.0; - this->fWaveSmoothing = 0; - this->fWaveParam = 0; - this->fModWaveAlphaStart = 0; - this->fModWaveAlphaEnd = 0; - this->fWarpAnimSpeed = 0; - this->fWarpScale = 0; - this->fShader = 0; + this->presetOutputs.fWaveAlpha =1.0; + this->presetOutputs.fWaveScale = 1.0; + this->presetOutputs.fWaveSmoothing = 0; + this->presetOutputs.fWaveParam = 0; + this->presetOutputs.fModWaveAlphaStart = 0; + this->presetOutputs.fModWaveAlphaEnd = 0; + this->presetOutputs.fWarpAnimSpeed = 0; + this->presetOutputs.fWarpScale = 0; + this->presetOutputs.fShader = 0; /* PER_PIXEL CONSTANTS BEGIN */ - this->x_per_pixel = 0; - this->y_per_pixel = 0; - this->rad_per_pixel = 0; - this->ang_per_pixel = 0; + this->presetInputs.x_per_pixel = 0; + this->presetInputs.y_per_pixel = 0; + this->presetInputs.rad_per_pixel = 0; + this->presetInputs.ang_per_pixel = 0; /* PER_PIXEL CONSTANT END */ /* Q VARIABLES START */ - this->q1 = 0; - this->q2 = 0; - this->q3 = 0; - this->q4 = 0; - this->q5 = 0; - this->q6 = 0; - this->q7 = 0; - this->q8 = 0; + this->presetOutputs.q1 = 0; + this->presetOutputs.q2 = 0; + this->presetOutputs.q3 = 0; + this->presetOutputs.q4 = 0; + this->presetOutputs.q5 = 0; + this->presetOutputs.q6 = 0; + this->presetOutputs.q7 = 0; + this->presetOutputs.q8 = 0; /* Q VARIABLES END */ @@ -2793,222 +2790,16 @@ DLLEXPORT void projectM::projectM_setTitle( char *title ) { */ } -/* loadPresetDir: opens the directory buffer - denoted by 'dir' to load presets */ -int projectM::loadPresetDir(char * dir) { - /* we no longer do anything here and instead look in PM->presetURL in switchPreset - this allows us to find new preset files on the fly */ - /* Start the prefix index right before the first entry, so next preset - starts at the top of the list */ -//#define PRESET_KLUDGE -#ifndef PRESET_KLUDGE - preset_index = -1; -#else - /** KLUDGE */ - preset_index = 30; -#endif - - /* Start the first preset */ - switchPreset( RANDOM_NEXT, HARD_CUT ); - - return PROJECTM_SUCCESS; -} - -/* closePresetDir: closes the current - preset directory buffer */ -int projectM::closePresetDir() { - - /* because we don't open we don't have to close ;) */ - destroyPresetLoader(); - - return PROJECTM_SUCCESS; -} - -/* switchPreset: loads the next preset from the directory stream. - loadPresetDir() must be called first. This is a - sequential load function */ - -int projectM::switchPreset(switch_mode_t switch_mode, int cut_type) { - - Preset * new_preset = 0; - - int switch_index; - int sindex = 0; - int slen = 0; - - DWRITE( "switchPreset(): in\n" ); - DWRITE( "switchPreset(): %s\n", presetURL ); - - switch (switch_mode) { - case ALPHA_NEXT: - preset_index = switch_index = preset_index + 1; - break; - case ALPHA_PREVIOUS: - preset_index = switch_index = preset_index - 1; - break; - case RANDOM_NEXT: - switch_index = rand(); - break; - case RESTART_ACTIVE: - switch_index = preset_index; - break; - default: - return PROJECTM_FAILURE; - } - - DWRITE( "switch_index: %d\n", switch_index ); - - // iterate through the presetURL directory looking for the next entry - { - struct dirent** entries; - int dir_size = scandir(presetURL, &entries, /* is_valid_extension */ NULL, alphasort); - DWRITE( "dir_size: %d\n", dir_size ); - if (dir_size > 0) { - int i; - - DWRITE( "nentries: %d\n", dir_size ); - - switch_index %= dir_size; - if (switch_index < 0) switch_index += dir_size; - for (i = 0; i < dir_size; ++i) { - if (switch_index == i) { - // matching entry - const size_t len = strlen(presetURL); - char* path = (char *) malloc(len + strlen(entries[i]->d_name) + 2); - if (path) { - strcpy(path, presetURL); - if (len && ((path[len - 1] != '/')||(path[len - 1] != '\\'))) { -#ifdef WIN32 - strcat(path + len, "\\"); -#else - strcat(path + len, "/"); -#endif - } - strcat(path + len, entries[i]->d_name); - - new_preset = Preset::load_preset(path); - free(path); - - // we must keep iterating to free the remaining entries - } - } - free(entries[i]); - } - free(entries); - } - } - -#ifdef WIN32 - new_preset = Preset::load_preset( "c:\\tmp\\projectM-1.00\\presets_test\\C.milk" ); -#else -// new_preset = Preset::load_preset( "/Users/descarte/tmp/projectM-1.00/presets_test/B.milk" ); -// new_preset = NULL; -#endif - - if (!new_preset) { - switchToIdlePreset(); - return PROJECTM_ERROR; - } - - - /* Closes a preset currently loaded, if any */ - if ((Preset::active_preset != NULL) && (Preset::active_preset != Preset::idle_preset)) { - Preset::active_preset->close_preset(); - } - - /* Sets global Preset::active_preset pointer */ - Preset::active_preset = new_preset; - -#ifndef PANTS - /** Split out the preset name from the path */ - slen = strlen( new_preset->file_path ); - sindex = slen; - while ( new_preset->file_path[sindex] != WIN32_PATH_SEPARATOR && - new_preset->file_path[sindex] != UNIX_PATH_SEPARATOR && sindex > 0 ) { - sindex--; - } - sindex++; - if ( presetName != NULL ) { - free( presetName ); - presetName = NULL; - } - presetName = (char *)wipemalloc( sizeof( char ) * (slen - sindex + 1) ); - strncpy( presetName, new_preset->file_path + sindex, slen - sindex ); - presetName[slen - sindex] = '\0'; -#endif - - /* Reinitialize the engine variables to sane defaults */ - projectM_resetengine(); - - /* Add any missing initial conditions */ - load_init_conditions(); - - /* Add any missing initial conditions for each wave */ - Preset::active_preset->load_custom_wave_init_conditions(); - -/* Add any missing initial conditions for each shape */ - Preset::active_preset->load_custom_shape_init_conditions(); - - /* Need to evaluate the initial conditions once */ - Preset::active_preset->evalInitConditions(); - Preset::active_preset->evalCustomWaveInitConditions(); - Preset::active_preset->evalCustomShapeInitConditions(); - // evalInitPerFrameEquations(); - return PROJECTM_SUCCESS; -} - -/* Loads a specific preset by absolute path */ -int projectM::loadPresetByFile(char * filename) { - - Preset * new_preset; - - /* Finally, load the preset using its actual path */ - if ((new_preset = Preset::load_preset(filename)) == NULL) { -#ifdef PRESET_DEBUG - printf("loadPresetByFile: failed to load preset!\n"); -#endif - return PROJECTM_ERROR; - } - - /* Closes a preset currently loaded, if any */ - if ((Preset::active_preset != NULL) && (Preset::active_preset != Preset::idle_preset)) - Preset::active_preset->close_preset(); - - /* Sets active preset global pointer */ - Preset::active_preset = new_preset; - - /* Reinitialize engine variables */ - projectM_resetengine(); - - - /* Add any missing initial conditions for each wave */ - Preset::active_preset->load_custom_wave_init_conditions(); - - /* Add any missing initial conditions for each wave */ - Preset::active_preset->load_custom_shape_init_conditions(); - - /* Add any missing initial conditions */ - load_init_conditions(); - - /* Need to do this once for menu */ - Preset::active_preset->evalInitConditions(); - // evalPerFrameInitEquations(); - - return PROJECTM_SUCCESS; -} /* initPresetLoader: initializes the preset loading library. this should be done before any parsing */ -int projectM::initPresetLoader() { - - /* Initializes the builtin parameter database */ - init_builtin_param_db(); +int projectM::initPresetTools() { /* Initializes the builtin function database */ - init_builtin_func_db(); - + BuiltinFuncs::init_builtin_func_db(); + /* Initializes all infix operators */ Eval::init_infix_ops(); @@ -3018,14 +2809,12 @@ int projectM::initPresetLoader() { #endif /* Initialize the 'idle' preset */ - Preset::init_idle_preset(); + //Preset::init_idle_preset(); projectM_resetengine(); -// Preset::active_preset = Preset::idle_preset; - presetName = NULL; - switchToIdlePreset(); - load_init_conditions(); + //switchToIdlePreset(); + //load_init_conditions(); /* Done */ #ifdef PRESET_DEBUG @@ -3034,183 +2823,4 @@ int projectM::initPresetLoader() { return PROJECTM_SUCCESS; } -/* Sort of experimental code here. This switches - to a hard coded preset. Useful if preset directory - was not properly loaded, or a preset fails to parse */ - -void projectM::switchToIdlePreset() { - - if ( Preset::idle_preset == NULL ) { - return; - } - - /* Idle Preset already activated */ - if (Preset::active_preset == Preset::idle_preset) - return; - - - /* Close active preset */ - if (Preset::active_preset != NULL) - Preset::active_preset->close_preset(); - - /* Sets global Preset::active_preset pointer */ - Preset::active_preset = Preset::idle_preset; - - /** Stash the preset name */ - if ( presetName != NULL ) { - free( presetName ); - } - presetName = (char *)wipemalloc( sizeof( char ) * 5 ); - strncpy( presetName, "IDLE", 4 ); - presetName[4] = '\0'; - - /* Reinitialize the engine variables to sane defaults */ - projectM_resetengine(); - - /* Add any missing initial conditions */ - load_init_conditions(); - - /* Need to evaluate the initial conditions once */ - Preset::active_preset->evalInitConditions(); - -} - - - -/* Initialize the builtin function database. - Should only be necessary once */ -int projectM::init_builtin_func_db() { - int retval; - - builtin_func_tree = - SplayTree::create_splaytree((int (*)(void*,void*))compare_string, (void*(*)(void*))copy_string, (void(*)(void*))free_string); - - if (builtin_func_tree == NULL) - return PROJECTM_OUTOFMEM_ERROR; - - retval = load_all_builtin_func(); - return PROJECTM_SUCCESS; -} - - -/* Destroy the builtin function database. - Generally, do this on projectm exit */ -int projectM::destroy_builtin_func_db() { - - builtin_func_tree->splay_traverse((void (*)(void*))free_func_helper); - return PROJECTM_SUCCESS; -} - -/* Insert a function into the database */ -int projectM::insert_func( Func *func ) { - - builtin_func_tree->splay_insert(func, func->name); - - return PROJECTM_SUCCESS; -} - -/* Remove a function from the database */ -int projectM::remove_func( Func *func ) { - - builtin_func_tree->splay_delete(func->name); - - return PROJECTM_SUCCESS; -} - -/* Find a function given its name */ -Func *projectM::find_func(char * name) { - - Func * func = NULL; - - /* First look in the builtin database */ - func = (Func *)builtin_func_tree->splay_find(name); - - return func; - -} - -/* Loads a builtin function */ -int projectM::load_builtin_func(char * name, float (*func_ptr)(float*), int num_args) { - - Func * func; - int retval; - - /* Create new function */ - func = Func::create_func(name, func_ptr, num_args); - - if (func == NULL) - return PROJECTM_OUTOFMEM_ERROR; - - retval = insert_func( func ); - - return retval; - -} - -/* Loads all builtin functions */ -int projectM::load_all_builtin_func() { - - if (load_builtin_func("int", int_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("abs", abs_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("sin", sin_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("cos", cos_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("tan", tan_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("asin", asin_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("acos", acos_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("atan", atan_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("sqr", sqr_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("sqrt", sqrt_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("pow", pow_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("exp", exp_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("log", log_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("log10", log10_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("sign", sign_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("min", min_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("max", max_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("sigmoid", sigmoid_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("atan2", atan2_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("rand", rand_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("band", band_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("bor", bor_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("bnot", bnot_wrapper, 1) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("if", if_wrapper, 3) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("equal", equal_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("above", above_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("below",below_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("nchoosek", nchoosek_wrapper, 2) < 0) - return PROJECTM_ERROR; - if (load_builtin_func("fact", fact_wrapper, 1) < 0) - return PROJECTM_ERROR; - - - return PROJECTM_SUCCESS; -} - diff --git a/src/projectM-engine/projectM.h b/src/projectM-engine/projectM.h index b2997d3dd..dd8a69c48 100755 --- a/src/projectM-engine/projectM.h +++ b/src/projectM-engine/projectM.h @@ -67,7 +67,8 @@ #include "dlldefs.h" #include "event.h" #include "fatal.h" - +#include "PresetFrameIO.hpp" +#include "Preset.hpp" //#include @@ -112,44 +113,10 @@ typedef enum { } interface_t; - static const char * IDLE_PRESET_STRING = "[idlepreset]\n"; - - -struct PresetInputs { - - /* PER_PIXEL CONSTANTS BEGIN */ - - float x_per_pixel; - float y_per_pixel; - float rad_per_pixel; - float ang_per_pixel; - - /* PER_PIXEL CONSTANT END */ - - int fps; - - - float time; - float bass; - float mid; - float bass_att; - float mid_att; - float treb_att; - int frame; - float progress; - - - /* variables added in 1.04 */ - int meshx; - int meshy; - - -}; - - class projectM { public: static projectM * currentEngine; + static Preset * activePreset; char *presetURL; char *presetName; @@ -220,9 +187,6 @@ public: int mesh_i, mesh_j; - // All builtin functions are store here - SplayTree *builtin_func_tree; - /** Timing information */ int mspf; int timed; @@ -240,11 +204,15 @@ public: /** Beat detection engine */ BeatDetect *beatDetect; - /** All readonly variables (that is not beat detection) + /** All readonly variables * which are passed as inputs * to presets. See struct defintition above */ PresetInputs presetInputs; + /** The presets modify these values. For now this is declared on stack + * but might be better on heap for sake of smooth preset switching */ + PresetOutputs presetOutputs; + /** Functions */ DLLEXPORT projectM(); @@ -292,15 +260,7 @@ public: projectMKeycode keycode, projectMModifier modifier ); void default_key_handler( projectMEvent event, projectMKeycode keycode ); - /** Func database */ - int init_builtin_func_db(); - int destroy_builtin_func_db(); - int load_all_builtin_func(); - int load_builtin_func( char * name, float (*func_ptr)(float*), int num_args ); - - int insert_func( Func *func ); - int remove_func( Func *func ); - Func *find_func( char *name ); + int initPresetTools(); }; #endif /** !_PROJECTM_H */