Skip to content

Commit

Permalink
Make sure 0 portamento is 0 in all modes (#6986)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruselj authored Apr 23, 2023
1 parent 31d85fa commit 768fb4f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/common/dsp/SurgeVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,20 +617,25 @@ void SurgeVoice::update_portamento()
int quantStep = 12;

if (!storage->isStandardTuning && storage->currentScale.count > 1)
{
quantStep = storage->currentScale.count;
}

// portamento constant rate mode (multiply portamento time with every octave traversed (or scale
// length in case of microtuning)
// portamento constant rate mode (multiply portamento time with every octave traversed
// (or scale length in case of microtuning)
if (scene->portamento.porta_constrate)
{
const_rate_factor =
(1.f /
((1.f / quantStep) * fabs(state.getPitch(storage) - state.portasrc_key) + 0.00001));
}

state.portaphase +=
storage->envelope_rate_linear(localcopy[scene->portamento.param_id_in_scene].f) *
(scene->portamento.temposync ? storage->temposyncratio : 1.f) * const_rate_factor;

if (state.portaphase < 1)
if ((state.portaphase < 1) &&
(localcopy[scene->portamento.param_id_in_scene].f > scene->portamento.val_min.f))
{
// exponential or linear key traversal for the portamento
float phase;
Expand All @@ -649,15 +654,23 @@ void SurgeVoice::update_portamento()

state.pkey = (1.f - phase) * state.portasrc_key + (float)phase * state.getPitch(storage);

if (scene->portamento.porta_gliss) // quantize portamento to keys
// quantize portamento to keys
if (scene->portamento.porta_gliss)
{
state.pkey = floor(state.pkey + 0.5);
}

state.porta_doretrigger = false;

if (scene->portamento.porta_retrigger)
{
retriggerPortaIfKeyChanged();
}
}
else
{
state.pkey = state.getPitch(storage);
}

state.pkey += noteExpressions[PITCH];
}
Expand Down

0 comments on commit 768fb4f

Please sign in to comment.