Skip to content

Commit

Permalink
Various fixes and reversal of PW pot scaling
Browse files Browse the repository at this point in the history
The reversal of pot scaling is in preparation of a survey of instrument
specific values so that a good universally acceptable solution can be
found.
  • Loading branch information
image-et-son committed Jan 25, 2022
1 parent a082030 commit a7ed537
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion common/lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void updateSpeed(struct lfo_s * lfo)
{
int32_t spd;

spd=exponentialCourse(UINT16_MAX-lfo->speedCV,8000.0,65535.0f);
spd=exponentialCourse(UINT16_MAX-lfo->speedCV,8000.0f,65535.0f);

lfo->speed=spd<<4;
}
Expand Down
8 changes: 4 additions & 4 deletions common/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ LOWERCODESIZE int8_t preset_loadCurrent(uint16_t number, uint8_t loadFromBuffer)
// rescale the LFO speed (the speed switch paramter was omitted from version 8 after)
// the exponential factor (ratio) was changed from 13000 to 8000
currentPreset.continuousParameters[cpLFOFreq]=(uint16_t)(0.615385f*(float)currentPreset.continuousParameters[cpLFOFreq])+25205;
// . The slow LFO variant was made a factor of 8 slower
if (readVar==0) currentPreset.continuousParameters[cpLFOFreq]-=16635; // this used to be the fast setting
// The slow LFO variant in version 7 / 2.1RC3 was made a factor of 8 slower comapred to the fast setting, so:
if (readVar==0) currentPreset.continuousParameters[cpLFOFreq]-=16635; // =0 used to be the slow setting

for(i=2;i<6;i+=3) // this picks up cpAPW (=2) and cpBPW (=5)
currentPreset.continuousParameters[i]=(currentPreset.continuousParameters[i]>62128)?FULL_RANGE:((uint16_t)(currentPreset.continuousParameters[i]*1.0323f)+1400);
//for(i=2;i<6;i+=3) // this picks up cpAPW (=2) and cpBPW (=5)
//currentPreset.continuousParameters[i]=(currentPreset.continuousParameters[i]>62128)?FULL_RANGE:((uint16_t)//(currentPreset.continuousParameters[i]*1.0323f)+1400);
}
else if (readVar<=3) currentPreset.steppedParameters[spEnvRouting]=readVar;

Expand Down
29 changes: 14 additions & 15 deletions common/synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ struct deadband freqFineDeadband = { HALF_RANGE, 0, 4096, 512};

static uint16_t rescaledPW(uint16_t pwPotValue)
{
uint16_t outVal;
outVal=(pwPotValue>1400)?(pwPotValue-1400):0;
outVal-=(outVal>>5); // extend the range by 2^11

return outVal;
//uint16_t outVal;
//outVal=(pwPotValue>1400)?(pwPotValue-1400):0;
//outVal-=(outVal>>5); // extend the range by 2^11
//return outVal;
return pwPotValue;
}

static void addWheelToTunedCVs(void) // this function is specific for the case in which there are only wheel changes. Could also be moved to inside wheel event...
Expand Down Expand Up @@ -723,6 +723,12 @@ static void refreshLfoSettings(void)
}
}

synth.lfoAmt=currentPreset.continuousParameters[cpLFOAmt];
synth.lfoAmt=(synth.lfoAmt<POT_DEAD_ZONE)?0:(synth.lfoAmt-POT_DEAD_ZONE);
synth.lfoAmt=((expf(((float)synth.lfoAmt)/15000.0f )-1.0f)*840.57f);

lfo_setFreq(&synth.lfo,currentPreset.continuousParameters[cpLFOFreq]);

if(currentPreset.steppedParameters[spModwheelTarget]==0) // targeting lfo?
{
lfo_setAmt(&synth.lfo, satAddU16U16(synth.lfoAmt, synth.modwheelAmount));
Expand Down Expand Up @@ -1015,6 +1021,9 @@ void refreshPresetMode(void)

ui_setNoActivePot();
ui.presetModified=0;
// trigger application of vib changes
ui.vibAmountChangePending=1;
ui.vibFreqChangePending=1;
ui.digitInput=(settings.presetMode)?diLoadDecadeDigit:diSynth;

}
Expand Down Expand Up @@ -1268,16 +1277,6 @@ void synth_update(void)
refreshEnvSettings();
else if (ui.lastActivePot==ppMVol)
synth.masterVolume = potmux_getValue(ppMVol);
else if (ui.lastActivePot==ppLFOAmt)
{
synth.lfoAmt=currentPreset.continuousParameters[cpLFOAmt];
synth.lfoAmt=(synth.lfoAmt<POT_DEAD_ZONE)?0:(synth.lfoAmt-POT_DEAD_ZONE);
synth.lfoAmt=((expf(((float)synth.lfoAmt)/15000.0f )-1.0f)*840.57f);
}
else if (ui.lastActivePot==ppLFOFreq)
{
lfo_setFreq(&synth.lfo,currentPreset.continuousParameters[cpLFOFreq]);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions common/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void ui_checkIfDataPotChanged(void)
break;
}

if (ui.menuParamSelectChange==1) // this make sure the the MANUAL_PRESET_PAGE is only stored the frist time a NEW menu parameter is CHANGED
if (ui.menuParamSelectChange==1) // this make sure the the MANUAL_PRESET_PAGE is only stored the first time a NEW menu parameter is CHANGED
{
if(!settings.presetMode)
preset_saveCurrent(MANUAL_PRESET_PAGE);
Expand Down Expand Up @@ -860,7 +860,7 @@ void ui_init(void)

ui.presetAwaitingNumber=-1;
ui.lastActivePotValue=-1;
ui.presetModified=1;
ui.presetModified=0;
settings.presetMode=1; // start in preset mode
ui.digitInput=diSynth; // panel mode
ui.activeParamIdx=0; // select clock/speed
Expand Down

0 comments on commit a7ed537

Please sign in to comment.