From f41076a969d1a9fbe096f94b27186cf65f8d7d93 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 14 Sep 2019 23:39:00 -0400 Subject: [PATCH] Remove buffering from host. DuktapeEngine: Replace Proxy getters/setters with normal arrays. Use r,g,b properties instead of indices for light colors. --- .gitignore | 1 + examples/rainbow.js | 18 +- src/DuktapeEngine.cpp | 422 ++++++++++++------------------------------ src/Prototype.cpp | 36 +--- src/ScriptEngine.hpp | 15 +- 5 files changed, 143 insertions(+), 349 deletions(-) diff --git a/.gitignore b/.gitignore index abde234..b88197b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /build /dist +/dep /plugin.so /plugin.dylib /plugin.dll diff --git a/examples/rainbow.js b/examples/rainbow.js index 29b3135..1053461 100644 --- a/examples/rainbow.js +++ b/examples/rainbow.js @@ -1,20 +1,14 @@ config.frameDivider = 1 -config.bufferSize = 1 -var frame = 0 function process(block) { - frame += 1 for (var i = 0; i < 6; i++) { - for (var j = 0; j < block.bufferSize; j++) { - var v = block.inputs[i][j] - v *= block.knobs[i] - block.outputs[i][j] = v - } - // block.lights[i][2] = 1 - // block.switchLights[i][1] = 1 + var v = block.inputs[i] + v *= block.knobs[i] + block.outputs[i] = v + block.lights[i].r = 1 + block.switchLights[i].g = 1 + block.switchLights[i].b = 1 } - - display(frame) } display("Hello, world!") diff --git a/src/DuktapeEngine.cpp b/src/DuktapeEngine.cpp index 5260a1b..58cb437 100644 --- a/src/DuktapeEngine.cpp +++ b/src/DuktapeEngine.cpp @@ -3,9 +3,20 @@ struct DuktapeEngine : ScriptEngine { - duk_context* ctx; + duk_context* ctx = NULL; - int initialize() override { + ~DuktapeEngine() { + if (ctx) + duk_destroy_heap(ctx); + } + + std::string getEngineName() override { + return "JavaScript"; + } + + int run(const std::string& path, const std::string& script) override { + assert(!ctx); + // Create duktape context ctx = duk_create_heap_default(); if (!ctx) { setMessage("Could not create duktape context"); @@ -45,142 +56,51 @@ struct DuktapeEngine : ScriptEngine { // frameDivider duk_push_int(ctx, getFrameDivider()); duk_put_prop_string(ctx, configIdx, "frameDivider"); - // bufferSize - duk_push_int(ctx, getBufferSize()); - duk_put_prop_string(ctx, configIdx, "bufferSize"); } duk_put_global_string(ctx, "config"); - // // block (put on stack) - // duk_idx_t blockIdx = duk_push_object(ctx); - // { - // // sampleRate - // duk_push_string(ctx, "sampleRate"); - // duk_push_c_function(ctx, native_block_sampleRate_get, 0); - // duk_def_prop(ctx, configIdx, DUK_DEFPROP_HAVE_GETTER); - - // // sampleTime - // duk_push_string(ctx, "sampleTime"); - // duk_push_c_function(ctx, native_block_sampleTime_get, 0); - // duk_def_prop(ctx, configIdx, DUK_DEFPROP_HAVE_GETTER); - - // // bufferSize - // duk_push_string(ctx, "bufferSize"); - // duk_push_c_function(ctx, native_block_bufferSize_get, 0); - // duk_def_prop(ctx, configIdx, DUK_DEFPROP_HAVE_GETTER); - - // // inputs - // duk_idx_t inputsIdx = duk_push_array(ctx); - // for (int i = 0; i < NUM_ROWS; i++) { - // duk_push_object(ctx); - // { - // duk_push_int(ctx, i); - // duk_put_prop_string(ctx, -2, "i"); - // } - // duk_push_object(ctx); - // { - // duk_push_c_function(ctx, native_block_input_get, 3); - // duk_put_prop_string(ctx, -2, "get"); - // } - // duk_push_proxy(ctx, 0); - // duk_put_prop_index(ctx, inputsIdx, i); - // } - // duk_put_prop_string(ctx, blockIdx, "inputs"); - - // // outputs - // duk_idx_t outputsIdx = duk_push_array(ctx); - // for (int i = 0; i < NUM_ROWS; i++) { - // duk_push_object(ctx); - // { - // duk_push_int(ctx, i); - // duk_put_prop_string(ctx, -2, "i"); - // } - // duk_push_object(ctx); - // { - // duk_push_c_function(ctx, native_block_output_set, 4); - // duk_put_prop_string(ctx, -2, "set"); - // } - // duk_push_proxy(ctx, 0); - // duk_put_prop_index(ctx, outputsIdx, i); - // } - // duk_put_prop_string(ctx, blockIdx, "outputs"); - - // // knobs - // duk_push_object(ctx); - // duk_push_object(ctx); - // { - // duk_push_c_function(ctx, native_block_knobs_get, 3); - // duk_put_prop_string(ctx, -2, "get"); - // } - // duk_push_proxy(ctx, 0); - // duk_put_prop_string(ctx, blockIdx, "knobs"); - - // // switches - // duk_push_object(ctx); - // duk_push_object(ctx); - // { - // duk_push_c_function(ctx, native_block_switches_get, 3); - // duk_put_prop_string(ctx, -2, "get"); - // } - // duk_push_proxy(ctx, 0); - // duk_put_prop_string(ctx, blockIdx, "switches"); - - // // lights - // duk_idx_t lightsIdx = duk_push_array(ctx); - // for (int i = 0; i < NUM_ROWS; i++) { - // duk_push_object(ctx); - // { - // duk_push_int(ctx, i); - // duk_put_prop_string(ctx, -2, "i"); - // } - // duk_push_object(ctx); - // { - // duk_push_c_function(ctx, native_block_light_set, 4); - // duk_put_prop_string(ctx, -2, "set"); - // } - // duk_push_proxy(ctx, 0); - // duk_put_prop_index(ctx, lightsIdx, i); - // } - // duk_put_prop_string(ctx, blockIdx, "lights"); - - // // switchLights - // duk_idx_t switchLightsIdx = duk_push_array(ctx); - // for (int i = 0; i < NUM_ROWS; i++) { - // duk_push_object(ctx); - // { - // duk_push_int(ctx, i); - // duk_put_prop_string(ctx, -2, "i"); - // } - // duk_push_object(ctx); - // { - // duk_push_c_function(ctx, native_block_switchLight_set, 4); - // duk_put_prop_string(ctx, -2, "set"); - // } - // duk_push_proxy(ctx, 0); - // duk_put_prop_index(ctx, switchLightsIdx, i); - // } - // duk_put_prop_string(ctx, blockIdx, "switchLights"); - // } - - // block (put on stack) - duk_idx_t blockIdx = duk_push_object(ctx); - { - // sampleRate - duk_push_undefined(ctx); - duk_put_prop_string(ctx, blockIdx, "sampleRate"); + // Compile string + duk_push_string(ctx, path.c_str()); + if (duk_pcompile_lstring_filename(ctx, 0, script.c_str(), script.size()) != 0) { + const char* s = duk_safe_to_string(ctx, -1); + setMessage(s); + duk_pop(ctx); + return -1; + } + // Execute function + if (duk_pcall(ctx, 0)) { + const char* s = duk_safe_to_string(ctx, -1); + setMessage(s); + duk_pop(ctx); + return -1; + } + // Ignore return value + duk_pop(ctx); - // sampleTime - duk_push_undefined(ctx); - duk_put_prop_string(ctx, blockIdx, "sampleTime"); + // Get config + duk_get_global_string(ctx, "config"); + { + // frameDivider + duk_get_prop_string(ctx, -1, "frameDivider"); + setFrameDivider(duk_get_int(ctx, -1)); + duk_pop(ctx); + } + duk_pop(ctx); - // bufferSize - duk_push_undefined(ctx); - duk_put_prop_string(ctx, blockIdx, "bufferSize"); + // Keep process function on stack for faster calling + duk_get_global_string(ctx, "process"); + if (!duk_is_function(ctx, -1)) { + setMessage("No process() function"); + return -1; + } + // block (keep on stack) + duk_idx_t blockIdx = duk_push_object(ctx); + { // inputs duk_idx_t inputsIdx = duk_push_array(ctx); for (int i = 0; i < NUM_ROWS; i++) { - duk_push_undefined(ctx); + duk_push_number(ctx, 0.0); duk_put_prop_index(ctx, inputsIdx, i); } duk_put_prop_string(ctx, blockIdx, "inputs"); @@ -188,7 +108,7 @@ struct DuktapeEngine : ScriptEngine { // outputs duk_idx_t outputsIdx = duk_push_array(ctx); for (int i = 0; i < NUM_ROWS; i++) { - duk_push_undefined(ctx); + duk_push_number(ctx, 0.0); duk_put_prop_index(ctx, outputsIdx, i); } duk_put_prop_string(ctx, blockIdx, "outputs"); @@ -196,7 +116,7 @@ struct DuktapeEngine : ScriptEngine { // knobs duk_idx_t knobsIdx = duk_push_array(ctx); for (int i = 0; i < NUM_ROWS; i++) { - duk_push_undefined(ctx); + duk_push_number(ctx, 0.0); duk_put_prop_index(ctx, knobsIdx, i); } duk_put_prop_string(ctx, blockIdx, "knobs"); @@ -204,7 +124,7 @@ struct DuktapeEngine : ScriptEngine { // switches duk_idx_t switchesIdx = duk_push_array(ctx); for (int i = 0; i < NUM_ROWS; i++) { - duk_push_undefined(ctx); + duk_push_number(ctx, 0.0); duk_put_prop_index(ctx, switchesIdx, i); } duk_put_prop_string(ctx, blockIdx, "switches"); @@ -212,10 +132,14 @@ struct DuktapeEngine : ScriptEngine { // lights duk_idx_t lightsIdx = duk_push_array(ctx); for (int i = 0; i < NUM_ROWS; i++) { - duk_idx_t lightIdx = duk_push_array(ctx); - for (int c = 0; c < 3; c++) { - duk_push_undefined(ctx); - duk_put_prop_index(ctx, lightIdx, c); + duk_idx_t lightIdx = duk_push_object(ctx); + { + duk_push_number(ctx, 0.0); + duk_put_prop_string(ctx, lightIdx, "r"); + duk_push_number(ctx, 0.0); + duk_put_prop_string(ctx, lightIdx, "g"); + duk_push_number(ctx, 0.0); + duk_put_prop_string(ctx, lightIdx, "b"); } duk_put_prop_index(ctx, lightsIdx, i); } @@ -224,10 +148,14 @@ struct DuktapeEngine : ScriptEngine { // switchLights duk_idx_t switchLightsIdx = duk_push_array(ctx); for (int i = 0; i < NUM_ROWS; i++) { - duk_idx_t lightIdx = duk_push_array(ctx); - for (int c = 0; c < 3; c++) { - duk_push_undefined(ctx); - duk_put_prop_index(ctx, lightIdx, c); + duk_idx_t switchLightIdx = duk_push_object(ctx); + { + duk_push_number(ctx, 0.0); + duk_put_prop_string(ctx, switchLightIdx, "r"); + duk_push_number(ctx, 0.0); + duk_put_prop_string(ctx, switchLightIdx, "g"); + duk_push_number(ctx, 0.0); + duk_put_prop_string(ctx, switchLightIdx, "b"); } duk_put_prop_index(ctx, switchLightsIdx, i); } @@ -237,92 +165,28 @@ struct DuktapeEngine : ScriptEngine { return 0; } - ~DuktapeEngine() { - duk_destroy_heap(ctx); - } - - std::string getEngineName() override { - return "JavaScript"; - } - - int run(const std::string& path, const std::string& script) override { - duk_push_string(ctx, path.c_str()); - if (duk_pcompile_lstring_filename(ctx, 0, script.c_str(), script.size()) != 0) { - const char* s = duk_safe_to_string(ctx, -1); - setMessage(s); - duk_pop(ctx); - return -1; - } - if (duk_pcall(ctx, 0)) { - const char* s = duk_safe_to_string(ctx, -1); - setMessage(s); - duk_pop(ctx); - return -1; - } - duk_pop(ctx); - - // Get config - duk_get_global_string(ctx, "config"); - { - // frameDivider - duk_get_prop_string(ctx, -1, "frameDivider"); - setFrameDivider(duk_get_int(ctx, -1)); - duk_pop(ctx); - // bufferSize - duk_get_prop_string(ctx, -1, "bufferSize"); - setBufferSize(duk_get_int(ctx, -1)); - duk_pop(ctx); - } - duk_pop(ctx); - - // Put process function on top of stack for faster calling - duk_get_global_string(ctx, "process"); - if (!duk_is_function(ctx, -1)) { - setMessage("No process() function"); - return -1; - } - return 0; - } - int process(ProcessBlock& block) override { - currentBlock = █ - // Duplicate process function - duk_dup(ctx, -1); - // Duplicate block object - duk_dup(ctx, -3); - // block + duk_idx_t blockIdx = duk_get_top(ctx) - 1; { // sampleRate duk_push_number(ctx, block.sampleRate); - duk_put_prop_string(ctx, -2, "sampleRate"); + duk_put_prop_string(ctx, blockIdx, "sampleRate"); // sampleTime duk_push_number(ctx, block.sampleTime); - duk_put_prop_string(ctx, -2, "sampleTime"); - - // bufferSize - duk_push_number(ctx, block.bufferSize); - duk_put_prop_string(ctx, -2, "bufferSize"); + duk_put_prop_string(ctx, blockIdx, "sampleTime"); // inputs - duk_get_prop_string(ctx, -1, "inputs"); - for (int i = 0; i < NUM_ROWS; i++) { - duk_push_number(ctx, block.inputs[i][0]); - duk_put_prop_index(ctx, -2, i); - } - duk_pop(ctx); - - // outputs - duk_get_prop_string(ctx, -1, "outputs"); + duk_get_prop_string(ctx, blockIdx, "inputs"); for (int i = 0; i < NUM_ROWS; i++) { - duk_push_number(ctx, block.outputs[i][0]); + duk_push_number(ctx, block.inputs[i]); duk_put_prop_index(ctx, -2, i); } duk_pop(ctx); // knobs - duk_get_prop_string(ctx, -1, "knobs"); + duk_get_prop_string(ctx, blockIdx, "knobs"); for (int i = 0; i < NUM_ROWS; i++) { duk_push_number(ctx, block.knobs[i]); duk_put_prop_index(ctx, -2, i); @@ -330,22 +194,55 @@ struct DuktapeEngine : ScriptEngine { duk_pop(ctx); // switches - duk_get_prop_string(ctx, -1, "switches"); + duk_get_prop_string(ctx, blockIdx, "switches"); for (int i = 0; i < NUM_ROWS; i++) { duk_push_boolean(ctx, block.switches[i]); duk_put_prop_index(ctx, -2, i); } duk_pop(ctx); + } + + // Duplicate process function + duk_dup(ctx, -2); + // Duplicate block object + duk_dup(ctx, -2); + // Call process function + if (duk_pcall(ctx, 1)) { + const char* s = duk_safe_to_string(ctx, -1); + setMessage(s); + duk_pop(ctx); + return -1; + } + // return value + duk_pop(ctx); + + // block + { + // outputs + duk_get_prop_string(ctx, -1, "outputs"); + for (int i = 0; i < NUM_ROWS; i++) { + duk_get_prop_index(ctx, -1, i); + block.outputs[i] = duk_get_number(ctx, -1); + duk_pop(ctx); + } + duk_pop(ctx); // lights duk_get_prop_string(ctx, -1, "lights"); for (int i = 0; i < NUM_ROWS; i++) { duk_get_prop_index(ctx, -1, i); - for (int c = 0; c < 3; c++) { - duk_push_number(ctx, block.lights[i][c]); - duk_put_prop_index(ctx, -2, c); + { + duk_get_prop_string(ctx, -1, "r"); + block.lights[i][0] = duk_get_number(ctx, -1); + duk_pop(ctx); + duk_get_prop_string(ctx, -1, "g"); + block.lights[i][1] = duk_get_number(ctx, -1); + duk_pop(ctx); + duk_get_prop_string(ctx, -1, "b"); + block.lights[i][2] = duk_get_number(ctx, -1); + duk_pop(ctx); } - duk_put_prop_index(ctx, -2, i); + duk_pop(ctx); } duk_pop(ctx); @@ -353,25 +250,22 @@ struct DuktapeEngine : ScriptEngine { duk_get_prop_string(ctx, -1, "switchLights"); for (int i = 0; i < NUM_ROWS; i++) { duk_get_prop_index(ctx, -1, i); - for (int c = 0; c < 3; c++) { - duk_push_number(ctx, block.switchLights[i][c]); - duk_put_prop_index(ctx, -2, c); + { + duk_get_prop_string(ctx, -1, "r"); + block.switchLights[i][0] = duk_get_number(ctx, -1); + duk_pop(ctx); + duk_get_prop_string(ctx, -1, "g"); + block.switchLights[i][1] = duk_get_number(ctx, -1); + duk_pop(ctx); + duk_get_prop_string(ctx, -1, "b"); + block.switchLights[i][2] = duk_get_number(ctx, -1); + duk_pop(ctx); } - duk_put_prop_index(ctx, -2, i); + duk_pop(ctx); } duk_pop(ctx); } - // Call process function - if (duk_pcall(ctx, 1)) { - const char* s = duk_safe_to_string(ctx, -1); - setMessage(s); - duk_pop(ctx); - return -1; - } - // return value - duk_pop(ctx); - currentBlock = NULL; return 0; } @@ -402,79 +296,9 @@ struct DuktapeEngine : ScriptEngine { getDuktapeEngine(ctx)->setMessage(s); return 0; } - - // Use thread_local variable instead of storing a user pointer in `ctx`, for performance. - static thread_local ProcessBlock* currentBlock; - - static duk_ret_t native_block_sampleRate_get(duk_context* ctx) { - float sampleRate = currentBlock->sampleRate; - duk_push_number(ctx, sampleRate); - return 1; - } - static duk_ret_t native_block_sampleTime_get(duk_context* ctx) { - float sampleTime = currentBlock->sampleTime; - duk_push_number(ctx, sampleTime); - return 1; - } - static duk_ret_t native_block_bufferSize_get(duk_context* ctx) { - int bufferSize = currentBlock->bufferSize; - duk_push_int(ctx, bufferSize); - return 1; - } - static duk_ret_t native_block_input_get(duk_context* ctx) { - duk_get_prop_string(ctx, -3, "i"); - int index = duk_get_int(ctx, -1); - duk_pop(ctx); - int bufferIndex = duk_get_int(ctx, -2); - float v = currentBlock->inputs[index][bufferIndex]; - duk_push_number(ctx, v); - return 1; - } - static duk_ret_t native_block_output_set(duk_context* ctx) { - duk_get_prop_string(ctx, -4, "i"); - int index = duk_get_int(ctx, -1); - duk_pop(ctx); - int bufferIndex = duk_get_int(ctx, -3); - float v = duk_get_number(ctx, -2); - currentBlock->outputs[index][bufferIndex] = v; - return 0; - } - static duk_ret_t native_block_knobs_get(duk_context* ctx) { - int index = duk_get_int(ctx, -2); - float v = currentBlock->knobs[index]; - duk_push_number(ctx, v); - return 1; - } - static duk_ret_t native_block_switches_get(duk_context* ctx) { - int index = duk_get_int(ctx, -2); - bool s = currentBlock->switches[index]; - duk_push_boolean(ctx, s); - return 1; - } - static duk_ret_t native_block_light_set(duk_context* ctx) { - duk_get_prop_string(ctx, -4, "i"); - int index = duk_get_int(ctx, -1); - duk_pop(ctx); - int c = duk_get_int(ctx, -3); - float v = duk_get_number(ctx, -2); - currentBlock->lights[index][c] = v; - return 0; - } - static duk_ret_t native_block_switchLight_set(duk_context* ctx) { - duk_get_prop_string(ctx, -4, "i"); - int index = duk_get_int(ctx, -1); - duk_pop(ctx); - int c = duk_get_int(ctx, -3); - float v = duk_get_number(ctx, -2); - currentBlock->switchLights[index][c] = v; - return 0; - } }; -thread_local ScriptEngine::ProcessBlock* DuktapeEngine::currentBlock; - - ScriptEngine* createDuktapeEngine() { return new DuktapeEngine; } \ No newline at end of file diff --git a/src/Prototype.cpp b/src/Prototype.cpp index 365cb51..672627b 100644 --- a/src/Prototype.cpp +++ b/src/Prototype.cpp @@ -40,7 +40,6 @@ struct Prototype : Module { int frame = 0; int frameDivider; ScriptEngine::ProcessBlock block; - int blockIndex = 0; Prototype() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); @@ -72,16 +71,7 @@ struct Prototype : Module { // Inputs for (int i = 0; i < NUM_ROWS; i++) - block.inputs[i][blockIndex] = inputs[IN_INPUTS + i].getVoltage(); - // Outputs - for (int i = 0; i < NUM_ROWS; i++) - outputs[OUT_OUTPUTS + i].setVoltage(block.outputs[i][blockIndex]); - - // Block divider - if (++blockIndex < block.bufferSize) - return; - blockIndex = 0; - + block.inputs[i] = inputs[IN_INPUTS + i].getVoltage(); // Params for (int i = 0; i < NUM_ROWS; i++) block.knobs[i] = params[KNOB_PARAMS + i].getValue(); @@ -103,6 +93,9 @@ struct Prototype : Module { } } + // Outputs + for (int i = 0; i < NUM_ROWS; i++) + outputs[OUT_OUTPUTS + i].setVoltage(block.outputs[i]); // Lights for (int i = 0; i < NUM_ROWS; i++) for (int c = 0; c < 3; c++) @@ -117,17 +110,18 @@ struct Prototype : Module { delete scriptEngine; scriptEngine = NULL; } - // Reset outputs because they might hold old values + // Reset outputs and lights because they might hold old values for (int i = 0; i < NUM_ROWS; i++) outputs[OUT_OUTPUTS + i].setVoltage(0.f); for (int i = 0; i < NUM_ROWS; i++) - lights[LIGHT_LIGHTS + i].setBrightness(0.f); + for (int c = 0; c < 3; c++) + lights[LIGHT_LIGHTS + i * 3 + c].setBrightness(0.f); for (int i = 0; i < NUM_ROWS; i++) - lights[SWITCH_LIGHTS + i].setBrightness(0.f); + for (int c = 0; c < 3; c++) + lights[SWITCH_LIGHTS + i * 3 + c].setBrightness(0.f); std::memset(block.inputs, 0, sizeof(block.inputs)); // Reset settings frameDivider = 32; - block.bufferSize = 1; } void setScriptString(std::string path, std::string script) { @@ -150,13 +144,7 @@ struct Prototype : Module { this->path = path; this->script = script; this->engineName = scriptEngine->getEngineName(); - // Initialize ScriptEngine scriptEngine->module = this; - if (scriptEngine->initialize()) { - // Error message should have been set by ScriptEngine - clearScriptEngine(); - return; - } // Read file std::ifstream file; file.exceptions(std::ifstream::failbit | std::ifstream::badbit); @@ -211,12 +199,6 @@ int ScriptEngine::getFrameDivider() { void ScriptEngine::setFrameDivider(int frameDivider) { module->frameDivider = frameDivider; } -int ScriptEngine::getBufferSize() { - return module->block.bufferSize; -} -void ScriptEngine::setBufferSize(int bufferSize) { - module->block.bufferSize = bufferSize; -} struct FileChoice : LedDisplayChoice { diff --git a/src/ScriptEngine.hpp b/src/ScriptEngine.hpp index ea515f4..0e64a39 100644 --- a/src/ScriptEngine.hpp +++ b/src/ScriptEngine.hpp @@ -3,7 +3,6 @@ static const int NUM_ROWS = 6; -static const int MAX_BUFFER_SIZE = 4096; struct Prototype; @@ -11,10 +10,6 @@ struct Prototype; struct ScriptEngine { // Virtual methods for subclasses - /** Constructor. - Return nonzero if failure, and set error message with setMessage(). - */ - virtual int initialize() {return 0;} virtual ~ScriptEngine() {} virtual std::string getEngineName() {return "";} /** Executes the script. @@ -26,9 +21,8 @@ struct ScriptEngine { struct ProcessBlock { float sampleRate = 0.f; float sampleTime = 0.f; - int bufferSize = 1; - float inputs[NUM_ROWS][MAX_BUFFER_SIZE] = {}; - float outputs[NUM_ROWS][MAX_BUFFER_SIZE] = {}; + float inputs[NUM_ROWS] = {}; + float outputs[NUM_ROWS] = {}; float knobs[NUM_ROWS] = {}; bool switches[NUM_ROWS] = {}; float lights[NUM_ROWS][3] = {}; @@ -39,12 +33,11 @@ struct ScriptEngine { */ virtual int process(ProcessBlock& block) {return 0;} - // Communication with Prototype module + // Communication with Prototype module. + // These cannot be called from the constructor, so initialize in the run() method. void setMessage(const std::string& message); int getFrameDivider(); void setFrameDivider(int frameDivider); - int getBufferSize(); - void setBufferSize(int bufferSize); // private Prototype* module; };