Esempio n. 1
0
static void activateGsm(LADSPA_Handle instance) {
	Gsm *plugin_data = (Gsm *)instance;
	biquad *blf = plugin_data->blf;
	int count = plugin_data->count;
	LADSPA_Data *dry = plugin_data->dry;
	gsm_signal *dst = plugin_data->dst;
	float fs = plugin_data->fs;
	gsm handle = plugin_data->handle;
	int resamp = plugin_data->resamp;
	float rsf = plugin_data->rsf;
	gsm_signal *src = plugin_data->src;
#line 41 "gsm_1215.xml"
	count = 0;
	memset(src, 0, sizeof(gsm_signal) * 160);
	memset(dst, 0, sizeof(gsm_signal) * 163);
	memset(dry, 0, sizeof(LADSPA_Data) * 160 * resamp);
	handle = gsm_create();
	biquad_init(blf);
	hs_set_params(blf, 3500.0f, -50.0f, 0.7f, fs);
	plugin_data->blf = blf;
	plugin_data->count = count;
	plugin_data->dry = dry;
	plugin_data->dst = dst;
	plugin_data->fs = fs;
	plugin_data->handle = handle;
	plugin_data->resamp = resamp;
	plugin_data->rsf = rsf;
	plugin_data->src = src;

}
Esempio n. 2
0
static LADSPA_Handle instantiateSurroundEncoder(
 const LADSPA_Descriptor *descriptor,
 unsigned long s_rate) {
	SurroundEncoder *plugin_data = (SurroundEncoder *)malloc(sizeof(SurroundEncoder));
	LADSPA_Data *buffer = NULL;
	unsigned int buffer_pos;
	unsigned int buffer_size;
	biquad *hc = NULL;
	biquad *lc = NULL;

#line 32 "surround_encoder_1401.xml"
	buffer_size = (int)(0.0072f * s_rate);
	buffer_pos = 0;
	buffer = calloc(buffer_size, sizeof(LADSPA_Data));
	lc = malloc(sizeof(biquad));
	hc = malloc(sizeof(biquad));
	biquad_init(lc);
	biquad_init(hc);
	ls_set_params(lc, 100.0f, -70.0f, 1.0f, s_rate);
	hs_set_params(hc, 7000.0f, -70.0f, 1.0f, s_rate);

	plugin_data->buffer = buffer;
	plugin_data->buffer_pos = buffer_pos;
	plugin_data->buffer_size = buffer_size;
	plugin_data->hc = hc;
	plugin_data->lc = lc;

	return (LADSPA_Handle)plugin_data;
}
Esempio n. 3
0
static void runAddingDj_eq(LADSPA_Handle instance, unsigned long sample_count) {
	Dj_eq *plugin_data = (Dj_eq *)instance;
	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;

	/* Lo gain (dB) (float value) */
	const LADSPA_Data lo = *(plugin_data->lo);

	/* Mid gain (dB) (float value) */
	const LADSPA_Data mid = *(plugin_data->mid);

	/* Hi gain (dB) (float value) */
	const LADSPA_Data hi = *(plugin_data->hi);

	/* Input L (array of floats of length sample_count) */
	const LADSPA_Data * const left_input = plugin_data->left_input;

	/* Input R (array of floats of length sample_count) */
	const LADSPA_Data * const right_input = plugin_data->right_input;

	/* Output L (array of floats of length sample_count) */
	LADSPA_Data * const left_output = plugin_data->left_output;

	/* Output R (array of floats of length sample_count) */
	LADSPA_Data * const right_output = plugin_data->right_output;
	biquad * filters = plugin_data->filters;
	float fs = plugin_data->fs;

#line 42 "dj_eq_1901.xml"
	unsigned long pos;
	unsigned int i;
	float samp;

	for (i=0; i<2; i++) {
	  eq_set_params(&filters[i*BANDS + 0], 100.0f, lo, PEAK_BW, fs);
	  eq_set_params(&filters[i*BANDS + 1], 1000.0f, mid, PEAK_BW, fs);
	  hs_set_params(&filters[i*BANDS + 2], 10000.0f, hi, SHELF_SLOPE, fs);
	}

	for (pos = 0; pos < sample_count; pos++) {
	  samp = biquad_run(&filters[0], left_input[pos]);
	  samp = biquad_run(&filters[1], samp);
	  samp = biquad_run(&filters[2], samp);
	  buffer_write(left_output[pos], samp);

	  samp = biquad_run(&filters[3], right_input[pos]);
	  samp = biquad_run(&filters[4], samp);
	  samp = biquad_run(&filters[5], samp);
	  buffer_write(right_output[pos], samp);
	}

	*(plugin_data->latency) = 3; //XXX is this right?
}
Esempio n. 4
0
static void activateDj_eq_mono(LADSPA_Handle instance) {
	Dj_eq_mono *plugin_data = (Dj_eq_mono *)instance;
	biquad *filters = plugin_data->filters;
	float fs = plugin_data->fs;
#line 33 "dj_eq_1901.xml"
	biquad_init(&filters[0]);
	eq_set_params(&filters[0], 100.0f, 0.0f, PEAK_BW, fs);
	biquad_init(&filters[1]);
	eq_set_params(&filters[1], 1000.0f, 0.0f, PEAK_BW, fs);
	biquad_init(&filters[2]);
	hs_set_params(&filters[2], 10000.0f, 0.0f, SHELF_SLOPE, fs);
	plugin_data->filters = filters;
	plugin_data->fs = fs;

}
Esempio n. 5
0
static void activateDj_eq(LADSPA_Handle instance) {
	Dj_eq *plugin_data = (Dj_eq *)instance;
	biquad *filters = plugin_data->filters;
	float fs = plugin_data->fs;
#line 33 "dj_eq_1901.xml"
	int i;

	for (i=0; i<2; i++) {
	  biquad_init(&filters[i*BANDS + 0]);
	  eq_set_params(&filters[i*BANDS + 0], 100.0f, 0.0f, PEAK_BW, fs);
	  biquad_init(&filters[i*BANDS + 1]);
	  eq_set_params(&filters[i*BANDS + 1], 1000.0f, 0.0f, PEAK_BW, fs);
	  biquad_init(&filters[i*BANDS + 2]);
	  hs_set_params(&filters[i*BANDS + 2], 10000.0f, 0.0f, SHELF_SLOPE, fs);
	}
	plugin_data->filters = filters;
	plugin_data->fs = fs;

}
Esempio n. 6
0
static void runDj_eq_mono(LADSPA_Handle instance, unsigned long sample_count) {
	Dj_eq_mono *plugin_data = (Dj_eq_mono *)instance;

	/* Lo gain (dB) (float value) */
	const LADSPA_Data lo = *(plugin_data->lo);

	/* Mid gain (dB) (float value) */
	const LADSPA_Data mid = *(plugin_data->mid);

	/* Hi gain (dB) (float value) */
	const LADSPA_Data hi = *(plugin_data->hi);

	/* Input (array of floats of length sample_count) */
	const LADSPA_Data * const input = plugin_data->input;

	/* Output (array of floats of length sample_count) */
	LADSPA_Data * const output = plugin_data->output;
	biquad * filters = plugin_data->filters;
	float fs = plugin_data->fs;

#line 42 "dj_eq_1901.xml"
	unsigned long pos;
	float samp;

	eq_set_params(&filters[0], 100.0f, lo, PEAK_BW, fs);
	eq_set_params(&filters[1], 1000.0f, mid, PEAK_BW, fs);
	hs_set_params(&filters[2], 10000.0f, hi, SHELF_SLOPE, fs);

	for (pos = 0; pos < sample_count; pos++) {
	  samp = biquad_run(&filters[0], input[pos]);
	  samp = biquad_run(&filters[1], samp);
	  samp = biquad_run(&filters[2], samp);
	  buffer_write(output[pos], samp);
	}

	*(plugin_data->latency) = 3; //XXX is this right?
}
Esempio n. 7
0
static void runAddingLcrDelay(LADSPA_Handle instance, unsigned long sample_count) {
	LcrDelay *plugin_data = (LcrDelay *)instance;
	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;

	/* L delay (ms) (float value) */
	const LADSPA_Data ldel = *(plugin_data->ldel);

	/* L level (float value) */
	const LADSPA_Data llev = *(plugin_data->llev);

	/* C delay (ms) (float value) */
	const LADSPA_Data cdel = *(plugin_data->cdel);

	/* C level (float value) */
	const LADSPA_Data clev = *(plugin_data->clev);

	/* R delay (ms) (float value) */
	const LADSPA_Data rdel = *(plugin_data->rdel);

	/* R level (float value) */
	const LADSPA_Data rlev = *(plugin_data->rlev);

	/* Feedback (float value) */
	const LADSPA_Data feedback = *(plugin_data->feedback);

	/* High damp (%) (float value) */
	const LADSPA_Data high_d = *(plugin_data->high_d);

	/* Low damp (%) (float value) */
	const LADSPA_Data low_d = *(plugin_data->low_d);

	/* Spread (float value) */
	const LADSPA_Data spread = *(plugin_data->spread);

	/* Dry/Wet level (float value) */
	const LADSPA_Data wet = *(plugin_data->wet);

	/* L input (array of floats of length sample_count) */
	const LADSPA_Data * const in_l = plugin_data->in_l;

	/* R input (array of floats of length sample_count) */
	const LADSPA_Data * const in_r = plugin_data->in_r;

	/* L output (array of floats of length sample_count) */
	LADSPA_Data * const out_l = plugin_data->out_l;

	/* R output (array of floats of length sample_count) */
	LADSPA_Data * const out_r = plugin_data->out_r;
	LADSPA_Data * buffer = plugin_data->buffer;
	unsigned int buffer_mask = plugin_data->buffer_mask;
	unsigned int buffer_pos = plugin_data->buffer_pos;
	biquad * filters = plugin_data->filters;
	float fs = plugin_data->fs;
	float last_cd = plugin_data->last_cd;
	float last_cl = plugin_data->last_cl;
	float last_ld = plugin_data->last_ld;
	float last_ll = plugin_data->last_ll;
	float last_rd = plugin_data->last_rd;
	float last_rl = plugin_data->last_rl;

#line 58 "lcr_delay_1436.xml"
	unsigned long pos;
	const float sc_r = 1.0f / (float)sample_count;
	const float spr_t = 0.5f + spread * 0.01f;
	const float spr_o = 0.5f - spread * 0.01f;
	float fb = feedback * 0.01f;
	float ll, cl, rl, ld, cd, rd;
	float ll_d, cl_d, rl_d, ld_d, cd_d, rd_d;
	float left, right;
	float fbs; /* Feedback signal */

	if (fb < -0.99f) {
	  fb = -0.99f;
	} else if (fb > 0.99f) {
	  fb = 0.99f;
	}

	ls_set_params(filters, fs * 0.0001f * powf(2.0f, low_d * 0.12f),
	              -0.5f * low_d, 0.5f, fs);
	hs_set_params(filters + 1, fs * (0.41f - 0.0001f *
	              powf(2.0f, high_d * 0.12f)), -70.0f, 0.9f, fs);

	ll = last_ll;                                /* Start value of Left Level */
	ll_d = (llev * 0.01f - last_ll) * sc_r;         /* Delta for Left Level */
	cl = last_cl;
	cl_d = (clev * 0.01f - last_cl) * sc_r;
	rl = last_rl;
	rl_d = (rlev * 0.01f - last_rl) * sc_r;

	ld = last_ld;
	ld_d = (ldel * fs * 0.001f - last_ld) * sc_r;
	cd = last_cd;
	cd_d = (cdel * fs * 0.001f - last_cd) * sc_r;
	rd = last_rd;
	rd_d = (rdel * fs * 0.001f - last_rd) * sc_r;

	for (pos = 0; pos < sample_count; pos++) {
	  /* Increment linear interpolators */
	  ll += ll_d;
	  rl += rl_d;
	  cl += cl_d;
	  ld += ld_d;
	  rd += rd_d;
	  cd += cd_d;

	  /* Write input into delay line */
	  buffer[buffer_pos] = in_l[pos] + in_r[pos];
	  /* Add feedback, must be done afterwards for case where C delay = 0 */
	  fbs = buffer[(buffer_pos - f_round(cd)) & buffer_mask] * fb;
	  fbs = flush_to_zero(fbs);
	  fbs = biquad_run(filters, fbs);
	  fbs = biquad_run(filters + 1, fbs);
	  buffer[buffer_pos] += fbs;

	  /* Outputs from left and right delay beffers + centre mix */
	  left  = buffer[(buffer_pos - f_round(ld)) & buffer_mask] * ll +
	          buffer[(buffer_pos - f_round(cd)) & buffer_mask] * cl;
	  right = buffer[(buffer_pos - f_round(rd)) & buffer_mask] * rl +
	          buffer[(buffer_pos - f_round(cd)) & buffer_mask] * cl;

	  /* Left and right channel outs */
	  buffer_write(out_l[pos], in_l[pos] * (1.0f - wet) +
	                  (left * spr_t + right * spr_o) * wet);
	  buffer_write(out_r[pos], in_r[pos] * (1.0f - wet) +
	                  (left * spr_o + right * spr_t) * wet);

	  buffer_pos = (buffer_pos + 1) & buffer_mask;
	}

	plugin_data->last_ll = ll;
	plugin_data->last_cl = cl;
	plugin_data->last_rl = rl;
	plugin_data->last_ld = ld;
	plugin_data->last_cd = cd;
	plugin_data->last_rd = rd;
	plugin_data->buffer_pos = buffer_pos;
}
Esempio n. 8
0
static void runAddingGate(LADSPA_Handle instance, unsigned long sample_count) {
	Gate *plugin_data = (Gate *)instance;
	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;

	/* LF key filter (Hz) (float value) */
	const LADSPA_Data lf_fc = *(plugin_data->lf_fc);

	/* HF key filter (Hz) (float value) */
	const LADSPA_Data hf_fc = *(plugin_data->hf_fc);

	/* Threshold (dB) (float value) */
	const LADSPA_Data threshold = *(plugin_data->threshold);

	/* Attack (ms) (float value) */
	const LADSPA_Data attack = *(plugin_data->attack);

	/* Hold (ms) (float value) */
	const LADSPA_Data hold = *(plugin_data->hold);

	/* Decay (ms) (float value) */
	const LADSPA_Data decay = *(plugin_data->decay);

	/* Range (dB) (float value) */
	const LADSPA_Data range = *(plugin_data->range);

	/* Output select (-1 = key listen, 0 = gate, 1 = bypass) (float value) */
	const LADSPA_Data select = *(plugin_data->select);

	/* Input (array of floats of length sample_count) */
	const LADSPA_Data * const input = plugin_data->input;

	/* Output (array of floats of length sample_count) */
	LADSPA_Data * const output = plugin_data->output;
	float env = plugin_data->env;
	float fs = plugin_data->fs;
	float gate = plugin_data->gate;
	biquad * hf = plugin_data->hf;
	int hold_count = plugin_data->hold_count;
	biquad * lf = plugin_data->lf;
	int state = plugin_data->state;

#line 55 "gate_1410.xml"
	unsigned long pos;
	float cut = DB_CO(range);
	float t_level = DB_CO(threshold);
	float a_rate = 1000.0f / (attack * fs);
	float d_rate = 1000.0f / (decay * fs);
	float post_filter, apost_filter;
	int op = f_round(select);

	ls_set_params(lf, lf_fc, -40.0f, 0.6f, fs);
	hs_set_params(hf, hf_fc, -50.0f, 0.6f, fs);

	for (pos = 0; pos < sample_count; pos++) {
	  post_filter = biquad_run(lf, input[pos]);
	  post_filter = biquad_run(hf, post_filter);
	  apost_filter = fabs(post_filter);

	  if (apost_filter > env) {
	    env = apost_filter;
	  } else {
	    env = apost_filter * ENV_TR + env * (1.0f - ENV_TR);
	  }

	  if (state == CLOSED) {
	    if (env >= t_level) {
	      state = OPENING;
	    }
	  } else if (state == OPENING) {
	    gate += a_rate;
	    if (gate >= 1.0f) {
	      gate = 1.0f;
	      state = OPEN;
	      hold_count = f_round(hold * fs * 0.001f);
	      plugin_data->hold_count = hold_count;
	    }
	  } else if (state == OPEN) {
	    if (hold_count <= 0) {
	      if (env < t_level) {
	        state = CLOSING;
	      }
	    } else {
	      hold_count--;
	    }
	  } else if (state == CLOSING) {
	    gate -= d_rate;
	    if (env >= t_level) {
	      state = OPENING;
	    } else if (gate <= 0.0f) {
	      gate = 0.0f;
	      state = CLOSED;
	    }
	  }

	  if (op == 0) {
	    buffer_write(output[pos], input[pos] * (cut * (1.0f - gate) + gate));
	  } else if (op == -1) {
	    buffer_write(output[pos], post_filter);
	  } else {
	    buffer_write(output[pos], input[pos]);
	  }
	}

	plugin_data->env = env;
	plugin_data->gate = gate;
	plugin_data->state = state;
	plugin_data->hold_count = hold_count;
}