Esempio n. 1
0
static void runAddingGverb(LADSPA_Handle instance, unsigned long sample_count) {
	Gverb *plugin_data = (Gverb *)instance;
	LADSPA_Data run_adding_gain = plugin_data->run_adding_gain;

	/* Roomsize (m) (float value) */
	const LADSPA_Data roomsize = *(plugin_data->roomsize);

	/* Reverb time (s) (float value) */
	const LADSPA_Data revtime = *(plugin_data->revtime);

	/* Damping (float value) */
	const LADSPA_Data damping = *(plugin_data->damping);

	/* Input bandwidth (float value) */
	const LADSPA_Data inputbandwidth = *(plugin_data->inputbandwidth);

	/* Dry signal level (dB) (float value) */
	const LADSPA_Data drylevel = *(plugin_data->drylevel);

	/* Early reflection level (dB) (float value) */
	const LADSPA_Data earlylevel = *(plugin_data->earlylevel);

	/* Tail level (dB) (float value) */
	const LADSPA_Data taillevel = *(plugin_data->taillevel);

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

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

	/* Right output (array of floats of length sample_count) */
	LADSPA_Data * const outr = plugin_data->outr;
	ty_gverb * verb = plugin_data->verb;

#line 62 "gverb_1216.xml"
	unsigned long pos;
	float l, r;
	float dryc = DB_CO(drylevel);

	gverb_set_roomsize(verb, roomsize);
	gverb_set_revtime(verb, revtime);
	gverb_set_damping(verb, damping);
	gverb_set_inputbandwidth(verb, inputbandwidth);
	gverb_set_earlylevel(verb, DB_CO(earlylevel));
	gverb_set_taillevel(verb, DB_CO(taillevel));

	for (pos = 0; pos < sample_count; pos++) {
	  gverb_do(verb, input[pos], &l, &r);
	  buffer_write(outl[pos], l + input[pos] * dryc);
	  buffer_write(outr[pos], r + input[pos] * dryc);
	}
}
Esempio n. 2
0
void GVERB::doupdate()
{
	double pfs[11];

	update(pfs, 11);

	amp = pfs[3];

	if (pfs[4] != p->roomsize) {
		if (pfs[4] < 1.0 || pfs[4] > p->maxroomsize) 
			warn("GVERB", "bogus roomsize: %f\n", pfs[4]);
		gverb_set_roomsize(p, pfs[4]); // sets p->roomsize
	}

	if (pfs[5] != p->revtime) {
		if (pfs[5] < 0.1 || pfs[5] > 360.0)
			warn("GVERB", "bad revtime: %f\n", pfs[5]);
		gverb_set_revtime(p, pfs[5]);
	}

	if (pfs[6] != p->fdndamping) {
		if (pfs[6] < 0.0 || pfs[6] > 1.0)
			warn("GVERB", "incorrect damping: %f\n", pfs[6]);
		gverb_set_damping(p, pfs[6]);
	}

	if (pfs[7] != p->inputbandwidth) {
		if (pfs[7] < 0.0 || pfs[7] > 1.0)
			warn("GVERB", "input bandwith problem: %f\n", pfs[7]);
		gverb_set_inputbandwidth(p, pfs[7]);
	}

	if (DB_CO(pfs[8]) != p->drylevel) {
		if (pfs[8] < -90.0 || pfs[8] > 0.0)
			warn("GVERB", "dry level wrong: %f\n", pfs[8]);
		gverb_set_drylevel(p, pfs[8]);
	}

	if (DB_CO(pfs[9]) != p->earlylevel) {
		if (pfs[9] < -90.0 || pfs[9] > 0.0)
			warn("GVERB", "problem with early reflection level: %f\n", pfs[9]);
			gverb_set_earlylevel(p, pfs[9]);
	}

	if (DB_CO(pfs[10]) != p->taillevel) {
		if (pfs[10] < -90.0 || pfs[10] > 0.0)
			warn("GVERB", "bogus tail level: %f\n", pfs[10]);
		gverb_set_taillevel(p, pfs[10]);
	}
}
Esempio n. 3
0
void GVerb_next(GVerb* unit, int inNumSamples)
{
    float* in = IN(0);
    float* outl = OUT(0);
    float* outr = OUT(1);
    float roomsize = IN0(1);
    float revtime = IN0(2);
    float damping = IN0(3);
    float inputbandwidth = IN0(4);
    //float spread = IN0(5); // spread can only be set at inittime
    float drylevel = IN0(6);
    float earlylevel = IN0(7);
    float taillevel = IN0(8);
    float earlylevelslope, taillevelslope, drylevelslope;
    float* fdngainslopes;
    float* tapgainslopes;
    g_diffuser** ldifs = unit->ldifs;
    g_diffuser** rdifs = unit->rdifs;
    float* u = unit->u;
    float* f = unit->f;
    float* d = unit->d;
    g_damper* inputdamper = unit->inputdamper;
    float* tapgains = unit->tapgains;
    g_fixeddelay* tapdelay = unit->tapdelay;
    int* taps = unit->taps;
    g_damper** fdndamps = unit->fdndamps;
    g_fixeddelay** fdndels = unit->fdndels;
    float* fdngains = unit->fdngains;
    int* fdnlens = unit->fdnlens;

    if((roomsize != unit->roomsize) || (revtime != unit->revtime) || (damping != unit->damping) ||
	    (inputbandwidth != unit->inputbandwidth) || (drylevel != unit->drylevel) ||
	    (earlylevel != unit->earlylevel) || (taillevel != unit->taillevel)) {
	// these should calc slopes for k-rate interpolation
	gverb_set_roomsize(unit, roomsize);
	gverb_set_revtime(unit, revtime);
	gverb_set_damping(unit, damping);
	gverb_set_inputbandwidth(unit, inputbandwidth);
	drylevel = gverb_set_drylevel(unit, drylevel);
	earlylevel = gverb_set_earlylevel(unit, earlylevel);
	taillevel = gverb_set_taillevel(unit, taillevel);
	}

    earlylevelslope = unit->earlylevelslope;
    taillevelslope = unit->taillevelslope;
    drylevelslope = unit->drylevelslope;
    fdngainslopes = unit->fdngainslopes;
    tapgainslopes = unit->tapgainslopes;


    for(int i = 0; i < inNumSamples; i++){
	float sign, sum, lsum, rsum, x;
	if(sc_isnan(in[i])) x = 0.f; else x = in[i];
	sum = 0.f;
	sign = 1.f;

	float z = damper_do(unit, inputdamper, x);
	z = diffuser_do(unit, ldifs[0], z);

	for(int j = 0; j < FDNORDER; j++) {
	    u[j] = tapgains[j] * fixeddelay_read(unit, tapdelay, taps[j]);
	}

	fixeddelay_write(unit, tapdelay, z);

	for(int j = 0; j < FDNORDER; j++) {
	    d[j] = damper_do(unit, fdndamps[j],
			    fdngains[j] *
				fixeddelay_read(unit, fdndels[j], fdnlens[j]));
	}

	for(int j = 0; j < FDNORDER; j++) {
	    sum += sign * (taillevel * d[j] + earlylevel * u[j]);
	    sign = -sign;
	}

	sum += x * earlylevel;
	lsum = sum;
	rsum = sum;

	gverb_fdnmatrix(d, f);

	for(int j = 0; j < FDNORDER; j++) {
	    fixeddelay_write(unit, fdndels[j], u[j] + f[j]);
	}

	lsum = diffuser_do(unit, ldifs[1],lsum);
	lsum = diffuser_do(unit, ldifs[2],lsum);
	lsum = diffuser_do(unit, ldifs[3],lsum);
	rsum = diffuser_do(unit, rdifs[1],rsum);
	rsum = diffuser_do(unit, rdifs[2],rsum);
	rsum = diffuser_do(unit, rdifs[3],rsum);

	x = x * drylevel;
	outl[i] = lsum + x;
	outr[i] = rsum + x;

	drylevel += drylevelslope;
	taillevel += taillevelslope;
	earlylevel += earlylevelslope;
	for(int j = 0; j < FDNORDER; j++){
	    fdngains[j] += fdngainslopes[j];
	    tapgains[j] += tapgainslopes[j];
	    }
	}

    // store vals back to the struct
    for(int i = 0; i < FDNORDER; i++){
	unit->ldifs[i] = ldifs[i];
	unit->rdifs[i] = rdifs[i];
	unit->u[i] = u[i];
	unit->f[i] = f[i];
	unit->d[i] = d[i];
	unit->tapgains[i] = tapgains[i];
	unit->taps[i] = taps[i];
	unit->fdndamps[i] = fdndamps[i];
	unit->fdndels[i] = fdndels[i];
	unit->fdngains[i] = fdngains[i];
	unit->fdnlens[i] = fdnlens[i];
	unit->fdngainslopes[i] = 0.f;
	unit->tapgainslopes[i] = 0.f;
	}
    unit->inputdamper = inputdamper;
    unit->tapdelay = tapdelay;
    // clear the slopes
    unit->earlylevelslope = unit->taillevelslope = unit->drylevelslope = 0.f;
}
Esempio n. 4
0
int GVERB::init(double pfs[], int n_args)
{
	if (rtsetoutput(pfs[0], pfs[2]+pfs[11], this) == -1)
		return DONT_SCHEDULE;
	if (outputChannels() != 2)
		return die("GVERB", "stereo output required");
	if (rtsetinput(pfs[1], this) == -1)
		return DONT_SCHEDULE;   // no input

	inputframes = pfs[2] * SR;
	inputchan = pfs[12];

	amp = pfs[3];

	float maxroomsize = 300.0f;
	float roomsize = 50.0f;
	float revtime = 7.0f;
	float damping = 0.5f;
	float spread = 15.0f;
	float inputbandwidth = 0.5f;
	float drylevel = 0.0f; //-1.9832f;
	float earlylevel = 0.0f; //-1.9832f;
	float taillevel = 0.0f;

	float ga,gb,gt;
	unsigned int i;
	int n;
	float r;
	float diffscale;
	int a,b,c,cc,d,dd,e;
	float spread1,spread2;

	// BGG max/msp heritage, params/etc. stored in this "p" struct (ty_gverb)
	p = &realp;
	// zero out the struct, to be careful
	bzero((void *)p, sizeof (ty_gverb));

	p->rate = SR;
	p->fdndamping = damping;
	p->maxroomsize = maxroomsize;
	p->roomsize = CLIP(roomsize, 0.1f, maxroomsize);
	p->revtime = revtime;
	p->drylevel = drylevel;
	p->earlylevel = earlylevel;
	p->taillevel = taillevel;

	p->maxdelay = p->rate*p->maxroomsize/340.0;
	p->largestdelay = p->rate*p->roomsize/340.0;

	/* Input damper */

	p->inputbandwidth = inputbandwidth;
	p->inputdamper = damper_make(1.0 - p->inputbandwidth);


	/* FDN section */

	p->fdndels = (ty_fixeddelay **)malloc(FDNORDER*sizeof(ty_fixeddelay *));
	if(!p->fdndels)
		return die("GVERB", "out of memory for fixeddelay ptrs");
	for(i = 0; i < FDNORDER; i++)
	{
		p->fdndels[i] = fixeddelay_make((int)p->maxdelay+1000);
		if(!p->fdndels[i])
			return die("GVERB", "out of memory for fixeddelays");
	}
	p->fdngains = (float *)malloc(FDNORDER*sizeof(float));
	p->fdnlens = (int *)malloc(FDNORDER*sizeof(int));
	if(!p->fdngains || !p->fdnlens)
		return die("GVERB", "out of memory for delay gains and lengths");

	p->fdndamps = (ty_damper **)malloc(FDNORDER*sizeof(ty_damper *));
	if(!p->fdndamps)
		return die("GVERB", "out of memory for delay amps");

	for(i = 0; i < FDNORDER; i++)
	{
		p->fdndamps[i] = damper_make(p->fdndamping);
		if(!p->fdndamps[i])
			return die("GVERB", "out of memory for delay amps 2");
	}

	ga = 60.0;
	gt = p->revtime;
	ga = pow(10.0,-ga/20.0);
	n = (int)(p->rate*gt);
	p->alpha = pow((double)ga,(double)1.0/(double)n);

	gb = 0.0;
	for(i = 0; i < FDNORDER; i++)
	{
		if (i == 0) gb = 1.000000*p->largestdelay;
		if (i == 1) gb = 0.816490*p->largestdelay;
		if (i == 2) gb = 0.707100*p->largestdelay;
		if (i == 3) gb = 0.632450*p->largestdelay;

#if 0
		p->fdnlens[i] = nearest_prime((int)gb, 0.5);
#else
		p->fdnlens[i] = (int)gb;
#endif
		// p->fdngains[i] = -pow(p->alpha,(double)p->fdnlens[i]);
		p->fdngains[i] = -powf((float)p->alpha,p->fdnlens[i]);
	}

	p->d = (float *)malloc(FDNORDER*sizeof(float));
	p->u = (float *)malloc(FDNORDER*sizeof(float));
	p->f = (float *)malloc(FDNORDER*sizeof(float));
	if(!p->d || !p->u || !p->f)
		return die("GVERB", "out of memory for other delay stuff");


	/* Diffuser section */

	diffscale = (float)p->fdnlens[3]/(210+159+562+410);
	spread1 = spread;
	spread2 = 3.0*spread;

	b = 210;
	r = 0.125541f;
	a = (int)(spread1*r);
	c = 210+159+a;
	cc = c-b;
	r = 0.854046f;
	a = (int)(spread2*r);
	d = 210+159+562+a;
	dd = d-c;
	e = 1341-d;

	p->ldifs = (ty_diffuser **)malloc(4*sizeof(ty_diffuser *));
	if(!p->ldifs)
		return die("GVERB", "out of memory for diffuser left structs");

	p->ldifs[0] = diffuser_make((int)(diffscale*b),0.75);
	p->ldifs[1] = diffuser_make((int)(diffscale*cc),0.75);
	p->ldifs[2] = diffuser_make((int)(diffscale*dd),0.625);
	p->ldifs[3] = diffuser_make((int)(diffscale*e),0.625);
	if(!p->ldifs[0] || !p->ldifs[1] || !p->ldifs[2] || !p->ldifs[3])
		return die("GVERB", "out of memory for diffuser left makes");

	b = 210;
	r = -0.568366f;
	a = (int)(spread1*r);
	c = 210+159+a;
	cc = c-b;
	r = -0.126815f;
	a = (int)(spread2*r);
	d = 210+159+562+a;
	dd = d-c;
	e = 1341-d;

	p->rdifs = (ty_diffuser **)malloc(4*sizeof(ty_diffuser *));
	if(!p->rdifs)
		return die("GVERB", "out of memory for diffuser right structs");

	p->rdifs[0] = diffuser_make((int)(diffscale*b),0.75);
	p->rdifs[1] = diffuser_make((int)(diffscale*cc),0.75);
	p->rdifs[2] = diffuser_make((int)(diffscale*dd),0.625);
	p->rdifs[3] = diffuser_make((int)(diffscale*e),0.625);
	if(!p->rdifs[0] || !p->rdifs[1] || !p->rdifs[2] || !p->rdifs[3])
		return die("GVERB", "out of memory for diffuser right makes");

	/* Tapped delay section */

	p->tapdelay = fixeddelay_make(44000);
	p->taps = (int *)malloc(FDNORDER*sizeof(int));
	p->tapgains = (float *)malloc(FDNORDER*sizeof(float));
	if(!p->tapdelay || !p->taps || !p->tapgains)
		return die("GVERB", "out of memory for taps");

	p->taps[0] = (int)(5+0.410*p->largestdelay);
	p->taps[1] = (int)(5+0.300*p->largestdelay);
	p->taps[2] = (int)(5+0.155*p->largestdelay);
	p->taps[3] = (int)(5+0.000*p->largestdelay);

	for(i = 0; i < FDNORDER; i++)
	{
		p->tapgains[i] = pow(p->alpha,(double)p->taps[i]);
	}


	// these values get set after all the init stuff
	if (pfs[4] < 1.0 || pfs[4] > maxroomsize) 
		return die("GVERB", "bogus roomsize: %f\n", pfs[4]);
	gverb_set_roomsize(p, pfs[4]); // sets p->roomsize

	if (pfs[5] < 0.1 || pfs[5] > 360.0)
		return die("GVERB", "bad revtime: %f\n", pfs[5]);
	gverb_set_revtime(p, pfs[5]);

	if (pfs[6] < 0.0 || pfs[6] > 1.0)
		return die("GVERB", "incorrect damping: %f\n", pfs[6]);
	gverb_set_damping(p, pfs[6]);

	if (pfs[7] < 0.0 || pfs[7] > 1.0)
		return die("GVERB", "input bandwith problem: %f\n", pfs[7]);
	gverb_set_inputbandwidth(p, pfs[7]);

	if (pfs[8] < -90.0 || pfs[8] > 0.0)
		return die("GVERB", "dry level wrong: %f\n", pfs[8]);
	gverb_set_drylevel(p, pfs[8]);

	if (pfs[9] < -90.0 || pfs[9] > 0.0)
		return die("GVERB", "problem with early reflection level: %f\n", pfs[9]);
	gverb_set_earlylevel(p, pfs[9]);

	if (pfs[10] < -90.0 || pfs[10] > 0.0)
		return die("GVERB", "bogus tail level: %f\n", pfs[10]);
	gverb_set_taillevel(p, pfs[10]);

	branch = 0;

	return nSamps();
}
Esempio n. 5
0
  // set parameter example
  float setRevTime( t_CKFLOAT x )
  {
	gverb_set_revtime(p, x/p->rate);
	return x;
  }