Skip to content

Commit

Permalink
Filter: Maintain param consistency when changing filter type
Browse files Browse the repository at this point in the history
When filter type changes (e.g. type 4 -> 0), some related params are
also being manipulated (cutoff and resonance). The general principle
should be to alter the filter operational characteristic, while
maintaining the continuity of the input values from the controls.

This is achieved by tweaking a param's float_val, yet preserving
the param's int_val (set to the input value). This way a care should
be taken in the filter-type (param[4]) change logic, when manipulating
the related params (cutoff and resonance), to recall the param's
float_val from its current int_val and only after that modify the
float_val as needed.

Respectively, the cutoff and resonance params need to properly handle
the changes just as those made in filter-type cases.
  • Loading branch information
nomadbyte committed Apr 28, 2021
1 parent 245085d commit 371eb89
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions bristol/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ param(bristolOP *operator, bristolOPParams *param,
switch (index) {
case 0:
{
param->param[index].int_val = intvalue;

if (param->param[4].int_val == 3) {
param->param[index].float_val =
gainTable[(int) (value * (CONTROLLER_RANGE - 1))].gain;
Expand All @@ -238,17 +240,17 @@ param(bristolOP *operator, bristolOPParams *param,
param->param[index].float_val = value / 3;
}
/*printf("Configuring filter %f\n", param->param[index].float_val); */
param->param[index].int_val = intvalue;
break;
}
case 1:
param->param[index].int_val = intvalue;

if (param->param[4].int_val == 1)
param->param[index].float_val =
gainTable[CONTROLLER_RANGE - 1
- (int) (value * (CONTROLLER_RANGE - 1))].gain;
else
param->param[index].float_val = value;
param->param[index].int_val = intvalue;
break;
case 2:
case 5: /* Gain */
Expand All @@ -268,8 +270,8 @@ param(bristolOP *operator, bristolOPParams *param,
if (intvalue > 1) {
param->param[index].int_val = intvalue;
} else if (value > 0) {
float floatvalue = ((float) param->param[0].int_val) /
(CONTROLLER_RANGE - 1);
float floatvalue =
((float) param->param[0].int_val) / CONTROLLER_RANGE;

param->param[index].int_val = 1;
/*
Expand All @@ -281,23 +283,23 @@ param(bristolOP *operator, bristolOPParams *param,
< (float) 0.000122)
param->param[0].float_val = (float) 0.000122;

floatvalue = ((float) param->param[1].int_val) /
(CONTROLLER_RANGE - 1);
floatvalue =
((float) param->param[1].int_val) / CONTROLLER_RANGE;

param->param[1].float_val =
gainTable[CONTROLLER_RANGE - 1
- (int) (floatvalue * (CONTROLLER_RANGE - 1))].gain;
} else {
float floatvalue = ((float) param->param[0].int_val) /
(CONTROLLER_RANGE - 1);
float floatvalue =
((float) param->param[0].int_val) / CONTROLLER_RANGE;

printf("Selected chamberlain filter\n");
param->param[index].int_val = 0;
param->param[0].float_val = value / 3;
param->param[0].float_val = floatvalue / 3;

floatvalue = ((float) param->param[1].int_val) /
(CONTROLLER_RANGE - 1);
param->param[1].float_val = value;
floatvalue =
((float) param->param[1].int_val) / CONTROLLER_RANGE;
param->param[1].float_val = floatvalue;
}
break;
case 6: /* LP/BP/HP */
Expand Down Expand Up @@ -380,7 +382,7 @@ static int operate(register bristolOP *operator, bristolVoice *voice,
*/

/* See if we are limited to lightweight filters */
if (param->param[4].int_val != 3)
if (param->param[4].int_val && param->param[4].int_val != 3)
{
if ((blo.flags & BRISTOL_LWF) || (mode == 1))
param->param[4].int_val = 0;
Expand Down Expand Up @@ -1001,7 +1003,7 @@ filterinit(bristolOP **operator, int index, int samplerate, int samplecount)
specs->spec.param[6].flags = BRISTOL_ROTARY|BRISTOL_SLIDER;

/*
* Now fill in the dco IO specs.
* Now fill in the filter IO specs.
*/
specs->spec.io[0].ioname = "input";
specs->spec.io[0].description = "Filter Input signal";
Expand Down

0 comments on commit 371eb89

Please sign in to comment.