diff options
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/device-functions.c b/device-functions.c index d27cf76..e5fbeea 100644 --- a/device-functions.c +++ b/device-functions.c @@ -2721,6 +2721,12 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int (*atten_range)--; + float max1 = fabs(globals.Flash.min_ampl[channel]); + float max2 = fabs(globals.Flash.max_ampl[channel]); + if (max2 > max1) { + max1 = max2; + } + if (*atten_range == -1) { // no valid attenuators use_atten = 1.0; @@ -2738,11 +2744,6 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int // Limit max voltage in attenuator mode to 93% of full maximum, // to avoid the region in AVPs where PW shifts at high amplitudes - float max1 = fabs(globals.Flash.min_ampl[channel]); - float max2 = fabs(globals.Flash.max_ampl[channel]); - if (max2 > max1) { - max1 = max2; - } if ((use_ampl * use_atten) > (globals.Flash.atten_percent_max_ampl[channel] * max1)) { continue; @@ -2753,7 +2754,25 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int /* apply pw ampl/pol tweaks */ if (parameter == pwl_pw_values) { // tweak pw shifts - tweaked_use_ampl = use_ampl + globals.Flash.pw_range_pol_tweaks[channel][range_i][pw_polarity]; + float dist_frac = 1.0; // use same tweaking for all amplitudes by default + + if (fabs(globals.Flash.distort_fully_below_ampl[channel]) > 0.0) { + // if distort_fully_below_ampl is specified (typically for AVR-E, AVIR, etc), + // distort zero at max ampl, and fully below specified ampl + dist_frac = (max1 - fabs(globals.ChannelState[channel].amplitude)) / + (max1 - fabs(globals.Flash.distort_fully_below_ampl[channel])); + if (dist_frac > 1.0) { + dist_frac = 1.0; + } + + if (dist_frac < 0.0) { + dist_frac = 0.0; + } + } + + float correction = dist_frac * globals.Flash.pw_range_pol_tweaks[channel][range_i][pw_polarity]; + tweaked_use_ampl = use_ampl + correction; + } else if (parameter == pwl_ampl_values) { // compensate for attenuators tweaked_use_ampl = use_ampl * use_atten; |