Skip to content

Commit

Permalink
Stages: Make kSampleAndHoldDelay local because it depends on the samp…
Browse files Browse the repository at this point in the history
…le rate, which was made a class variable.
  • Loading branch information
AndrewBelt committed May 3, 2020
1 parent 6f2cc99 commit 9739c02
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions stages/segment_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ using namespace segment;
// output is high.
const int kRetrigDelaySamples = 32;

// S&H delay (for all those sequencers whose CV and GATE outputs are out of
// sync).
const size_t kSampleAndHoldDelay = kSampleRate * 2 / 1000; // 2 milliseconds

void SegmentGenerator::Init() {
process_fn_ = &SegmentGenerator::ProcessMultiSegment;

Expand Down Expand Up @@ -258,10 +254,14 @@ void SegmentGenerator::ProcessSampleAndHold(
parameters_[0].secondary);
ParameterInterpolator primary(&primary_, parameters_[0].primary, size);

// S&H delay (for all those sequencers whose CV and GATE outputs are out of
// sync).
const size_t sampleAndHoldDelay = sample_rate_ * 2 / 1000; // 2 milliseconds

while (size--) {
const float p = primary.Next();
gate_delay_.Write(*gate_flags);
if (gate_delay_.Read(kSampleAndHoldDelay) & GATE_FLAG_RISING) {
if (gate_delay_.Read(sampleAndHoldDelay) & GATE_FLAG_RISING) {
value_ = p;
}
active_segment_ = *gate_flags & GATE_FLAG_HIGH ? 0 : 1;
Expand Down

0 comments on commit 9739c02

Please sign in to comment.