Skip to content

Commit

Permalink
Merge pull request #5 from pfzzz/init-fix
Browse files Browse the repository at this point in the history
Add already scaled values of ms, fix init vals
  • Loading branch information
0mars committed Nov 2, 2019
2 parents 11e4d71 + 7a8d97a commit c2a6e46
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/OhGates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@ struct OhGates : Module {
NUM_LIGHTS
};

OhGates() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(BUFFER_SIZE_PARAM, 0.f, 1.f, 0.f, "");
configParam(GATE_LENGTH_PARAM, 0.f, 1.f, 0.f, "");
}

dsp::SchmittTrigger trigger_in;
dsp::SchmittTrigger reset_in;
int index;
int current = 0;
int num_triggers = 1;

Expand All @@ -49,6 +42,12 @@ struct OhGates : Module {
int remaining_samples = 0;
int sampleRate = 0;

OhGates() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(BUFFER_SIZE_PARAM, 0.f, 10.f, 0.f, "");
configParam(GATE_LENGTH_PARAM, 20.f, 6000.f, 0.f, "");
}

void process(const ProcessArgs& args) override {
if (inputs[GATE_IN_INPUT].isConnected()) {
trigger_in.process(inputs[GATE_IN_INPUT].getVoltage());
Expand Down Expand Up @@ -86,15 +85,15 @@ struct OhGates : Module {

int get_num_gates_to_buffer()
{
float val = params[BUFFER_SIZE_PARAM].getValue() * 10;
float val = params[BUFFER_SIZE_PARAM].getValue();
return (int)val;
}

float get_gate_time()
{
float val = params[GATE_LENGTH_PARAM].getValue() * 6000;
if (val < 1) {
val = 1;
float val = params[GATE_LENGTH_PARAM].getValue();
if (val < 20) {
val = 20;
}

return val/1000;
Expand Down

0 comments on commit c2a6e46

Please sign in to comment.