| 104 | } |
| 105 | |
| 106 | void process(const ProcessArgs& args) override { |
| 107 | float in1 = inputs[IN1_INPUT].getVoltageSum(); |
| 108 | float in2 = inputs[IN2_INPUT].getVoltageSum(); |
| 109 | const float levelScale = 0.030; |
| 110 | const float levelBase = 25.0; |
| 111 | float level1 = levelScale * dsp::exponentialBipolar(levelBase, params[LEVEL1_PARAM].getValue()) * inputs[CV1_INPUT].getNormalVoltage(10.0) / 10.0; |
| 112 | float level2 = levelScale * dsp::exponentialBipolar(levelBase, params[LEVEL2_PARAM].getValue()) * inputs[CV2_INPUT].getNormalVoltage(10.0) / 10.0; |
| 113 | float dry = in1 * level1 + in2 * level2; |
| 114 | |
| 115 | // HPF on dry |
| 116 | float dryCutoff = 200.0 * std::pow(20.0, params[HPF_PARAM].getValue()) * args.sampleTime; |
| 117 | dryFilter.setCutoff(dryCutoff); |
| 118 | dryFilter.process(dry); |
| 119 | |
| 120 | // Add dry to input buffer |
| 121 | if (!inputBuffer.full()) { |
| 122 | dsp::Frame<1> inputFrame; |
| 123 | inputFrame.samples[0] = dryFilter.highpass(); |
| 124 | inputBuffer.push(inputFrame); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | if (outputBuffer.empty()) { |
| 129 | float input[BLOCK_SIZE] = {}; |
| 130 | float output[BLOCK_SIZE]; |
| 131 | // Convert input buffer |
| 132 | { |
| 133 | inputSrc.setRates(args.sampleRate, 48000); |
| 134 | int inLen = inputBuffer.size(); |
| 135 | int outLen = BLOCK_SIZE; |
| 136 | inputSrc.process(inputBuffer.startData(), &inLen, (dsp::Frame<1>*) input, &outLen); |
| 137 | inputBuffer.startIncr(inLen); |
| 138 | } |
| 139 | |
| 140 | // Convolve block |
| 141 | convolver->processBlock(input, output); |
| 142 | |
| 143 | // Convert output buffer |
| 144 | { |
| 145 | outputSrc.setRates(48000, args.sampleRate); |
| 146 | int inLen = BLOCK_SIZE; |
| 147 | int outLen = outputBuffer.capacity(); |
| 148 | outputSrc.process((dsp::Frame<1>*) output, &inLen, outputBuffer.endData(), &outLen); |
| 149 | outputBuffer.endIncr(outLen); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // Set output |
| 154 | if (outputBuffer.empty()) |
| 155 | return; |
| 156 | |
| 157 | float wet = outputBuffer.shift().samples[0]; |
| 158 | float balance = clamp(params[WET_PARAM].getValue() + inputs[MIX_CV_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f); |
| 159 | float mix = crossfade(in1, wet, balance); |
| 160 | |
| 161 | outputs[WET_OUTPUT].setVoltage(clamp(wet, -10.0f, 10.0f)); |
| 162 | outputs[MIX_OUTPUT].setVoltage(clamp(mix, -10.0f, 10.0f)); |
| 163 | |