Browse Source

Use 1ms pulse for trigger and retrigger of SEQ3

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
b8e264473c
1 changed files with 16 additions and 5 deletions
  1. +16
    -5
      src/SEQ3.cpp

+ 16
- 5
src/SEQ3.cpp View File

@@ -31,11 +31,12 @@ struct SEQ3 : Module {


bool running = true; bool running = true;
SchmittTrigger clockTrigger; // for external clock SchmittTrigger clockTrigger; // for external clock
// For buttons
SchmittTrigger runningTrigger; SchmittTrigger runningTrigger;
SchmittTrigger resetTrigger; SchmittTrigger resetTrigger;
SchmittTrigger gateTriggers[8];
float phase = 0.0; float phase = 0.0;
int index = 0; int index = 0;
SchmittTrigger gateTriggers[8];
bool gateState[8] = {}; bool gateState[8] = {};
float stepLights[8] = {}; float stepLights[8] = {};


@@ -45,6 +46,7 @@ struct SEQ3 : Module {
CONTINUOUS, CONTINUOUS,
}; };
GateMode gateMode = TRIGGER; GateMode gateMode = TRIGGER;
PulseGenerator gatePulse;


// Lights // Lights
float runningLight = 0.0; float runningLight = 0.0;
@@ -137,7 +139,7 @@ void SEQ3::step() {
// Reset // Reset
if (resetTrigger.process(params[RESET_PARAM].value + inputs[RESET_INPUT].value)) { if (resetTrigger.process(params[RESET_PARAM].value + inputs[RESET_INPUT].value)) {
phase = 0.0; phase = 0.0;
index = 999;
index = 8;
nextStep = true; nextStep = true;
resetLight = 1.0; resetLight = 1.0;
} }
@@ -150,16 +152,25 @@ void SEQ3::step() {
index = 0; index = 0;
} }
stepLights[index] = 1.0; stepLights[index] = 1.0;
gatePulse.trigger(1e-3);
} }


resetLight -= resetLight / lightLambda / gSampleRate; resetLight -= resetLight / lightLambda / gSampleRate;


bool pulse = gatePulse.process(1.0 / gSampleRate);

// Gate buttons // Gate buttons
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if (gateTriggers[i].process(params[GATE_PARAM + i].value)) { if (gateTriggers[i].process(params[GATE_PARAM + i].value)) {
gateState[i] = !gateState[i]; gateState[i] = !gateState[i];
} }
float gate = (i == index && gateState[i] >= 1.0) ? 10.0 : 0.0;
float gateOn = (i == index && gateState[i] >= 1.0);
if (gateMode == TRIGGER)
gateOn = gateOn && pulse;
else if (gateMode == RETRIGGER)
gateOn = gateOn && !pulse;
float gate = gateOn ? 10.0 : 0.0;

outputs[GATE_OUTPUT + i].value = gate; outputs[GATE_OUTPUT + i].value = gate;
stepLights[i] -= stepLights[i] / lightLambda / gSampleRate; stepLights[i] -= stepLights[i] / lightLambda / gSampleRate;
gateLights[i] = (gateState[i] >= 1.0) ? 1.0 - stepLights[i] : stepLights[i]; gateLights[i] = (gateState[i] >= 1.0) ? 1.0 - stepLights[i] : stepLights[i];
@@ -171,9 +182,9 @@ void SEQ3::step() {
float row3 = params[ROW3_PARAM + index].value; float row3 = params[ROW3_PARAM + index].value;
bool gatesOn = gateState[index]; bool gatesOn = gateState[index];
if (gateMode == TRIGGER) if (gateMode == TRIGGER)
gatesOn = gatesOn && nextStep;
gatesOn = gatesOn && pulse;
else if (gateMode == RETRIGGER) else if (gateMode == RETRIGGER)
gatesOn = gatesOn && !nextStep;
gatesOn = gatesOn && !pulse;
float gates = gatesOn ? 10.0 : 0.0; float gates = gatesOn ? 10.0 : 0.0;


// Outputs // Outputs


Loading…
Cancel
Save