~rantlivelintkale/extended-drive.lv2

4f51db721baf3ed30f1fac306ecea71ea7af8ad7 — Veikka Valtteri Kallinen 5 months ago d7a4e25 master
Change mix control to separate dry level control
2 files changed, 41 insertions(+), 37 deletions(-)

M lv2ttl/extended-drive.ttl.in
M src/main.c
M lv2ttl/extended-drive.ttl.in => lv2ttl/extended-drive.ttl.in +13 -12
@@ 94,22 94,13 @@
                lv2:symbol "post" ;
                lv2:name "Post" ;
                lv2:default 0.0 ;
                lv2:minimum -50.0 ;
                lv2:maximum 50.0 ;
                lv2:minimum -100.0 ;
                lv2:maximum 0.0 ;
                units:unit units:db ;
        ] , [
                a lv2:InputPort ,
                        lv2:ControlPort ;
                lv2:index 7 ;
                lv2:symbol "mix" ;
                lv2:name "Mix" ;
                lv2:default 1.0 ;
                lv2:minimum 0.0 ;
                lv2:maximum 1.0 ;
        ] , [
                a lv2:InputPort ,
                        lv2:ControlPort ;
                lv2:index 8 ;
                lv2:symbol "tone" ;
                lv2:name "Tone" ;
                lv2:default 0.5 ;


@@ 118,13 109,23 @@
        ] , [
                a lv2:InputPort ,
                        lv2:ControlPort ;
                lv2:index 9 ;
                lv2:index 8 ;
                lv2:symbol "mid" ;
                lv2:name "Mid" ;
                lv2:default 1.0 ;
                lv2:minimum 0.0 ;
                lv2:maximum 1.0 ;
        ] , [
                a lv2:InputPort ,
                        lv2:ControlPort ;
                lv2:index 9 ;
                lv2:symbol "dry" ;
                lv2:name "Dry" ;
                lv2:default -100.0 ;
                lv2:minimum -100.0 ;
                lv2:maximum 0.0 ;
                units:unit units:db ;
        ] , [
                a lv2:AudioPort ,
                        lv2:InputPort ;
                lv2:index 10 ;

M src/main.c => src/main.c +28 -25
@@ 16,9 16,9 @@ typedef enum {
	PRE         = 4,
	SOFT        = 5,
	POST        = 6,
	MIX         = 7,
	TONE        = 8,
	MID         = 9,
	TONE        = 7,
	MID         = 8,
	DRY         = 9,
	INPUT       = 10,
	OUTPUT      = 11,
} PortIndex;


@@ 311,9 311,9 @@ typedef struct {
	const float *pre;
	const float *soft;
	const float *post;
	const float *mix;
	const float *tone;
	const float *mid;
	const float *dry;
	const float *input;
	float *output;



@@ 504,15 504,15 @@ static void connect_port(LV2_Handle instance, uint32_t port, void *data)
	case POST:
		plugin->post = (const float *)data;
		break;
	case MIX:
		plugin->mix = (const float *)data;
		break;
	case TONE:
		plugin->tone = (const float *)data;
		break;
	case MID:
		plugin->mid = (const float *)data;
		break;
	case DRY:
		plugin->dry = (const float *)data;
		break;
	case INPUT:
		plugin->input = (const float *)data;
		break;


@@ 562,25 562,19 @@ static void run(LV2_Handle instance, uint32_t n_samples)
			float const pre         = lpf_process(db_co(*plugin->pre), &plugin->cf[3]);
			float const soft        = lpf_process(*plugin->soft > 0.f ? 1.f : 0.f, &plugin->cf[4]);
			float const post        = lpf_process(db_co(*plugin->post), &plugin->cf[5]);
			float const mix         = lpf_process(*plugin->mix, &plugin->cf[6]);
			float const tone        = lpf_process(*plugin->tone, &plugin->cf[7]);
			float const mid         = lpf_process(*plugin->mid, &plugin->cf[8]);
			float const tone        = lpf_process(*plugin->tone, &plugin->cf[6]);
			float const mid         = lpf_process(*plugin->mid, &plugin->cf[7]);
			float const dry         = lpf_process(db_co(*plugin->dry), &plugin->cf[8]);

			hpf_set(filter, plugin->rate_r, &plugin->hpf[0]);
			hpf_set(1000.f - 500.f * mid, plugin->rate_r, &plugin->hpf[1]);
			lpf_set(250.f + 250.f * mid, plugin->rate_r, &plugin->lpf[0]);

			float x = output[pos];
			// common DC block
			dcf_filter(&x, &plugin->dcf_z[0], plugin->dcf_r);

			// dry path
			float dry = x;
			// causes some 1dB drop in lowest frequencies
			dry_process(&dry, &plugin->fdlf[0]);
			const float x = output[pos];

			// wet path
			float wet = x;
			// blocks also DC
			wet = hpf_process(wet, &plugin->hpf[0]);

			{


@@ 599,6 593,7 @@ static void run(LV2_Handle instance, uint32_t n_samples)
			wet = wet * pre + envelope * bias;
			// causes some 1dB drop in lowest frequencies
			wet_process(&wet, &plugin->clf[0], soft);
			wet *= post;

			{
				// 1/g * (1 - rz^-1)


@@ 608,19 603,27 @@ static void run(LV2_Handle instance, uint32_t n_samples)
				wet = wet + (y - wet) * integration;
			}

			// dry & wet mix
			float y = dry + mix * (wet * post - dry);

			{
				// tone filter
				float tone_hpf = hpf_process(y, &plugin->hpf[1]);
				float tone_hpf = hpf_process(wet, &plugin->hpf[1]);

				float tone_lpf = lpf_process(y, &plugin->lpf[0]);
				float tone_lpf = lpf_process(wet, &plugin->lpf[0]);

				y = tone * tone_hpf + (1.f - tone) * tone_lpf;
				wet = tone * tone_hpf + (1.f - tone) * tone_lpf;
				// compensate
				wet *= 2;
			}

			dcf_filter(&y, &plugin->dcf_z[1], plugin->dcf_r);
			dcf_filter(&wet, &plugin->dcf_z[0], plugin->dcf_r);

			// dry path
			float dry_signal = x;
			// causes some 1dB drop in lowest frequencies
			dry_process(&dry_signal, &plugin->fdlf[0]);

			// dry & wet mix
			const float y = dry_signal * dry + wet;

			output[pos] = y;
		}
	}