Skip to content

Commit

Permalink
reverse y so positive is up visually. compoly mode labels
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamPorcineFudgepuppy committed Jul 14, 2024
1 parent 59c840b commit 76ceb02
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/ComputerscareComplexTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ struct ComputerscareComplexTransformer : ComputerscareComplexBase {
getParamQuantity(COMPOLY_CHANNELS)->resetEnabled = false;

configParam<cpx::CompolyModeParam>(MAIN_OUTPUT_MODE,0.f,3.f,0.f,"Main Output Mode");
configParam(MAIN_INPUT_MODE,0.f,3.f,0.f);
configParam<cpx::CompolyModeParam>(MAIN_INPUT_MODE,0.f,3.f,0.f,"Main Input Mode");
configParam(MAIN_SCALE_INPUT_MODE,0.f,3.f,0.f);
configParam(MAIN_OFFSET_INPUT_MODE,0.f,3.f,0.f);

configInput<cpx::CompolyPortInfo<MAIN_INPUT_MODE,0>>(MAIN_INPUT, "Main");
configInput<cpx::CompolyPortInfo<MAIN_INPUT_MODE,1>>(MAIN_INPUT + 1, "Main");


configOutput<cpx::CompolyPortInfo<MAIN_OUTPUT_MODE,0>>(COMPOLY_MAIN_OUT_A, "f(z)");
configOutput<cpx::CompolyPortInfo<MAIN_OUTPUT_MODE,1>>(COMPOLY_MAIN_OUT_B, "f(z)");

Expand Down
2 changes: 1 addition & 1 deletion src/ComputerscareDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ struct DebugViz : TransparentWidget {

for (int i = 0; i < 8; i++) {
xx[i]=module->logLines[2*i];
yy[i]=module->logLines[2*i+1];
yy[i]=-module->logLines[2*i+1];
colorsToDraw[i]=module->logLines[2*i]/3;
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/ComputerscareNomplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ struct ComputerscareNomplexPumbers : ComputerscareComplexBase
POLAR_IN_POLAR_OUT_MODE,
COMPLEX_CONSTANT_A,
COMPLEX_CONSTANT_B,
AB_MODE,
COMPLEX_CONSTANT_U,
COMPLEX_CONSTANT_V,
UV_MODE,
NUM_PARAMS
};
enum InputIds
Expand Down Expand Up @@ -95,11 +97,13 @@ struct ComputerscareNomplexPumbers : ComputerscareComplexBase
configParam<cpx::CompolyModeParam>(POLAR_IN_RECT_OUT_MODE,0.f,3.f,0.f,"Polar Output 1 Mode");
configParam<cpx::CompolyModeParam>(POLAR_IN_POLAR_OUT_MODE,0.f,3.f,0.f,"Polar Output 2 Mode");

configParam(COMPLEX_CONSTANT_A,-10.f,10.f,0.f,"Complex A");
configParam(COMPLEX_CONSTANT_B,-10.f,10.f,0.f,"Complex B");
configParam(COMPLEX_CONSTANT_A,-10.f,10.f,0.f,"X Input Offset");
configParam(COMPLEX_CONSTANT_B,-10.f,10.f,0.f,"Y Input Offset");
configParam(AB_MODE,0.f,1.f,0.f,"AB Mode");

configParam(COMPLEX_CONSTANT_U,-10.f,10.f,0.f,"Complex U");
configParam(COMPLEX_CONSTANT_V,-10.f,10.f,0.f,"Complex V");
configParam(UV_MODE,0.f,1.f,1.f,"UV Mode");

configOutput<cpx::CompolyPortInfo<RECT_IN_RECT_OUT_MODE,0>>(RECT_IN_RECT_OUT, "Rectangular Input");
configOutput<cpx::CompolyPortInfo<RECT_IN_RECT_OUT_MODE,1>>(RECT_IN_RECT_OUT + 1, "Rectangular Input");
Expand Down Expand Up @@ -180,8 +184,8 @@ struct ComputerscareNomplexPumbers : ComputerscareComplexBase
int realInputCh=inputChannelIndices[0];
int imInputCh=inputChannelIndices[1];

float x = inputs[REAL_IN].getVoltage(realInputCh)*realTrimKnob + realOffsetKnob + xyParamX;
float y = inputs[IMAGINARY_IN].getVoltage(imInputCh)*imaginaryTrimKnob + imaginaryOffsetKnob + xyParamY;
float x = inputs[REAL_IN].getVoltage(realInputCh)*realTrimKnob + xyParamX;
float y = inputs[IMAGINARY_IN].getVoltage(imInputCh)*imaginaryTrimKnob + xyParamY;

float r = std::hypot(x,y);
float arg = std::atan2(y,x);
Expand Down Expand Up @@ -274,12 +278,12 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget


addInput(createInput<InPort>(Vec(leftInputX, rectInSectionY), module, ComputerscareNomplexPumbers::REAL_IN));
addParam(createParam<SmoothKnob>(Vec(leftInputX, rectInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::REAL_INPUT_OFFSET));
addParam(createParam<SmoothKnob>(Vec(leftInputX, rectInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::COMPLEX_CONSTANT_A));
addParam(createParam<SmallKnob>(Vec(leftInputX, rectInSectionY).plus(trimRelPos), module, ComputerscareNomplexPumbers::REAL_INPUT_TRIM));


addInput(createInput<InPort>(Vec(rightInputX, rectInSectionY), module, ComputerscareNomplexPumbers::IMAGINARY_IN));
addParam(createParam<SmoothKnob>(Vec(rightInputX, rectInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::IMAGINARY_INPUT_OFFSET));
addParam(createParam<SmoothKnob>(Vec(rightInputX, rectInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::COMPLEX_CONSTANT_B));
addParam(createParam<SmallKnob>(Vec(rightInputX, rectInSectionY).plus(trimRelPos), module, ComputerscareNomplexPumbers::IMAGINARY_INPUT_TRIM));

cpx::CompolyPortsWidget* outRect1 = new cpx::CompolyPortsWidget(Vec(output1X, rectInSectionY+40),module,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT_MODE);
Expand Down
7 changes: 4 additions & 3 deletions src/complex/ComplexWidgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ namespace cpx {
if(module) {
float complexA = module->params[paramA].getValue();
float complexB = module->params[paramA+1].getValue();
int complexMode = module->params[paramA+2].getValue();

origComplexValue = Vec(complexA,complexB);
origComplexValue = Vec(complexA,-complexB);
origComplexLength=origComplexValue.norm();

if(origComplexLength < 0.1) {
Expand Down Expand Up @@ -115,10 +116,10 @@ namespace cpx {
newZ = pixelsDiff.div(originalMagnituteRadiusPixels).mult(origComplexLength);

module->params[paramA].setValue(newZ.x);
module->params[paramA+1].setValue(newZ.y);
module->params[paramA+1].setValue(-newZ.y);
} else {
if(module) {
newZ = Vec(module->params[paramA].getValue(),module->params[paramA+1].getValue());
newZ = Vec(module->params[paramA].getValue(),-module->params[paramA+1].getValue());
} else {
newZ = Vec(-10 + 20* random::uniform(),-10 + 20* random::uniform());
}
Expand Down

0 comments on commit 76ceb02

Please sign in to comment.