| 92 | } |
| 93 | |
| 94 | void process(const ProcessArgs& args) override { |
| 95 | |
| 96 | float gainA = params[FOLD_A_PARAM].getValue(); |
| 97 | gainA += params[CV_A_PARAM].getValue() * inputs[CV_A_INPUT].getVoltage() / 10.f; |
| 98 | gainA += inputs[VCA_CV_A_INPUT].getVoltage() / 10.f; |
| 99 | gainA = std::max(gainA, 0.f); |
| 100 | |
| 101 | // CV_B_INPUT is normalled to CV_A_INPUT (input with attenuverter) |
| 102 | float gainB = params[FOLD_B_PARAM].getValue(); |
| 103 | gainB += params[CV_B_PARAM].getValue() * inputs[CV_B_INPUT].getNormalVoltage(inputs[CV_A_INPUT].getVoltage()) / 10.f; |
| 104 | gainB += inputs[VCA_CV_B_INPUT].getVoltage() / 10.f; |
| 105 | gainB = std::max(gainB, 0.f); |
| 106 | |
| 107 | const float inA = inputs[IN_A_INPUT].getVoltageSum(); |
| 108 | const float inB = inputs[IN_B_INPUT].getNormalVoltage(inputs[IN_A_INPUT].getVoltageSum()); |
| 109 | |
| 110 | // if the CHOPP gate is wired in, do chop logic |
| 111 | if (inputs[IN_GATE_INPUT].isConnected()) { |
| 112 | // TODO: check rescale? |
| 113 | trigger.process(rescale(inputs[IN_GATE_INPUT].getVoltageSum(), 0.1f, 2.f, 0.f, 1.f)); |
| 114 | outputAToChopp = trigger.isHigh(); |
| 115 | } |
| 116 | // else zero-crossing detector on input A switches between A and B |
| 117 | else { |
| 118 | if (previousA > 0 && inA < 0) { |
| 119 | outputAToChopp = false; |
| 120 | } |
| 121 | else if (previousA < 0 && inA > 0) { |
| 122 | outputAToChopp = true; |
| 123 | } |
| 124 | } |
| 125 | previousA = inA; |
| 126 | |
| 127 | const bool choppIsRequired = outputs[OUT_CHOPP_OUTPUT].isConnected(); |
| 128 | const bool aIsRequired = outputs[OUT_A_OUTPUT].isConnected() || choppIsRequired; |
| 129 | const bool bIsRequired = outputs[OUT_B_OUTPUT].isConnected() || choppIsRequired; |
| 130 | |
| 131 | if (aIsRequired) { |
| 132 | oversampler[CHANNEL_A].upsample(inA * gainA); |
| 133 | } |
| 134 | if (bIsRequired) { |
| 135 | oversampler[CHANNEL_B].upsample(inB * gainB); |
| 136 | } |
| 137 | if (choppIsRequired) { |
| 138 | oversampler[CHANNEL_CHOPP].upsample(outputAToChopp ? 1.f : 0.f); |
| 139 | } |
| 140 | |
| 141 | float* osBufferA = oversampler[CHANNEL_A].getOSBuffer(); |
| 142 | float* osBufferB = oversampler[CHANNEL_B].getOSBuffer(); |
| 143 | float* osBufferChopp = oversampler[CHANNEL_CHOPP].getOSBuffer(); |
| 144 | |
| 145 | for (int i = 0; i < oversampler[0].getOversamplingRatio(); i++) { |
| 146 | if (aIsRequired) { |
| 147 | //osBufferA[i] = wavefolderAResponse(osBufferA[i]); |
| 148 | osBufferA[i] = wavefolderAResponseCached(osBufferA[i]); |
| 149 | } |
| 150 | if (bIsRequired) { |
| 151 | //osBufferB[i] = wavefolderBResponse(osBufferB[i]); |
nothing calls this directly
no test coverage detected