Skip to content

Commit

Permalink
Voice: Remove remove expapprox mode; use approximation for exp VCA
Browse files Browse the repository at this point in the history
Remove the experimental exp vs expapprox VCA modes, and use x**5
for the exponential approximation, calling the mode 'LinExp'.

There are now three modes: exp env + lin vca (classic analog),
lin env + lin VCA (MiMi-a linear VCA mode), lin env + exp VCA
(MiMi-a exponential (default) VCA mode).
  • Loading branch information
Ricard Wanderlof committed Mar 18, 2024
1 parent c056462 commit 50f0828
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugins/mimid/Engine/ParamDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
PARAMPOINTS(SP_KEYSYNC, " Free ", "KeySync")
PARAMPOINTS(SP_OSC3WAVE, " Off ", "-1 Squ", "-2 Squ", "-2 Pul", "Noise")
PARAMPOINTS(SP_FILTERTYPE, " 24 ", "SVF", "SVF+", "SVFN") /* not used */
PARAMPOINTS(SP_ENVMODE, " Exp ", " Lin ", "LinExp", "LinX5")
PARAMPOINTS(SP_ENVMODE, " Exp ", " Lin ", "LinExp")

// Parameters

Expand Down
5 changes: 2 additions & 3 deletions plugins/mimid/Engine/SynthEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,8 @@ class SynthEngine
void procEnvMode(float param)
{
// Exp env / Lin VCA - Lin env / Lin VCA - Lin env / Exp VCA
ForEachVoice(env.setLinear(param>0.25));
ForEachVoice(expvca = (param>0.50));
ForEachVoice(expapprox = (param>0.75));
ForEachVoice(env.setLinear(param>0.33));
ForEachVoice(expvca = (param>0.67));
}
void processOsc2Xmod(float param)
{
Expand Down
13 changes: 6 additions & 7 deletions plugins/mimid/Engine/Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ class Voice
bool oscmodEnable; // Oscillator modulation output enabled

bool expvca;
bool expapprox;

int voiceNumber; // Handy to have in the voice itself

Expand Down Expand Up @@ -179,7 +178,6 @@ class Voice
// fenvd=new DelayLine(Samples*2);
oscmodEnable = false;
expvca = false;
expapprox = false;
lfo2.waveForm = 1; // Triangle
voiceNumber = 0; // Until someone else says something else
unused1=unused2=0; // TODO: Remove
Expand Down Expand Up @@ -312,11 +310,12 @@ class Voice

// VCA
if (expvca) {
if (expapprox)
envVal *= envVal * envVal * envVal * envVal; // x5
else
//envVal *= envVal * envVal; // cube
envVal = expf(7.5*(envVal-1)); // 1..0 -> 0..-65 dB
// Approximate exponential curve with x**5:
// - Faster to calculate yet reasonable approximation
// - Actually goes down to zero when envelope goes t0 0
// Empirically, MiMi-a exponential VCA would be:
// envVal = expf(7.5*(envVal-1)); // 1..0 -> 0..-65 dB
envVal *= envVal * envVal * envVal * envVal;
}
x1 *= envVal;
return x1;
Expand Down

0 comments on commit 50f0828

Please sign in to comment.