| @@ -47,7 +47,7 @@ struct Percall : Module { | |||
| configParam(DECAY_PARAMS + i, 0.f, 1.f, 0.f, "Ch " + std::to_string(i + 1) + " decay time"); | |||
| envs[i].attackTime = attackTime; | |||
| envs[i].attackShape = 0.5f; | |||
| envs[i].decayShape = 3.0f; | |||
| envs[i].decayShape = 2.0f; | |||
| } | |||
| for (int i = 0; i < 2; i++) { | |||
| @@ -63,7 +63,7 @@ struct Percall : Module { | |||
| strength = 1.0f; | |||
| if (inputs[STRENGTH_INPUT].isConnected()) { | |||
| strength = clamp(inputs[STRENGTH_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f); | |||
| strength = sqrt(clamp(inputs[STRENGTH_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f)); | |||
| } | |||
| // only calculate gains/decays every 16 samples | |||
| @@ -71,13 +71,13 @@ struct Percall : Module { | |||
| for (int i = 0; i < 4; i++) { | |||
| gains[i] = std::pow(params[VOL_PARAMS + i].getValue(), 2.f) * strength; | |||
| float fallCv = inputs[CV_INPUTS + i].getVoltage() + params[DECAY_PARAMS + i].getValue() * 10.f; | |||
| envs[i].decayTime = minDecayTime * std::pow(2.0, clamp(fallCv, 0.0f, 10.0f)); | |||
| float fallCv = inputs[CV_INPUTS + i].getVoltage() * 0.05f + params[DECAY_PARAMS + i].getValue(); | |||
| envs[i].decayTime = rescale(std::pow(clamp(fallCv, 0.f, 1.0f), 2.f), 0.f, 1.f, minDecayTime, maxDecayTime); | |||
| } | |||
| } | |||
| simd::float_4 mix[4] = {}; | |||
| int maxChannels = 1; | |||
| int maxPolyphonyChannels = 1; | |||
| // Mixer channels | |||
| for (int i = 0; i < 4; i++) { | |||
| @@ -94,19 +94,19 @@ struct Percall : Module { | |||
| envs[i].process(args.sampleTime); | |||
| int channels = 1; | |||
| int polyphonyChannels = 1; | |||
| simd::float_4 in[4] = {}; | |||
| bool inputIsConnected = inputs[CH_INPUTS + i].isConnected(); | |||
| bool inputIsNormed = !inputIsConnected && (i % 2) && inputs[CH_INPUTS + i - 1].isConnected(); | |||
| if ((inputIsConnected || inputIsNormed)) { | |||
| int channel_to_read_from = inputIsNormed ? CH_INPUTS + i - 1 : CH_INPUTS + i; | |||
| channels = inputs[channel_to_read_from].getChannels(); | |||
| maxChannels = std::max(maxChannels, channels); | |||
| polyphonyChannels = inputs[channel_to_read_from].getChannels(); | |||
| maxPolyphonyChannels = std::max(maxPolyphonyChannels, polyphonyChannels); | |||
| // only process input audio if envelope is active | |||
| if (envs[i].stage != ADEnvelope::STAGE_OFF) { | |||
| float gain = gains[i] * envs[i].env; | |||
| for (int c = 0; c < channels; c += 4) { | |||
| for (int c = 0; c < polyphonyChannels; c += 4) { | |||
| in[c / 4] = simd::float_4::load(inputs[channel_to_read_from].getVoltages(c)) * gain; | |||
| } | |||
| } | |||
| @@ -115,14 +115,14 @@ struct Percall : Module { | |||
| if (i != LAST_CHANNEL_ID) { | |||
| // if connected, output via the jack (and don't add to mix) | |||
| if (outputs[CH_OUTPUTS + i].isConnected()) { | |||
| outputs[CH_OUTPUTS + i].setChannels(channels); | |||
| for (int c = 0; c < channels; c += 4) { | |||
| outputs[CH_OUTPUTS + i].setChannels(polyphonyChannels); | |||
| for (int c = 0; c < polyphonyChannels; c += 4) { | |||
| in[c / 4].store(outputs[CH_OUTPUTS + i].getVoltages(c)); | |||
| } | |||
| } | |||
| else { | |||
| // else add to mix | |||
| for (int c = 0; c < channels; c += 4) { | |||
| for (int c = 0; c < polyphonyChannels; c += 4) { | |||
| mix[c / 4] += in[c / 4]; | |||
| } | |||
| } | |||
| @@ -130,14 +130,14 @@ struct Percall : Module { | |||
| // otherwise if it is the final channel and it's wired in | |||
| else if (outputs[CH_OUTPUTS + i].isConnected()) { | |||
| outputs[CH_OUTPUTS + i].setChannels(maxChannels); | |||
| outputs[CH_OUTPUTS + i].setChannels(maxPolyphonyChannels); | |||
| // last channel must always go into mix | |||
| for (int c = 0; c < channels; c += 4) { | |||
| for (int c = 0; c < polyphonyChannels; c += 4) { | |||
| mix[c / 4] += in[c / 4]; | |||
| } | |||
| for (int c = 0; c < maxChannels; c += 4) { | |||
| for (int c = 0; c < maxPolyphonyChannels; c += 4) { | |||
| mix[c / 4].store(outputs[CH_OUTPUTS + i].getVoltages(c)); | |||
| } | |||
| } | |||
| @@ -168,41 +168,43 @@ struct PercallWidget : ModuleWidget { | |||
| addChild(createWidget<Knurlie>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); | |||
| addChild(createWidget<Knurlie>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(8.003, 41.196)), module, Percall::VOL_PARAMS + 0)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(22.829, 41.196)), module, Percall::VOL_PARAMS + 1)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(37.655, 41.196)), module, Percall::VOL_PARAMS + 2)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(52.481, 41.196)), module, Percall::VOL_PARAMS + 3)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(5.385, 52.476)), module, Percall::DECAY_PARAMS + 0)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(20.728, 52.476)), module, Percall::DECAY_PARAMS + 1)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(35.543, 52.476)), module, Percall::DECAY_PARAMS + 2)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(50.357, 52.476)), module, Percall::DECAY_PARAMS + 3)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(8.048, 41.265)), module, Percall::VOL_PARAMS + 0)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(22.879, 41.265)), module, Percall::VOL_PARAMS + 1)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(37.709, 41.265)), module, Percall::VOL_PARAMS + 2)); | |||
| addParam(createParamCentered<BefacoTinyKnob>(mm2px(Vec(52.54, 41.265)), module, Percall::VOL_PARAMS + 3)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(5.385, 53.912)), module, Percall::DECAY_PARAMS + 0)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(20.292, 53.912)), module, Percall::DECAY_PARAMS + 1)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(35.173, 53.912)), module, Percall::DECAY_PARAMS + 2)); | |||
| addParam(createParam<BefacoSlidePot>(mm2px(Vec(49.987, 53.912)), module, Percall::DECAY_PARAMS + 3)); | |||
| addParam(createParam<CKSS>(mm2px(Vec(13.365, 58.672)), module, Percall::CHOKE_PARAMS + 0)); | |||
| addParam(createParam<CKSS>(mm2px(Vec(42.993, 58.672)), module, Percall::CHOKE_PARAMS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(7.173, 12.894)), module, Percall::CH_INPUTS + 0)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(20.335, 12.894)), module, Percall::CH_INPUTS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(40.347, 12.894)), module, Percall::CH_INPUTS + 2)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(53.492, 12.894)), module, Percall::CH_INPUTS + 3)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(30.341, 18.236)), module, Percall::STRENGTH_INPUT)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(7.173, 24.834)), module, Percall::TRIG_INPUTS + 0)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(18.547, 23.904)), module, Percall::TRIG_INPUTS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(42.218, 23.904)), module, Percall::TRIG_INPUTS + 2)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(53.453, 24.834)), module, Percall::TRIG_INPUTS + 3)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(5.093, 101.799)), module, Percall::CV_INPUTS + 0)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(15.22, 101.799)), module, Percall::CV_INPUTS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(25.347, 101.799)), module, Percall::CV_INPUTS + 2)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(35.474, 101.799)), module, Percall::CV_INPUTS + 3)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(45.541, 101.699)), module, Percall::CH_OUTPUTS + 0)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(55.624, 101.699)), module, Percall::CH_OUTPUTS + 1)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(45.541, 113.696)), module, Percall::CH_OUTPUTS + 2)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(55.624, 113.696)), module, Percall::CH_OUTPUTS + 3)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(5.093, 113.74)), module, Percall::ENV_OUTPUTS + 0)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(15.22, 113.74)), module, Percall::ENV_OUTPUTS + 1)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(25.347, 113.74)), module, Percall::ENV_OUTPUTS + 2)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(35.474, 113.74)), module, Percall::ENV_OUTPUTS + 3)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(7.15, 12.905)), module, Percall::CH_INPUTS + 0)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(20.298, 12.905)), module, Percall::CH_INPUTS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(40.266, 12.905)), module, Percall::CH_INPUTS + 2)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(53.437, 12.905)), module, Percall::CH_INPUTS + 3)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(30.282, 18.221)), module, Percall::STRENGTH_INPUT)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(7.15, 24.827)), module, Percall::TRIG_INPUTS + 0)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(18.488, 23.941)), module, Percall::TRIG_INPUTS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(42.171, 23.95)), module, Percall::TRIG_INPUTS + 2)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(53.437, 24.827)), module, Percall::TRIG_INPUTS + 3)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(5.037, 101.844)), module, Percall::CV_INPUTS + 0)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(15.159, 101.844)), module, Percall::CV_INPUTS + 1)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(25.28, 101.844)), module, Percall::CV_INPUTS + 2)); | |||
| addInput(createInputCentered<BefacoInputPort>(mm2px(Vec(35.402, 101.844)), module, Percall::CV_INPUTS + 3)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(45.524, 101.844)), module, Percall::CH_OUTPUTS + 0)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(55.645, 101.844)), module, Percall::CH_OUTPUTS + 1)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(45.524, 113.766)), module, Percall::CH_OUTPUTS + 2)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(55.645, 113.766)), module, Percall::CH_OUTPUTS + 3)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(5.037, 113.766)), module, Percall::ENV_OUTPUTS + 0)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(15.159, 113.766)), module, Percall::ENV_OUTPUTS + 1)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(25.28, 113.766)), module, Percall::ENV_OUTPUTS + 2)); | |||
| addOutput(createOutputCentered<BefacoOutputPort>(mm2px(Vec(35.402, 113.766)), module, Percall::ENV_OUTPUTS + 3)); | |||
| addChild(createLightCentered<SmallLight<RedLight>>(mm2px(Vec(8.107, 49.221)), module, Percall::LEDS + 0)); | |||
| addChild(createLightCentered<SmallLight<RedLight>>(mm2px(Vec(22.934, 49.221)), module, Percall::LEDS + 1)); | |||