Skip to content

Commit

Permalink
Small VCA-QUADVCA code fix
Browse files Browse the repository at this point in the history
Reverted back part of the code for the VCA and QUADVCA modules
  • Loading branch information
AScustomWorks committed Apr 16, 2022
1 parent 9ad1350 commit fd235b2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Buy them on the [VCV plugin library](https://vcvrack.com/plugins.html#Alfredo%20

# AS modules

### V 2.0.4

Reverted back part of the code for the VCA and QUADVCA modules, all should be fine now (thanks to circadiansound for finding the bug)

### V 2.0.3

Removed some leftover extra code on VCA and QUADVCA modules that caused wrong behavior when using the CV Level ports (thanks to circadiansound for finding the bug)
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"slug": "AS",
"version": "2.0.3",
"version": "2.0.4",
"license": "MIT",
"name": "AS",
"brand": "AS",
Expand Down
16 changes: 8 additions & 8 deletions src/QuadVCA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ struct QuadVCA : Module {
float out = 0.0;

v1 = inputs[IN1_INPUT].getVoltage() * params[GAIN1_PARAM].getValue();
//if(inputs[GAIN1_CV_INPUT].isConnected()){
if(inputs[GAIN1_CV_INPUT].isConnected()){
if(params[MODE1_PARAM].getValue()==1){
v1 *= clamp(inputs[GAIN1_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f);
}else{
v1 *= rescale(powf(expBase, clamp(inputs[GAIN1_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
}
//}
}
out+=v1;
lights[GAIN1_LIGHT].setSmoothBrightness(fmaxf(0.0f, out / 5.0f), args.sampleTime);
if (outputs[OUT1_OUTPUT].isConnected()) {
Expand All @@ -109,13 +109,13 @@ struct QuadVCA : Module {
}
//QuadVCA 2
v2 = inputs[IN2_INPUT].getVoltage() * params[GAIN2_PARAM].getValue();
//if(inputs[GAIN2_CV_INPUT].isConnected()){
if(inputs[GAIN2_CV_INPUT].isConnected()){
if(params[MODE2_PARAM].getValue()){
v2 *= clamp(inputs[GAIN2_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f);
}else{
v2 *= rescale(powf(expBase, clamp(inputs[GAIN2_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
}
//}
}
out+=v2;
lights[GAIN2_LIGHT].setSmoothBrightness(fmaxf(0.0f, out / 5.0f), args.sampleTime);
if (outputs[OUT2_OUTPUT].isConnected()) {
Expand All @@ -125,13 +125,13 @@ struct QuadVCA : Module {
//QuadVCA 3

v3 = inputs[IN3_INPUT].getVoltage() * params[GAIN3_PARAM].getValue();
//if(inputs[GAIN3_CV_INPUT].isConnected()){
if(inputs[GAIN3_CV_INPUT].isConnected()){
if(params[MODE3_PARAM].getValue()){
v3 *= clamp(inputs[GAIN3_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f);
}else{
v3 *= rescale(powf(expBase, clamp(inputs[GAIN3_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
}
//}
}
out+=v3;
lights[GAIN3_LIGHT].setSmoothBrightness(fmaxf(0.0f, out / 5.0f), args.sampleTime);
if (outputs[OUT3_OUTPUT].isConnected()) {
Expand All @@ -141,13 +141,13 @@ struct QuadVCA : Module {
//QuadVCA 4

v4 = inputs[IN4_INPUT].getVoltage() * params[GAIN4_PARAM].getValue();
//if(inputs[GAIN4_CV_INPUT].isConnected()){
if(inputs[GAIN4_CV_INPUT].isConnected()){
if(params[MODE4_PARAM].getValue()){
v4 *= clamp(inputs[GAIN4_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f);
}else{
v4 *= rescale(powf(expBase, clamp(inputs[GAIN4_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
}
//}
}
out+=v4;
lights[GAIN4_LIGHT].setSmoothBrightness(fmaxf(0.0f, out / 5.0f), args.sampleTime);
if (outputs[OUT4_OUTPUT].isConnected()) {
Expand Down
9 changes: 4 additions & 5 deletions src/VCA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,26 @@ struct VCA : Module {

void process(const ProcessArgs &args) override {
//VCA 1

v1 = inputs[IN1_INPUT].getVoltage() * params[LEVEL1_PARAM].getValue();
//if(inputs[ENV1_INPUT].isConnected()){
if(inputs[ENV1_INPUT].isConnected()){
if(params[MODE1_PARAM].getValue()==1){
v1 *= clamp(inputs[ENV1_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f);
}else{
v1 *= rescale(powf(expBase, clamp(inputs[ENV1_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
}
//}
}

outputs[OUT1_OUTPUT].setVoltage(v1);
//VCA 2

v2 = inputs[IN2_INPUT].getVoltage() * params[LEVEL2_PARAM].getValue();
//if(inputs[ENV2_INPUT].isConnected()){
if(inputs[ENV2_INPUT].isConnected()){
if(params[MODE2_PARAM].getValue()){
v2 *= clamp(inputs[ENV2_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f);
}else{
v2 *= rescale(powf(expBase, clamp(inputs[ENV2_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)), 1.0f, expBase, 0.0f, 1.0f);
}
//}
}
outputs[OUT2_OUTPUT].setVoltage(v2);
}

Expand Down

0 comments on commit fd235b2

Please sign in to comment.