Пример #1
0
int SFLUTE::init(double p[], int n_args)
{
// p0 = start; p1 = dur; p2 = noise amp; p3 = length1; p4 = length2
// p5 = amp multiplier; p6 = stereo spread (0-1) <optional>
// function slot 1 is the noise amp envelope
// function slot 2 is the out amp envelope

	if (rtsetoutput(p[0], p[1], this) == -1)
		return DONT_SCHEDULE;

	dampcoef = .7;

	amparr = floc(1);
	if (amparr) {
		int len = fsize(1);
		tableset(SR, p[1], len, amptabs);
	}
	else
		return die("SFLUTE", "You haven't made the noise amp envelope (table 1).");

	oamparr = floc(2);
	if (oamparr) {
		int len = fsize(2);
		tableset(SR, p[1], len, oamptabs);
	}
	else
		return die("SFLUTE", "You haven't made the output amp envelope (table 2).");

	int imax = DELSIZE;
	mdelset(SR, del1,dl1,imax);
	mdelset(SR, del2,dl2,imax);
	dl1ptr = dl1;
	dl2ptr = dl2;
	del1ptr = del1;
	del2ptr = del2;

//	srrand(0.1);
	length1 = (int)p[3];
	length2 = (int)p[4];
	olength1 = length1;
	olength2 = length2;

	oldsig = 0; /* for the filter */

	amp = p[5];
	namp = p[2];
	spread = p[6];
	skip = (int)(SR/(float)resetval);

	aamp = oamp = 0.0;

	return nSamps();
}
int CLAR::init(double p[], int n_args)
{
// p0 = start; p1 = dur; p2 = noise amp; p3 = length1; p4 = length2
// p5 = output amp; p6 = d2 gain; p7 = stereo spread (0-1) <optional>
// function slot 1 is the noise amp envelope
// function slot 2 is the output amp envelope

	int imax;

	if (rtsetoutput(p[0], p[1], this) == -1)
		return DONT_SCHEDULE;

	dampcoef = .7;

	amparr = floc(1);
	if (amparr) {
		int lenamp = fsize(1);
		tableset(SR, p[1], lenamp, amptabs);
	}
	else
		rtcmix_advise("CLAR", "Setting noise amp curve to all 1's.");

	oamparr = floc(2);
	if (oamparr) {
		int olenamp = fsize(2);
		tableset(SR, p[1], olenamp, oamptabs);
	}
	else
		rtcmix_advise("CLAR", "Setting output amp curve to all 1's.");

	imax = DELSIZE;
	mdelset(SR, del1,dl1,imax);
	mdelset(SR, del2,dl2,imax);

//	srrand(0.1);
	length1 = (int)p[3];
	length2 = (int)p[4];

	oldsig = 0; /* for the filter */

	amp = p[5];
	namp = p[2];
	d2gain = p[6];
	spread = p[7];
	skip = (int)(SR/(float)resetval);

	aamp = oamp = 1.0;        /* in case amparr or oamparr are NULL */

	return nSamps();
}