Skip to content

Commit

Permalink
A collection of fixes from the side project (#1469)
Browse files Browse the repository at this point in the history
1. LFO Temposync Works
2. Legato mode fix for multi-triggered legatos
3. Accessibility improvements
4. ADSR better about zero stage skips and adds
   (non-exposed) delay
  • Loading branch information
baconpaul authored Jan 1, 2025
1 parent d6df8b3 commit 0925adf
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/engine/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ void Group::setupOnUnstream(engine::Engine &e)
{
stepLfos[i].setSampleRate(sampleRate, sampleRateInv);

stepLfos[i].assign(&modulatorStorage[i], endpoints.lfo[i].rateP, nullptr, getEngine()->rng);
stepLfos[i].assign(&modulatorStorage[i], endpoints.lfo[i].rateP, &(getEngine()->transport),
getEngine()->rng);
curveLfos[i].assign(&modulatorStorage[i], &(getEngine()->transport));
}

for (int p = 0; p < processorCount; ++p)
Expand Down Expand Up @@ -577,8 +579,9 @@ void Group::resetLFOs(int whichLFO)
{
stepLfos[i].setSampleRate(sampleRate, sampleRateInv);

stepLfos[i].assign(&modulatorStorage[i], endpoints.lfo[i].rateP, nullptr,
getEngine()->rng);
stepLfos[i].assign(&modulatorStorage[i], endpoints.lfo[i].rateP,
&(getEngine()->transport), getEngine()->rng);
curveLfos[i].assign(&modulatorStorage[i], &(getEngine()->transport));
}
else if (lfoEvaluator[i] == CURVE)
{
Expand Down
22 changes: 21 additions & 1 deletion src/modulation/modulators/curvelfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,25 @@ struct CurveLFO : SampleRateSupport

slfo_t::Shape curveShape{slfo_t::SINE};

private:
modulation::ModulatorStorage *settings{nullptr};
engine::Transport *td{nullptr};

public:
void assign(modulation::ModulatorStorage *s, engine::Transport *t)
{
settings = s;
td = t;
}

float envelope_rate_linear_nowrap(float f)
{
return blockSize * sampleRateInv * dsp::twoToTheXTable.twoToThe(-f);
}

void attack(float initPhase, ModulatorStorage::ModulatorShape shape)
{
assert(settings && td);
switch (shape)
{
case ModulatorStorage::LFO_RAMP:
Expand Down Expand Up @@ -85,10 +97,18 @@ struct CurveLFO : SampleRateSupport
}

uint32_t smp{0};
datamodel::pmd tsConverter{datamodel::pmd().asLfoRate()};
void process(const float rate, const float deform, const float delay, const float attack,
const float release, bool useEnv, bool unipolar, bool isGated)
{
simpleLfo.process_block(rate, deform, curveShape);
float tsRatio{1.0};
float rt = rate;
if (settings && td && settings->temposync)
{
rt = -tsConverter.snapToTemposync(-rt);
tsRatio = td->tempo / 120.0;
}
simpleLfo.process_block(rt, deform, curveShape, false, tsRatio);
auto lfov = simpleLfo.lastTarget;
if (unipolar)
lfov = (lfov + 1) * 0.5;
Expand Down
1 change: 1 addition & 0 deletions src/voice/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void Voice::voiceStarted()
else if (lfoEvaluator[i] == CURVE)
{
curveLfos[i].setSampleRate(sampleRate, sampleRateInv);
curveLfos[i].assign(&zone->modulatorStorage[i], &engine->transport);
curveLfos[i].attack(ms.start_phase, ms.modulatorShape);
}
else if (lfoEvaluator[i] == ENV)
Expand Down

0 comments on commit 0925adf

Please sign in to comment.