Skip to content

Commit

Permalink
implement Frame Step output to fix VCVRack#36
Browse files Browse the repository at this point in the history
  • Loading branch information
jweather committed Jun 28, 2018
1 parent dd25b17 commit 3146d99
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Frames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ struct Frames : Module {
frames::PolyLfo poly_lfo;
bool poly_lfo_mode = false;
uint16_t lastControls[4] = {};
int16_t lastPosition = -1;

SchmittTrigger addTrigger;
SchmittTrigger delTrigger;
PulseGenerator frameStepPulse;

Frames();
void step() override;
Expand Down Expand Up @@ -196,6 +198,10 @@ void Frames::step() {
}
}
keyframer.Evaluate(timestampMod);

if (keyframer.position() != lastPosition) {
frameStepPulse.trigger(1e-3f);
}
}

// Get gains
Expand All @@ -221,6 +227,7 @@ void Frames::step() {
for (int i = 0; i < 4; i++) {
lastControls[i] = controls[i];
}
lastPosition = keyframer.position();

// Get inputs
float all = ((int)params[OFFSET_PARAM].value == 1) ? 10.0 : 0.0;
Expand All @@ -247,6 +254,9 @@ void Frames::step() {

outputs[MIX_OUTPUT].value = clamp(mix / 2.0, -10.0f, 10.0f);

float deltaTime = engineGetSampleTime();
outputs[FRAME_STEP_OUTPUT].value = frameStepPulse.process(deltaTime) ? 10.f : 0.f;

// Set lights
for (int i = 0; i < 4; i++) {
lights[GAIN1_LIGHT + i].setBrightness(gains[i]);
Expand Down

0 comments on commit 3146d99

Please sign in to comment.