computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit ff91b70dc0b382d0308f5adab3a426a6b34ff796
parent 2fe941205261c06fb373a97485756a2af7b6f0bc
Author: Adam M <[email protected]>
Date:   Sun,  5 Jan 2020 23:15:03 -0600

Taylor and sin expansion

Diffstat:
Msrc/ComputerscareGolyPenerator.cpp | 16++++++----------
Msrc/golyFunctions.cpp | 21+++++++++++++--------
Msrc/golyFunctions.hpp | 2+-
3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/ComputerscareGolyPenerator.cpp b/src/ComputerscareGolyPenerator.cpp @@ -50,27 +50,23 @@ struct ComputerscareGolyPenerator : Module { configParam(KNOB +1,0.f,10.f,1.f,"Algorithm"); - for (int i = 2; i < numKnobs; i++) { - configParam(KNOB + i, 0.0f, 10.0f, 0.0f); - configParam(KNOB + i, 0.f, 10.f, 0.f, "Channel " + std::to_string(i + 1) + " Voltage", " Volts"); + for (int i = 2; i < 8; i++) { + configParam(KNOB + i, -10.f, 10.f, 0.f, "Parameter " + std::to_string(i - 1)); } goly = Goly(); } void updateCurrents() { - std::vector<float> golyParams = {params[KNOB+2].getValue(),params[KNOB+3].getValue()}; - goly.invoke((int)params[KNOB+1].getValue(),golyParams); + std::vector<float> golyParams = {params[KNOB+2].getValue(),params[KNOB+3].getValue(),params[KNOB+4].getValue(),params[KNOB+5].getValue(),params[KNOB+6].getValue(),params[KNOB+7].getValue()}; + goly.invoke((int) std::floor(params[KNOB+1].getValue()),golyParams); } void process(const ProcessArgs &args) override { counter++; if (counter > 5012) { - //printf("%f \n",random::uniform()); counter = 0; - //rect4032 - //south facing high wall updateCurrents(); - numChannels=(params[KNOB].getValue()); + numChannels=(int) (std::floor(params[KNOB].getValue())); } @@ -100,7 +96,7 @@ struct ComputerscareGolyPeneratorWidget : ModuleWidget { } float xx; float yy; - for (int i = 0; i < numKnobs; i++) { + for (int i = 0; i < 8; i++) { xx = 1.4f + 24.3 * (i-i % 8)/8; yy = 64 + 37.5 * (i % 8) + 14.3 * (i - i % 8)/8; addLabeledKnob(std::to_string(i + 1), xx, yy, module, i, (i-i%8)*1.2-2, 0); diff --git a/src/golyFunctions.cpp b/src/golyFunctions.cpp @@ -7,26 +7,31 @@ Goly::Goly() { } } -void Goly::invoke(int algorithm, std::vector<float> params) { +void Goly::invoke(int algorithm, std::vector<float> gp) { switch (algorithm) { case 0: // code to be executed if n = 1; for (int i = 0; i < 16; i++) { - currentValues[i] = params[0]; + currentValues[i] = gp[0]+gp[1]*i/16.f+gp[2]*i*i/8.f; } break; - case 1: - + float trigFactor; for (int i = 0; i < 16; i++) { - currentValues[i] = (float) i * (params[0]); + trigFactor = 5.f+((float) (i) )*2.f*M_PI/(16*expf(gp[0])); + float val =0.f; + for(int j = 1; j<6; j++) { + val += gp[j]*sinf(trigFactor*j); + } + currentValues[i] = val; } break; default: - for (int i = 0; i < 16; i++) { - currentValues[i] = (float) i ; - } + /*for (int i = 0; i < 16; i++) { + currentValues[i] = 0.f; + }*/ + int k = 0; } } diff --git a/src/golyFunctions.hpp b/src/golyFunctions.hpp @@ -22,6 +22,6 @@ class Goly { float currentValues[16]; Goly(); - void invoke(int algorithm,std::vector<float> pararms); + void invoke(int algorithm,std::vector<float> gp); };