Skip to content

Commit

Permalink
cleanup and failed attempt to fix audio click on first transition. Wi…
Browse files Browse the repository at this point in the history
…ll have to get back to it later
  • Loading branch information
vberthiaume committed Oct 24, 2024
1 parent 921ec39 commit 70ec078
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions source/DSP/ProPhatSynthesiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ class EffectsCrossfadeProcessor
enum EffectType
{
verb = 0,
phaser,
chorus,
transitioning
};
EffectType curEffect = EffectType::verb;

EffectsCrossfadeProcessor() = default;

Expand All @@ -48,16 +47,22 @@ class EffectsCrossfadeProcessor
void changeEffect()
{
if (curEffect == EffectType::verb)
curEffect = EffectType::phaser;
else if (curEffect == EffectType::phaser)
curEffect = EffectType::chorus;
else if (curEffect == EffectType::chorus)
curEffect = EffectType::verb;
else
jassertfalse;

if (curEffect == EffectType::verb)
setGain (1.0);
smoothedGain.setTargetValue (1.);
else
setGain (0.0);
smoothedGain.setTargetValue (0.);

//this does not resolve the click we get on the first transition
//if (curEffect == EffectType::verb)
// smoothedGain.setTargetValue (0.);
//else
// smoothedGain.setTargetValue (1.);
};

EffectType getCurrentEffectType() const
Expand Down Expand Up @@ -128,16 +133,13 @@ class EffectsCrossfadeProcessor
}

private:
/**
Can be used to set a custom gain level to combine the two buffers.
@param gain The gain level of the left buffer.
*/
void setGain (double gain)
{
smoothedGain.setTargetValue (std::clamp (gain, 0.0, 1.0));
}

juce::SmoothedValue<double, juce::ValueSmoothingTypes::Linear> smoothedGain;

//TODO: this needs to be stored and retreived from the state
EffectType curEffect = EffectType::verb;

//changing the default curEffect to chorus DOES fix the click on first transition. Weird man
//EffectType curEffect = EffectType::chorus;
};

//==================================================
Expand Down Expand Up @@ -214,7 +216,7 @@ class EffectsProcessor

if (currentEffectType == EffectsCrossfadeProcessor<T>::EffectType::verb)
verbWrapper->process (context);
else if (currentEffectType == EffectsCrossfadeProcessor<T>::EffectType::phaser)
else if (currentEffectType == EffectsCrossfadeProcessor<T>::EffectType::chorus)
chorusWrapper->process (context);
else
jassertfalse; //unknown effect!!
Expand Down

0 comments on commit 70ec078

Please sign in to comment.