#include "aepelzen.hpp" #include "dsp/digital.hpp" #define NUM_CHANNELS 4 struct Werner : Module { enum ParamIds { TIME_PARAM, DELTA_PARAM, NUM_PARAMS }; enum InputIds { CV_INPUT, NUM_INPUTS = NUM_CHANNELS }; enum OutputIds { GATE_OUTPUT, NUM_OUTPUTS = NUM_CHANNELS }; enum LightIds { NUM_LIGHTS }; Werner() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} void step() override; PulseGenerator gatePulse[NUM_CHANNELS]; float lastValue[NUM_CHANNELS]; int res = 16; float minDelta = 0; int frame = 0; }; void Werner::step() { //max time is about 100ms at 44kHz res = (int)clamp(params[TIME_PARAM].value * 4400.0f, 16.0f, 4400.0f); minDelta = params[DELTA_PARAM].value * 2.0f; if(++frame > res) { for(int i=0; i minDelta) { gatePulse[i].trigger(0.01); } lastValue[i] = value; } frame = 0; } for(int i=0; i(Vec(6, 30), module, Werner::TIME_PARAM, 0.0, 1.0, 0.0)); addParam(ParamWidget::create(Vec(6, 75), module, Werner::DELTA_PARAM, 0.0, 1.0, 0.0)); for(int i=0;i(Vec(3, 125 + i*30), Port::INPUT, module, Werner::CV_INPUT + i)); addOutput(Port::create(Vec(3, 250 + i*30), Port::OUTPUT, module, Werner::GATE_OUTPUT + i)); } } Model *modelWerner = Model::create("Aepelzens Modules", "Werner", "CV-to-Trigger", UTILITY_TAG);