From 992f6c2d82ab9c7f86065096dbd2f628b7c345f8 Mon Sep 17 00:00:00 2001 From: Xenakios Date: Sun, 13 Oct 2019 18:52:58 +0300 Subject: [PATCH 01/10] Random sampler : Initial implementation to allow setting gate length from GUI --- src/Marbles.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Marbles.cpp b/src/Marbles.cpp index 6b3d627..1d8e2cf 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -210,7 +210,7 @@ struct Marbles : Module { int x_scale; int y_divider_index; int x_clock_source_internal; - + float _gate_len=0.5f; // Buffers stmlib::GateFlags t_clocks[BLOCK_SIZE] = {}; stmlib::GateFlags last_t_clock = 0; @@ -451,7 +451,7 @@ struct Marbles : Module { t_generator.set_deja_vu(t_deja_vu ? deja_vu : 0.f); t_generator.set_length(deja_vu_length); // TODO - t_generator.set_pulse_width_mean(0.f); + t_generator.set_pulse_width_mean(_gate_len); t_generator.set_pulse_width_std(0.f); t_generator.Process(t_external_clock, t_clocks, ramps, gates, BLOCK_SIZE); @@ -676,6 +676,32 @@ struct MarblesWidget : ModuleWidget { YDividerItem *yDividerItem = createMenuItem("Y divider ratio"); yDividerItem->module = module; menu->addChild(yDividerItem); + + struct GateLenMenuItem : MenuItem { + Marbles *module; + float source=0.0f; + void onAction(const event::Action &e) override { + module->_gate_len = source; + } + }; + menu->addChild(new MenuEntry); + menu->addChild(createMenuLabel("Gate length")); + const std::pair gateLens[] = { + {"1%",0.01f}, + {"10%",0.1f}, + {"25%",0.25f}, + {"50%",0.5f}, + {"75%",0.75f}, + {"90%",0.9f}, + {"99%",0.99f} + }; + for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { + GateLenMenuItem *item = createMenuItem(gateLens[i].first, + CHECKMARK(gateLens[i].second==module->_gate_len)); + item->module = module; + item->source = gateLens[i].second; + menu->addChild(item); + } } }; From bbf63efcc1e69b74200d4382f4ceb7c044535efc Mon Sep 17 00:00:00 2001 From: xenakios Date: Sun, 13 Oct 2019 19:25:27 +0300 Subject: [PATCH 02/10] Use a submenu for the gate length --- .vscode/c_cpp_properties.json | 24 +++++++++++++++++ src/Marbles.cpp | 51 ++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..d690713 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,24 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**", + "C:\\msys64\\home\\Teemu\\Rack-SDK\\include", + "C:\\msys64\\home\\Teemu\\AudibleInstruments\\src", + "C:\\msys64\\home\\Teemu\\Rack-SDK\\dep\\include" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.17763.0", + "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/src/Marbles.cpp b/src/Marbles.cpp index 1d8e2cf..90f416b 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -677,31 +677,44 @@ struct MarblesWidget : ModuleWidget { yDividerItem->module = module; menu->addChild(yDividerItem); - struct GateLenMenuItem : MenuItem { - Marbles *module; + struct GateLenMenuIndexItem : MenuItem { + Marbles *module = nullptr; float source=0.0f; void onAction(const event::Action &e) override { module->_gate_len = source; } }; - menu->addChild(new MenuEntry); - menu->addChild(createMenuLabel("Gate length")); - const std::pair gateLens[] = { - {"1%",0.01f}, - {"10%",0.1f}, - {"25%",0.25f}, - {"50%",0.5f}, - {"75%",0.75f}, - {"90%",0.9f}, - {"99%",0.99f} + + struct GateLenMenuItem : MenuItem + { + Marbles* module = nullptr; + Menu *createChildMenu() override { + Menu *submenu = new Menu(); + const std::pair gateLens[] = { + {"1%",0.01f}, + {"10%",0.1f}, + {"25%",0.25f}, + {"50%",0.5f}, + {"75%",0.75f}, + {"90%",0.9f}, + {"99%",0.99f} + }; + for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { + GateLenMenuIndexItem *item = createMenuItem(gateLens[i].first, + CHECKMARK(gateLens[i].second==module->_gate_len)); + item->module = module; + item->source = gateLens[i].second; + submenu->addChild(item); + } + return submenu; + } }; - for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { - GateLenMenuItem *item = createMenuItem(gateLens[i].first, - CHECKMARK(gateLens[i].second==module->_gate_len)); - item->module = module; - item->source = gateLens[i].second; - menu->addChild(item); - } + + menu->addChild(new MenuEntry); + GateLenMenuItem* glitem = createMenuItem("Gate length"); + glitem->module = module; + menu->addChild(glitem); + } }; From fdda2874f5df9da249de4718f609a3917755587e Mon Sep 17 00:00:00 2001 From: Xenakios Date: Sun, 13 Oct 2019 19:33:04 +0300 Subject: [PATCH 03/10] Random sampler : serialize gate length setting --- src/Marbles.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Marbles.cpp b/src/Marbles.cpp index 90f416b..3644ad2 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -292,7 +292,7 @@ struct Marbles : Module { json_object_set_new(rootJ, "x_scale", json_integer(x_scale)); json_object_set_new(rootJ, "y_divider_index", json_integer(y_divider_index)); json_object_set_new(rootJ, "x_clock_source_internal", json_integer(x_clock_source_internal)); - + json_object_set_new(rootJ, "gate_length", json_real(_gate_len)); return rootJ; } @@ -336,6 +336,10 @@ struct Marbles : Module { json_t *x_clock_source_internalJ = json_object_get(rootJ, "x_clock_source_internal"); if (x_clock_source_internalJ) x_clock_source_internal = json_integer_value(x_clock_source_internalJ); + + json_t *gatelenJ = json_object_get(rootJ, "gate_length"); + if (gatelenJ) + _gate_len = json_real_value(gatelenJ); } void process(const ProcessArgs &args) override { From 188086ab65d715733db855e262496748aa90c0ab Mon Sep 17 00:00:00 2001 From: Xenakios Date: Sun, 13 Oct 2019 19:39:26 +0300 Subject: [PATCH 04/10] Remove vs code settings file from repo --- .vscode/c_cpp_properties.json | 24 ------------------------ src/Marbles.cpp | 3 ++- 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index d690713..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**", - "C:\\msys64\\home\\Teemu\\Rack-SDK\\include", - "C:\\msys64\\home\\Teemu\\AudibleInstruments\\src", - "C:\\msys64\\home\\Teemu\\Rack-SDK\\dep\\include" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "windowsSdkVersion": "10.0.17763.0", - "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "msvc-x64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/src/Marbles.cpp b/src/Marbles.cpp index 3644ad2..4cbdacc 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -454,8 +454,9 @@ struct Marbles : Module { t_generator.set_jitter(t_jitter); t_generator.set_deja_vu(t_deja_vu ? deja_vu : 0.f); t_generator.set_length(deja_vu_length); - // TODO + t_generator.set_pulse_width_mean(_gate_len); + // TODO t_generator.set_pulse_width_std(0.f); t_generator.Process(t_external_clock, t_clocks, ramps, gates, BLOCK_SIZE); From 3011e1d9862384b0f754a820e613bad26914b4a3 Mon Sep 17 00:00:00 2001 From: Xenakios Date: Sun, 13 Oct 2019 21:11:46 +0300 Subject: [PATCH 05/10] Random sampler : fuzzy compare gate length when determining checkmark state --- src/Marbles.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Marbles.cpp b/src/Marbles.cpp index 4cbdacc..3925dbf 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -705,8 +705,9 @@ struct MarblesWidget : ModuleWidget { {"99%",0.99f} }; for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { + bool checked = rack::math::isNear(gateLens[i].second,module->_gate_len,0.0001); GateLenMenuIndexItem *item = createMenuItem(gateLens[i].first, - CHECKMARK(gateLens[i].second==module->_gate_len)); + CHECKMARK(checked)); item->module = module; item->source = gateLens[i].second; submenu->addChild(item); From 47e7ad85d9e32b58c890ca41f240a7f6c5ad5306 Mon Sep 17 00:00:00 2001 From: Xenakios Date: Tue, 15 Oct 2019 17:01:55 +0300 Subject: [PATCH 06/10] Random sampler : added support for changing gate length randomization --- src/Marbles.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/Marbles.cpp b/src/Marbles.cpp index 3925dbf..dcc63f7 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -211,6 +211,7 @@ struct Marbles : Module { int y_divider_index; int x_clock_source_internal; float _gate_len=0.5f; + float _gate_len_dev = 0.0f; // Buffers stmlib::GateFlags t_clocks[BLOCK_SIZE] = {}; stmlib::GateFlags last_t_clock = 0; @@ -293,6 +294,7 @@ struct Marbles : Module { json_object_set_new(rootJ, "y_divider_index", json_integer(y_divider_index)); json_object_set_new(rootJ, "x_clock_source_internal", json_integer(x_clock_source_internal)); json_object_set_new(rootJ, "gate_length", json_real(_gate_len)); + json_object_set_new(rootJ, "gate_length_dev", json_real(_gate_len_dev)); return rootJ; } @@ -340,6 +342,9 @@ struct Marbles : Module { json_t *gatelenJ = json_object_get(rootJ, "gate_length"); if (gatelenJ) _gate_len = json_real_value(gatelenJ); + json_t *gatelendevJ = json_object_get(rootJ, "gate_length_dev"); + if (gatelendevJ) + _gate_len_dev = json_real_value(gatelendevJ); } void process(const ProcessArgs &args) override { @@ -456,8 +461,7 @@ struct Marbles : Module { t_generator.set_length(deja_vu_length); t_generator.set_pulse_width_mean(_gate_len); - // TODO - t_generator.set_pulse_width_std(0.f); + t_generator.set_pulse_width_std(_gate_len_dev); t_generator.Process(t_external_clock, t_clocks, ramps, gates, BLOCK_SIZE); @@ -705,11 +709,12 @@ struct MarblesWidget : ModuleWidget { {"99%",0.99f} }; for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { - bool checked = rack::math::isNear(gateLens[i].second,module->_gate_len,0.0001); + bool checked = isNear(gateLens[i].second,module->_gate_len,0.0001); GateLenMenuIndexItem *item = createMenuItem(gateLens[i].first, CHECKMARK(checked)); item->module = module; - item->source = gateLens[i].second; + // The marbles code wants the parameter to be in range 0.0-1.0 + item->source = rescale(gateLens[i].second,0.01f,0.99f,0.0f,1.0f); submenu->addChild(item); } return submenu; @@ -721,6 +726,42 @@ struct MarblesWidget : ModuleWidget { glitem->module = module; menu->addChild(glitem); + struct GateLenDevMenuIndexItem : MenuItem { + Marbles *module = nullptr; + float source=0.0f; + void onAction(const event::Action &e) override { + module->_gate_len_dev = source; + } + }; + + struct GateLenDevMenuItem : MenuItem + { + Marbles* module = nullptr; + Menu *createChildMenu() override { + Menu *submenu = new Menu(); + const std::pair gateLenDevs[] = { + {"None",0.00f}, + {"Small",0.1f}, + {"Medium",0.5f}, + {"Large",0.9f} + }; + for (int i = 0; i < (int) LENGTHOF(gateLenDevs); i++) { + bool checked = isNear(gateLenDevs[i].second,module->_gate_len_dev,0.0001); + GateLenDevMenuIndexItem *item = createMenuItem(gateLenDevs[i].first, + CHECKMARK(checked)); + item->module = module; + item->source = gateLenDevs[i].second; + submenu->addChild(item); + } + return submenu; + } + }; + + menu->addChild(new MenuEntry); + GateLenDevMenuItem* glditem = createMenuItem("Gate length randomization"); + glditem->module = module; + menu->addChild(glditem); + } }; From 59efd545783c8cbf842cdf7d87b1694e5334e137 Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 16 Oct 2019 02:50:02 +0300 Subject: [PATCH 07/10] Random sampler : Fix checkmark status checking --- src/Marbles.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Marbles.cpp b/src/Marbles.cpp index dcc63f7..a82e524 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -709,7 +709,8 @@ struct MarblesWidget : ModuleWidget { {"99%",0.99f} }; for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { - bool checked = isNear(gateLens[i].second,module->_gate_len,0.0001); + float scaled_len = rescale(module->_gate_len,0.01f,0.99f, 0.0f,1.0f); + bool checked = isNear(gateLens[i].second,scaled_len,0.0001); GateLenMenuIndexItem *item = createMenuItem(gateLens[i].first, CHECKMARK(checked)); item->module = module; From f86512664caffc04f5c086459a40b762cd6c8b82 Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 16 Oct 2019 05:02:26 +0300 Subject: [PATCH 08/10] Random sampler : Actually fix the checkmark issue --- src/Marbles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Marbles.cpp b/src/Marbles.cpp index a82e524..5dfe746 100644 --- a/src/Marbles.cpp +++ b/src/Marbles.cpp @@ -709,7 +709,7 @@ struct MarblesWidget : ModuleWidget { {"99%",0.99f} }; for (int i = 0; i < (int) LENGTHOF(gateLens); i++) { - float scaled_len = rescale(module->_gate_len,0.01f,0.99f, 0.0f,1.0f); + float scaled_len = rescale(module->_gate_len,0.0f,1.0f, 0.01f,0.99f); bool checked = isNear(gateLens[i].second,scaled_len,0.0001); GateLenMenuIndexItem *item = createMenuItem(gateLens[i].first, CHECKMARK(checked)); From 31dc74e4d940a34ec54eab01e12c84143894222e Mon Sep 17 00:00:00 2001 From: Xenakios Date: Fri, 18 Oct 2019 13:55:13 +0300 Subject: [PATCH 09/10] Random sampler : Increase version number --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 4db8a40..c2524b1 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "slug": "AudibleInstruments", - "version": "1.0.0", + "version": "1.0.1", "license": "GPL-3.0-only", "name": "Audible Instruments", "author": "VCV", From fe55668f14f17905e93292c5723cb656d21d8ed1 Mon Sep 17 00:00:00 2001 From: Xenakios Date: Sat, 19 Oct 2019 02:16:03 +0300 Subject: [PATCH 10/10] Roll back version number for now --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index c2524b1..4db8a40 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "slug": "AudibleInstruments", - "version": "1.0.1", + "version": "1.0.0", "license": "GPL-3.0-only", "name": "Audible Instruments", "author": "VCV",