/* Construct a new plugin instance. */
LADSPA_Handle 
instantiate_DeEsser(const LADSPA_Descriptor * Descriptor,
		    unsigned long             SampleRate) {
	
	LADSPA_Handle * ptr;
	
	if ((ptr = malloc(sizeof(DeEsser))) != NULL) {
		((DeEsser *)ptr)->sample_rate = SampleRate;
		((DeEsser *)ptr)->run_adding_gain = 1.0f;

		/* init filters */
		biquad_init(&((DeEsser *)ptr)->sidech_lo_filter);
		biquad_init(&((DeEsser *)ptr)->sidech_hi_filter);
		
		/* alloc mem for ringbuffer */
		if ((((DeEsser *)ptr)->ringbuffer = 
		     calloc(RINGBUF_SIZE, sizeof(LADSPA_Data))) == NULL)
			return NULL;

                /* 10 ms attenuation data is stored */
		((DeEsser *)ptr)->buflen = ((DeEsser *)ptr)->sample_rate / 100; 

		((DeEsser *)ptr)->pos = 0;
		((DeEsser *)ptr)->sum = 0.0f;
		((DeEsser *)ptr)->old_freq = 0;

		return ptr;
	}
	return NULL;
}
Exemple #2
0
/* activate a plugin instance */
void
activate_Reverb(LADSPA_Handle Instance) {

	Reverb * ptr = (Reverb *)Instance;
	unsigned long i,j;

	for (i = 0; i < 2 * MAX_COMBS; i++) {
		for (j = 0; j < (unsigned long)MAX_COMB_DELAY * ptr->sample_rate / 1000; j++)
		        ((COMB_FILTER *)(ptr->combs + i))->ringbuffer[j] = 0.0f;
		*(((COMB_FILTER *)(ptr->combs + i))->buffer_pos) = 0;
		((COMB_FILTER *)(ptr->combs + i))->last_out = 0;
		biquad_init(((COMB_FILTER *)(ptr->combs + i))->filter);
	}

	for (i = 0; i < 2 * MAX_ALLPS; i++) {
		for (j = 0; j < (unsigned long)MAX_ALLP_DELAY * ptr->sample_rate / 1000; j++)
			((ALLP_FILTER *)(ptr->allps + i))->ringbuffer[j] = 0.0f;
		*(((ALLP_FILTER *)(ptr->allps + i))->buffer_pos) = 0;
		((ALLP_FILTER *)(ptr->allps + i))->last_out = 0;
	}

	biquad_init(ptr->low_pass);
	biquad_init((biquad *)(ptr->low_pass + 1));
	biquad_init(ptr->high_pass);
	biquad_init((biquad *)(ptr->high_pass + 1));

	ptr->old_decay = -10.0f;
	ptr->old_stereo_enh = -10.0f;
	ptr->old_mode = -10.0f;
}
Exemple #3
0
static LADSPA_Handle instantiateGate(
 const LADSPA_Descriptor *descriptor,
 unsigned long s_rate) {
	Gate *plugin_data = (Gate *)calloc(1, sizeof(Gate));
	float env;
	float fs;
	float gate;
	biquad *hf = NULL;
	int hold_count;
	biquad *lf = NULL;
	int state;

#line 28 "gate_1410.xml"
	fs = s_rate;
	env = 0.0f;
	gate = 0.0f;
	state = CLOSED;
	hold_count = 0;

	lf = malloc(sizeof(biquad));
	hf = malloc(sizeof(biquad));
	biquad_init(lf);
	biquad_init(hf);

	plugin_data->env = env;
	plugin_data->fs = fs;
	plugin_data->gate = gate;
	plugin_data->hf = hf;
	plugin_data->hold_count = hold_count;
	plugin_data->lf = lf;
	plugin_data->state = state;

	return (LADSPA_Handle)plugin_data;
}
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;
}
Exemple #5
0
void
activate_ChorusFlanger(LV2_Handle Instance) {

	ChorusFlanger * ptr = (ChorusFlanger *)Instance;

	memset(ptr->ring_L, 0, sizeof(float)*ptr->buflen_L);
	memset(ptr->ring_R, 0, sizeof(float)*ptr->buflen_R);

	biquad_init(&ptr->highpass_L);
	biquad_init(&ptr->highpass_R);
}
void
activate_ChorusFlanger(LADSPA_Handle Instance) {

	ChorusFlanger * ptr = (ChorusFlanger *)Instance;
	unsigned long i;

	for (i = 0; i < (DEPTH_BUFLEN + DELAY_BUFLEN) * ptr->sample_rate / 192000; i++) {
		ptr->ring_L[i] = 0.0f;
		ptr->ring_R[i] = 0.0f;
	}

	biquad_init(&ptr->highpass_L);
	biquad_init(&ptr->highpass_R);
}
Exemple #7
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;

}
Exemple #8
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;

}
Exemple #9
0
biquad_t *
biquad_new(filter_t *f)
{
    biquad_t *b = malloc(sizeof(biquad_t));
    if (!b) return NULL;
    if (f)  biquad_init(b, f);
    return b;
}
static void activateSurroundEncoder(LADSPA_Handle instance) {
	SurroundEncoder *plugin_data = (SurroundEncoder *)instance;
	LADSPA_Data *buffer = plugin_data->buffer;
	unsigned int buffer_pos = plugin_data->buffer_pos;
	unsigned int buffer_size = plugin_data->buffer_size;
	biquad *hc = plugin_data->hc;
	biquad *lc = plugin_data->lc;
#line 44 "surround_encoder_1401.xml"
	memset(buffer, 0, buffer_size * sizeof(LADSPA_Data));
	biquad_init(lc);
	biquad_init(hc);
	plugin_data->buffer = buffer;
	plugin_data->buffer_pos = buffer_pos;
	plugin_data->buffer_size = buffer_size;
	plugin_data->hc = hc;
	plugin_data->lc = lc;

}
Exemple #11
0
static void activateSinglePara(LADSPA_Handle instance) {
	SinglePara *plugin_data = (SinglePara *)instance;
	biquad *filter = plugin_data->filter;
	float fs = plugin_data->fs;
#line 26 "single_para_1203.xml"
	biquad_init(filter);
	plugin_data->filter = filter;
	plugin_data->fs = fs;

}
Exemple #12
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;

}
static void activatePointerCastDistortion(LADSPA_Handle instance) {
	PointerCastDistortion *plugin_data = (PointerCastDistortion *)instance;
	biquad *filt = plugin_data->filt;
	float fs = plugin_data->fs;
#line 36 "pointer_cast_1910.xml"
	biquad_init(filt);
	plugin_data->filt = filt;
	plugin_data->fs = fs;

}
Exemple #14
0
djeq_t *djeq_create() {

	djeq_t *djeq = calloc(1, sizeof(djeq_t));
	
	djeq->rate = 44100.0f;

	djeq->filters = calloc(BANDS * CHANNELS, sizeof(biquad));
      
	for (djeq->i = 0; djeq->i < CHANNELS; djeq->i++) {
		biquad_init(&djeq->filters[djeq->i*BANDS + 0]);
		eq_set_params(&djeq->filters[djeq->i*BANDS + 0], 100.0f, 0.0f, LOW_BW, djeq->rate);
		biquad_init(&djeq->filters[djeq->i*BANDS + 1]);
		eq_set_params(&djeq->filters[djeq->i*BANDS + 1], 1000.0f, 0.0f, MID_BW, djeq->rate);
		biquad_init(&djeq->filters[djeq->i*BANDS + 2]);
		eq_set_params(&djeq->filters[djeq->i*BANDS + 2], 10000.0f, 0.0f, HIGH_BW, djeq->rate);
	}
	
	return djeq;

}
Exemple #15
0
static
void
activate_eq(LADSPA_Handle instance) {

	eq *ptr = (eq *)instance;
	biquad *filters = ptr->filters;

	biquad_init(&filters[0]);
	biquad_init(&filters[1]);
	biquad_init(&filters[2]);
	biquad_init(&filters[3]);
	biquad_init(&filters[4]);
	biquad_init(&filters[5]);
	biquad_init(&filters[6]);
	biquad_init(&filters[7]);
}
Exemple #16
0
static void biquad_lpf(biquad_t *bq, double freq, double Q) {
    double w0 = 2*M_PI*freq/((float)sampling_rate/(float)frame_size);
    double alpha = sin(w0)/(2.0*Q);

    double a_0 = 1.0 + alpha;
    double b[3], a[2];
    b[0] = (1.0-cos(w0))/(2.0*a_0);
    b[1] = (1.0-cos(w0))/a_0;
    b[2] = b[0];
    a[0] = -2.0*cos(w0)/a_0;
    a[1] = (1-alpha)/a_0;

    biquad_init(bq, a, b);
}
Exemple #17
0
static void activateLcrDelay(LADSPA_Handle instance) {
	LcrDelay *plugin_data = (LcrDelay *)instance;
	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 41 "lcr_delay_1436.xml"
	memset(buffer, 0, (buffer_mask + 1) * sizeof(LADSPA_Data));
	last_ll = 0.0f;
	last_cl = 0.0f;
	last_rl = 0.0f;
	last_ld = 0.0f;
	last_cd = 0.0f;
	last_rd = 0.0f;
	biquad_init(filters);
	biquad_init(filters + 1);
	plugin_data->buffer = buffer;
	plugin_data->buffer_mask = buffer_mask;
	plugin_data->buffer_pos = buffer_pos;
	plugin_data->filters = filters;
	plugin_data->fs = fs;
	plugin_data->last_cd = last_cd;
	plugin_data->last_cl = last_cl;
	plugin_data->last_ld = last_ld;
	plugin_data->last_ll = last_ll;
	plugin_data->last_rd = last_rd;
	plugin_data->last_rl = last_rl;

}
Exemple #18
0
static void activateGate(LADSPA_Handle instance) {
	Gate *plugin_data = (Gate *)instance;
	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 41 "gate_1410.xml"
	env = 0.0f;
	gate = 0.0f;
	state = CLOSED;
	biquad_init(lf);
	biquad_init(hf);
	plugin_data->env = env;
	plugin_data->fs = fs;
	plugin_data->gate = gate;
	plugin_data->hf = hf;
	plugin_data->hold_count = hold_count;
	plugin_data->lf = lf;
	plugin_data->state = state;

}
Exemple #19
0
static LADSPA_Handle instantiateSinglePara(
 const LADSPA_Descriptor *descriptor,
 unsigned long s_rate) {
	SinglePara *plugin_data = (SinglePara *)calloc(1, sizeof(SinglePara));
	biquad *filter = NULL;
	float fs;

#line 20 "single_para_1203.xml"
	fs = (float)s_rate;
	filter = malloc(sizeof(biquad));
	biquad_init(filter);

	plugin_data->filter = filter;
	plugin_data->fs = fs;

	return (LADSPA_Handle)plugin_data;
}
Exemple #20
0
static LADSPA_Handle instantiateGsm(
 const LADSPA_Descriptor *descriptor,
 unsigned long s_rate) {
	Gsm *plugin_data = (Gsm *)calloc(1, sizeof(Gsm));
	biquad *blf = NULL;
	int count;
	LADSPA_Data *dry = NULL;
	gsm_signal *dst = NULL;
	float fs;
	gsm handle;
	int resamp;
	float rsf;
	gsm_signal *src = NULL;

#line 27 "gsm_1215.xml"
	count = 0;
	resamp = s_rate / 8000;
	fs = s_rate;
	rsf = SCALE / (float)resamp;
	src = malloc(sizeof(gsm_signal) * 160);
	dst = malloc(sizeof(gsm_signal) * 163);
	dry = malloc(sizeof(LADSPA_Data) * 160 * resamp);
	handle = NULL;

	blf = malloc(sizeof(biquad));
	biquad_init(blf);

	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;

	return (LADSPA_Handle)plugin_data;
}
Exemple #21
0
int main(void)
{


  
  // init motors and PWMs
  brushless_init();


  // enable power bridges
  sbi(DDRG, 1);
  sbi(PORTG, 1);
  
  
  // init uart
  uart_init();
  fdevopen((void *)uart0_send,NULL,0);

  
  
  //printf_P(PSTR("\nbonjour\n"));
  
  
  
  /** replaces the scheduler. This is directly derived from the interrupt which runs the brushless motors, for convenience */
  brushless_0_register_periodic_event(asserv_rapide_manage); // 10 ms
  
  
  
  /** speed PID stuff */
  
  // PID
  pid_init(&speed_pid);
  
  pid_set_gains(&speed_pid,     180, 70, 40); // sur alim
  
  pid_set_maximums(&speed_pid,  0, 80, PWM_MAX*4/5);
  pid_set_out_shift(&speed_pid, 0);
  
  // derivation (This could alternatively be skipped if we use the brushless peed info directly)
  biquad_init(&speed_derivation);
  biquad_set_numerator_coeffs(&speed_derivation, 1,-1,0); // this is a discrete derivation : O(n) = I(n) - I(n-1)
  // no need to initialize denominator coeffs to 0, init has done it
  
  // control system speed
  cs_init(&speed);
  
  cs_set_correct_filter(&speed, pid_do_filter, &speed_pid);
  cs_set_process_in(&speed, brushless_set_torque, (void *)0 );
  cs_set_process_out(&speed,brushless_get_pos , (void *)0 );
  cs_set_feedback_filter(&speed, biquad_do_filter, &speed_derivation);
  cs_set_consign(&speed, 0);
  
  
  
  /** ramp generator parameters */
  
  quadramp_derivate_init(&position_quadr_derv);
  
  quadramp_derivate_set_gain_anticipation(&position_quadr_derv, 256 *3);// some anticipation : 3.0 (this is a fixed point value *1/256)

  quadramp_derivate_set_goal_window(&position_quadr_derv, 5);           // algorithm shut down window

  quadramp_derivate_set_2nd_order_vars(&position_quadr_derv,   1 ,  1); // max acceleration : 1
  quadramp_derivate_set_1st_order_vars(&position_quadr_derv,  12,  12); // max speed is 12

  quadramp_derivate_set_divisor(&position_quadr_derv, 2);               // divisor, for precision


  // control system position 
  cs_init(&position);
  cs_set_correct_filter(&position, quadramp_derivate_do_filter, &position_quadr_derv); 
  cs_set_process_in(&position, (void *)cs_set_consign, &speed );
  cs_set_process_out(&position,brushless_get_pos , (void *)0 );
  cs_set_consign(&position, 0);


  /** begin */
  
  brushless_set_speed((void *)0 , BRUSHLESS_MAX_SPEED); // init speed

  sei();




  // some simple trajectories (enable one )

  while(1)
  {
  wait_ms(3500);
  cs_set_consign(&position, 400);
  wait_ms(500);
  cs_set_consign(&position, 0);
  }


  /*
  while(1)
  {
  wait_ms(2500);
  cs_set_consign(&position, 2000);
  wait_ms(2500);
  cs_set_consign(&position, 0);
  }



  // test of speed pid only, deactivate the position.
  while(1)
  {
  wait_ms(300);
  cs_set_consign(&speed, 10);
  wait_ms(300);
  cs_set_consign(&speed, -10);
  } */




  while(1);


  return 0;
}