Exemplo n.º 1
0
int GRANSYNTH::run()
{
   const int frames = framesToRun();
   const int outchans = outputChannels();
   int i;
   for (i = 0; i < frames; i++) {
      if (--_branch <= 0) {
         doupdate();
         _branch = getSkip();
      }

      _stream->prepare();

      float out[outchans];
      if (outchans == 2) {
         out[0] = _stream->lastL() * _amp;
         out[1] = _stream->lastR() * _amp;
      }
      else
         out[0] = _stream->lastL() * _amp;

      rtaddout(out);
      increment();
   }

   return i;
}
Exemplo n.º 2
0
int BEND1::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			if (amptable)
				aamp = tablei(currentFrame(), amptable, amptabs) * amp;
			float freq = diff * tablei(currentFrame(), glissf, tags) + freq0;
			sset(SR, freq, tf0, tfN, strumq1);
			branch = reset;
		}

		float a = strum(d, strumq1);
		float b = dist(dgain*a);
		d = fbgain*delay(b, dq);

		float out[2];
		out[0] = (cleanlevel*a + distlevel*b) * aamp;

		if (outputChannels() == 2) { /* split stereo files between the channels */
			out[1] = (1.0 - spread) * out[0];
			out[0] *= spread;
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
int WAVESHAPE::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			doupdate();
			branch = skip;
		}

		float sig = osc->next();
		float wsig = wshape(sig * index, xferfunc, lenxfer);

		// dc blocking filter
		float osig = a1 * z1;
		z1 = b1 * z1 + wsig;
		osig += a0 * z1;

		float out[2];
		out[0] = osig * amp;

		if (outputChannels() == 2) {
			out[1] = (1.0 - spread) * out[0];
			out[0] *= spread;
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 4
0
int AM::run()
{
	const int samps = framesToRun() * inputChannels();

	rtgetin(in, this, samps);

	for (int i = 0; i < samps; i += inputChannels())  {
		if (--branch <= 0) {
			double p[7];
			update(p, 7, kAmp | kFreq | kPan);
			amp = p[3];
			if (amptable)
				amp *= tablei(currentFrame(), amptable, amptabs);
			if (freqtable)
				modfreq = tablei(currentFrame(), freqtable, freqtabs);
			else
				modfreq = p[4];
			modosc->setfreq(modfreq);
			spread = p[6];
			branch = skip;
		}

		float out[2];
		out[0] = in[i + inchan] * modosc->next() * amp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - spread);
			out[0] *= spread;
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 5
0
int MMESH2D :: run()
{
	int   i;
	float out[2];

	for (i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			double p[10];
			update (p, 10, kAmp | kPan);

			amp = p[2];
			if (amptable)
				amp *= theEnv->next(currentFrame());

			branch = getSkip();
		}

		out[0] = dcblocker->next(theMesh->tick()) * amp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - pctleft);
			out[0] *= pctleft;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Exemplo n.º 6
0
int WAVETABLE::run()
{
    const int nframes = framesToRun();
    for (int i = 0; i < nframes; i++) {
        if (--branch <= 0) {
            if (fastUpdate) {
                if (amptable)
                    amp = ampmult * tablei(currentFrame(), amptable, amptabs);
            }
            else
                doupdate();
            branch = getSkip();
        }

        float out[2];
        out[0] = osc->next() * amp;

        if (outputChannels() == 2) {
            out[1] = (1.0 - spread) * out[0];
            out[0] *= spread;
        }

        rtaddout(out);
        increment();
    }
    return framesToRun();
}
Exemplo n.º 7
0
int MULTIWAVE::run()
{
   const int samps = framesToRun();
   const int chans = outputChannels();
   float out[chans];

   for (int i = 0; i < samps; i++) {
      if (--branch <= 0) {
         doupdate();
         branch = getSkip();
      }

      for (int j = 0; j < chans; j++)
         out[j] = 0.0f;

      for (int j = 0; j < numpartials; j++) {
         float sig = oscil[j]->next() * amp[j];
         if (chans == 1)
            out[0] += sig;
         else {
            out[0] += sig * pan[j];
            out[1] += sig * (1.0 - pan[j]);
         }
      }
      float scale = (1.0 / float(numpartials)) * (overall_amp * chans);
      for (int j = 0; j < chans; j++)
         out[j] *= scale;

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
Exemplo n.º 8
0
int CRACKLE::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			doupdate();
			branch = getSkip();
		}

		x3 = x2;
		x2 = x1;
		x1 = x0;
		x0 = std::abs(0.03 - x2 + x3 - param * x1);

		float out[2];
		out[0] = x0 * amp * 5;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - pan);
			out[0] *= pan;
		}
		rtaddout(out);
		increment();
	}

	return framesToRun();
}
int MBOWED :: run()
{
    int   i;
    float out[2];

    for (i = 0; i < framesToRun(); i++) {
        if (--branch <= 0) {
            doupdate();
            branch = getSkip();
        }
        if (--vibupdate < 0) { // reset the vibrato freq after each cycle
            float vibfreq = theRand->range(viblo, vibhi);
            theVib->setfreq(vibfreq);
            vibupdate = (int)(SR/vibfreq);
        }

        out[0] = theBow->tick(bowvel) * amp;
        theBow->setFrequency(freqbase + (freqamp * ( (theVib->next()+2.0) * 0.5 )));

        if (outputChannels() == 2) {
            out[1] = out[0] * (1.0 - pctleft);
            out[0] *= pctleft;
        }

        rtaddout(out);
        increment();
    }

    return framesToRun();
}
Exemplo n.º 10
0
int JFIR :: run()
{
   const int samps = framesToRun() * inputChannels();

   rtgetin(in, this, samps);

   for (int i = 0; i < samps; i += inputChannels()) {
      if (--branch <= 0) {
         doupdate();
         branch = getSkip();
      }

      float insig;
      if (currentFrame() < insamps)          // still taking input
         insig = in[i + inchan] * amp;
      else                                   // in ring-down phase
         insig = 0.0;

      float out[2];
      if (bypass)
         out[0] = insig;
      else
         out[0] = filt->tick(insig);

      if (outputchans == 2) {
         out[1] = out[0] * (1.0 - pctleft);
         out[0] *= pctleft;
      }

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
int IINOISE::run()
{
	for (int i = 0; i < framesToRun(); i++)  {
		if (--branch <= 0) {
			if (fastUpdate) {
				if (amptable)
					amp = ampmult * tablei(currentFrame(), amptable, amptabs);
			}
			else
				doupdate();
			branch = getSkip();
		}

		float sig = rrand();

		float out[2];
		out[0] = 0.0f;
		for (int j = 0; j < nresons; j++)
			out[0] += resons[j]->next(sig) * resonamp[j];

		out[0] *= amp;
		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0f - pan);
			out[0] *= pan;
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 12
0
int SHAPE :: run()
{
   const int samps = framesToRun() * inputChannels();
   rtgetin(in, this, samps);

   for (int i = 0; i < samps; i += inputChannels()) {
      if (--branch <= 0) {
         doupdate();
         branch = skip;
      }

      // NB: WavShape deals with samples in range [-1, 1].
      float insig = in[i + inchan] * (1.0 / 32768.0);
      float outsig = shaper->tick(insig * index);
      if (outsig) {
         if (ampnorm)
            outsig = dcblocker->tick(outsig) * ampnorm->tick(norm_index);
         else
            outsig = dcblocker->tick(outsig);
      }
      float out[2];
      out[0] = outsig * amp * 32768.0;

      if (outputChannels() == 2) {
         out[1] = out[0] * (1.0 - pctleft);
         out[0] *= pctleft;
      }

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
Exemplo n.º 13
0
int WAVY::run()
{
	const int frames = framesToRun();
	const int chans = outputChannels();

	for (int i = 0; i < frames; i++) {
		if (--_branch <= 0) {
			doupdate();
			_branch = getSkip();
		}

		float sig1 = _oscilA->nexti();
		float sig2 = _oscilB->nexti();

		float out[chans];
		if (_fp)
			out[0] = eval(sig1, sig2) * _amp;
		else
			out[0] = (*_combiner)(sig1, sig2) * _amp;

		if (chans == 2) {
			out[1] = out[0] * (1.0f - _pan);
			out[0] *= _pan;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Exemplo n.º 14
0
int GVERB::run()
{
	const int samps = framesToRun() * inputChannels();
	int i;
	float out[2];

	rtgetin(in, this, samps);
	
	for (i = 0; i < samps; i += inputChannels()) {
		if (--branch <= 0) {
			doupdate();
			branch = getSkip();
		}

		if (currentFrame() > inputframes) in[i+inputchan] = 0.0;
		gverb_do(p, in[i+inputchan], out, out+1);

		out[0] = (out[0] * amp) + (in[i+inputchan] * p->drylevel);
		out[1] = (out[1] * amp) + (in[i+inputchan] * p->drylevel);

		rtaddout(out);

		increment();
	}
	return i;
}
Exemplo n.º 15
0
int DISTORT::run()
{
   const int insamps = framesToRun() * inputChannels();
   rtgetin(in, this, insamps);

   for (int i = 0; i < insamps; i += inputChannels()) {
      if (--branch <= 0) {
         doupdate();
         branch = getSkip();
      }
      float sig = in[i + inchan];
      if (!bypass) {
         sig *= (gain / 32768.0f);  // apply gain, convert range
         sig = distort->next(sig, param);
         sig *= 32768.0f;
         if (usefilt)
            sig = filt->tick(sig);
      }
      sig *= amp;
      float out[2];
      if (outputChannels() == 2) {
         out[0] = sig * pctleft;
         out[1] = sig * (1.0f - pctleft);
      }
      else
         out[0] = sig;

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
Exemplo n.º 16
0
int NOISE :: run()
{
   for (int i = 0; i < framesToRun(); i++) {
      if (--branch <= 0) {
         double p[nargs];
         update(p, nargs);
         amp = p[2];
         if (amparray)
            amp *= tablei(currentFrame(), amparray, amptabs);
         pctleft = nargs > 3 ? p[3] : 0.5;         // default is .5
         branch = skip;
      }

      float out[2];
      out[0] = rrand() * amp;

      if (outputChannels() == 2) {
         out[1] = out[0] * (1.0 - pctleft);
         out[0] *= pctleft;
      }

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
Exemplo n.º 17
0
int FMINST::run()
{
	const int nframes = framesToRun();
	for (int i = 0; i < nframes; i++) {
		if (--branch <= 0) {
			if (fastUpdate) {
				if (amptable)
					amp = ampmult * tablei(currentFrame(), amptable, amptabs);
				float guide = tablei(currentFrame(), indexenv, indtabs);
				peakdev = modfreq * (minindex + (indexdiff * guide));
			}
			else
				doupdate();
			branch = getSkip();
		}

		float out[2];

		float modsig = modosc->next() * peakdev;
		carosc->setfreq(carfreq + modsig);
		out[0] = carosc->next() * amp;

		if (outputChannels() == 2) {
			out[1] = (1.0 - pan) * out[0];
			out[0] *= pan;
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 18
0
int STEREO::run()
{
	const int inchans = inputChannels();
	const int samps = framesToRun() * inchans;

	rtgetin(in, this, samps);

	for (int i = 0; i < samps; i += inchans)  {
		if (--branch <= 0) {
			if (fastUpdate) {
				if (amptable)
					amp = ampmult * tablei(currentFrame(), amptable, amptabs);
			}
			else
				doupdate();
			branch = getSkip();
		}

		float out[2];
		out[0] = out[1] = 0.0;
		for (int j = 0; j < inchans; j++) {
			if (outPan[j] >= 0.0) {
				out[0] += in[i+j] * outPan[j] * amp;
				out[1] += in[i+j] * (1.0 - outPan[j]) * amp;
			}
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 19
0
int BROWN::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (--_branch <= 0) {
			doupdate();
			_branch = getSkip();
		}
		float out[2];

		while (true) {
			float r = rrand();
			_brown += r;
			if (_brown <- 8.0 || _brown > 8.0)
				_brown -= r;
			else
				break;
		}

		out[0] = _brown * 0.125 * _amp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - _pan);
			out[0] *= _pan;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
int REVMIX::run()
{
   int samps = framesToRun() * inputChannels();

   rtinrepos(this, -framesToRun(), SEEK_CUR);

   rtgetin(in, this, samps);

   for (int i = samps - inputChannels(); i >=  0; i -= inputChannels())  {
      if (--branch <= 0) {
         double p[nargs];
         update(p, nargs);
         amp = p[3];
         if (amparray)
            amp *= tablei(currentFrame(), amparray, amptabs);
         pctleft = nargs > 5 ? p[5] : 0.5;         // default is .5
         branch = skip;
      }

      float out[2];
      out[0] = in[i + inchan] * amp;

      if (outputChannels() == 2) {
         out[1] = out[0] * (1.0 - pctleft);
         out[0] *= pctleft;
      }

      rtaddout(out);
      increment();
   }
   rtinrepos(this, -framesToRun(), SEEK_CUR);

   return framesToRun();
}
Exemplo n.º 21
0
int MMODALBAR :: run()
{
	int   i;
	float out[2];

	for (i = 0; i < framesToRun(); i++) {
		if (--branch <=0) {
			doupdate();
			branch = getSkip();
		}

		if (currentFrame() < 256) // feed in excitation
			out[0] = theBar->tick(exciteamp, excite[currentFrame()]) * amp;
		else
			out[0] = theBar->tick(exciteamp, 0.0) * amp;

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - pctleft);
			out[0] *= pctleft;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Exemplo n.º 22
0
int MYINST::run()
{
	// framesToRun() gives the number of sample frames -- 1 sample for each
	// channel -- that we have to write during this scheduler time slice.

	const int samps = framesToRun() * inputChannels();

	// Read <samps> samples from the input file (or audio input device).

	rtgetin(_in, this, samps);

	// Each loop iteration processes 1 sample frame. */

	for (int i = 0; i < samps; i += inputChannels()) {

		// This block updates certain parameters at the control rate -- the
		// rate set by the user with the control_rate() or reset() script
		// functions.  The Instrument base class holds this value as a number
		// of sample frames to skip between updates.  Get this value using
		// getSkip() to reset the <_branch> counter.

		if (--_branch <= 0) {
			doupdate();
			_branch = getSkip();
		}

		// Grab the current input sample, scaled by the amplitude multiplier.

		float insig = _in[i + _inchan] * _amp;

		float out[2];		// Space for only 2 output chans!

		// Just copy it to the output array with no processing.

		out[0] = insig;

		// If we have stereo output, use the pan pfield.

		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0f - _pan);
			out[0] *= _pan;
		}

		// Write this sample frame to the output buffer.

		rtaddout(out);

		// Increment the count of sample frames this instrument has written.

		increment();
	}

	// Return the number of frames we processed.

	return framesToRun();
}
int REVERBIT::run()
{
    int samps = framesToRun() * inputChannels();

    if (currentFrame() < insamps)
        rtgetin(in, this, samps);

    for (int i = 0; i < samps; i += inputChannels()) {
        if (--branch <= 0) {
            doupdate();
            branch = getSkip();
        }

        float insig[2], out[2];

        if (currentFrame() < insamps) {        // still taking input from file
            insig[0] = in[i] * amp;
            insig[1] = (inputChannels() == 2) ? in[i + 1] * amp : insig[0];
        }
        else                                   // in ring-down phase
            insig[0] = insig[1] = 0.0;

        float rvbsig = -reverbpct * reverb(insig[0] + insig[1], rvbarray);

        if (usefilt)
            rvbsig = tone(rvbsig, tonedata);

        delput(rvbsig, delarray, deltabs);
        float delsig = delget(delarray, rtchan_delaytime, deltabs);

        out[0] = insig[0] + rvbsig;
        out[1] = insig[1] + delsig;

        if (dcblock) {
            float tmp_in[2];

            tmp_in[0] = out[0];
            tmp_in[1] = out[1];

            out[0] = tmp_in[0] - prev_in[0] + (0.99 * prev_out[0]);
            prev_in[0] = tmp_in[0];
            prev_out[0] = out[0];

            out[1] = tmp_in[1] - prev_in[1] + (0.99 * prev_out[1]);
            prev_in[1] = tmp_in[1];
            prev_out[1] = out[1];
        }

        rtaddout(out);
        increment();
    }

    return framesToRun();
}
Exemplo n.º 24
0
int HOLO::run()
{
    int i, j;
    float output[2];

    int rsamps = framesToRun()*inputChannels();
    rtgetin(in, this, rsamps);

    for (i = 0; i < rsamps; i += 2) {
        if (--count <= 0) {
            double p[5];
            update(p, 5);
            amp = p[3];
            xtalkAmp = (p[4] != 0.0) ? p[4] : 1.0;
            count = skip;
        }
        for (int n = 0; n < 2; n++) {
            int c;
            output[n] = 0.0;
            pastsamps[n][intap] = in[i+n];

            // sum all past samples * coefficients
            // two loops to avoid bounds checking

            for (j = intap, c = 0; j < ncoefs; j++, c++)
                output[n] += (pastsamps[n][j] * sameSideCoeffs[c]);

            const int remaining = ncoefs - c;

            for (j = 0; j < remaining; j++, c++)
                output[n] += (pastsamps[n][j] * sameSideCoeffs[c]);

            // feed signal to opposite side
            pastsamps2[n][intap] = in[i + 1 - n];

            // add this into output for each side

            for (j = intap, c = 0; j < ncoefs; j++, c++)
                output[n] += xtalkAmp * (pastsamps2[n][j] * oppositeSideCoeffs[c]);

            const int remaining2 = ncoefs - c;

            for (j = 0; j < remaining2; j++, c++)
                output[n] += xtalkAmp * (pastsamps2[n][j] * oppositeSideCoeffs[c]);

            output[n] *= amp;
        }
        rtaddout(output);
        increment();
        if (--intap < 0)
            intap = ncoefs - 1;
    }
    return(i);
}
Exemplo n.º 25
0
int ROOM::run()
{
   const int samps = framesToRun() * inputChannels();

   rtgetin(in, this, samps);

   for (int i = 0; i < samps; i += inputChannels()) {
      if (--branch <= 0) {
         if (amparray)
            aamp = tablei(currentFrame(), amparray, amptabs) * amp;
         branch = skip;
      }

      float insig;
      if (currentFrame() < insamps) {        /* still taking input */
         if (inchan == AVERAGE_CHANS) {
            insig = 0.0;
            for (int n = 0; n < inputChannels(); n++)
               insig += in[i + n];
            insig /= (float) inputChannels();
         }
         else
            insig = in[i + inchan];
      }
      else                                   /* in ring-down phase */
         insig = 0.0;

      echo[jpoint++] = insig;
      if (jpoint >= nmax)
         jpoint -= nmax;

      float out[2];
      out[0] = out[1] = 0.0;
      for (int j = 0; j < NTAPS; j++) {
         float e = echo[ipoint[j]];
         out[0] += e * lamp[j];
         out[1] += e * ramp[j];
         ipoint[j]++;
         if (ipoint[j] >= nmax)
            ipoint[j] -= nmax;
      }

      if (aamp != 1.0) {
         out[0] *= aamp;
         out[1] *= aamp;
      }

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
Exemplo n.º 26
0
int COMBIT::run()
{
	int samps = framesToRun() * inputChannels();

	if (currentFrame() < insamps)
		rtgetin(in, this, samps);

	for (int i = 0; i < samps; i += inputChannels())  {
		if (--branch <= 0) {
			double p[8];
			update(p, 8);
			amp = p[3];
			if (amptable) {
#ifdef EMBEDDED
				amp *= rtcmix_table(currentFrame(), amptable, tabs);
#else
				amp *= table(currentFrame(), amptable, tabs);
#endif
			}
			if (p[4] != frequency) {
				frequency = p[4];
				delsamps = (int) ((1.0 / frequency) * SR + 0.5);
			}
			if (p[5] != rvbtime) {
				rvbtime = p[5];
				comb->setReverbTime(rvbtime);
			}
			pctleft = p[7];
			branch = skip;
		}

		float insig, out[2];

		if (currentFrame() < insamps)
			insig = in[i + inchan];
		else
			insig = 0.0;
		out[0] = comb->next(insig, delsamps) * amp;
		if (outputChannels() == 2) {
			out[1] = out[0] * (1.0 - pctleft);
			out[0] *= pctleft;
		}

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Exemplo n.º 27
0
int DUMP::run()
{
	float out[2] = {0.0, 0.0};

	for (int i = 0; i < framesToRun(); i++) {
		if (--branch <= 0) {
			doupdate();
			branch = skip;
		}
		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Exemplo n.º 28
0
int PANECHO::run()
{
	int samps = framesToRun() * inputChannels();

	if (currentFrame() < insamps)
		rtgetin(in, this, samps);

	for (int i = 0; i < samps; i += inputChannels())  {
		if (--branch <= 0) {
			double p[7];
			update(p, 7, kDelTime0 | kDelTime1 | kDelRegen);
			amp = update(3, insamps);
			if (amptable)
				amp *= tablei(currentFrame(), amptable, amptabs);
			float thisdeltime = p[4];
			if (thisdeltime != prevdeltime0) {
				delsamps0 = getdelsamps(thisdeltime);
				prevdeltime0 = thisdeltime;
			}
			thisdeltime = p[5];
			if (thisdeltime != prevdeltime1) {
				delsamps1 = getdelsamps(thisdeltime);
				prevdeltime1 = thisdeltime;
			}
			regen = p[6];
			branch = getSkip();
		}

		float sig, out[2];

		if (currentFrame() < insamps)
			sig = in[i + inchan] * amp;
		else
			sig = 0.0;

		out[0] = sig + (delay1->getsamp(delsamps1) * regen);
		out[1] = delay0->getsamp(delsamps0);

		delay0->putsamp(out[0]);
		delay1->putsamp(out[1]);

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 29
0
int LSFLUTE::run()
{
	for (int i = 0; i < framesToRun(); i++) {
		if (olength1 < length1) olength1++;
		if (olength1 > length1) olength1--;
		if (olength2 < length2) olength2++;
		if (olength2 > length2) olength2--;
		if (--branch <= 0) {
			aamp = tablei(currentFrame(), amparr, amptabs);
			oamp = tablei(currentFrame(), oamparr, oamptabs);
			branch = skip;
		}

		float sig = (rrand() * namp * aamp) + aamp;
		float del1sig = mdelget(del1ptr,olength1,dl1ptr);
		sig = sig + (del1sig * -0.35);
#ifdef MAXMSP
		delput(sig,del2ptr,dl2ptr);
#else
		mdelput(sig,del2ptr,dl2ptr);
#endif

		sig = mdelget(del2ptr,olength2,dl2ptr);
		sig = (sig * sig * sig) - sig;
		sig = (0.4 * sig) + (0.9 * del1sig);

		float out[2];
		out[0] = sig * amp * oamp;
		sig = (dampcoef * sig) + ((1.0 - dampcoef) * oldsig);
		oldsig = sig;
#ifdef MAXMSP
		delput(sig,del1ptr,dl1ptr);
#else
		mdelput(sig,del1ptr,dl1ptr);
#endif

		if (outputChannels() == 2) {
			out[1] = (1.0 - spread) * out[0];
			out[0] *= spread;
		}

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Exemplo n.º 30
0
int WIGGLE::run()
{
   const int nframes = framesToRun();

   for (int i = 0; i < nframes; i++) {
      if (--branch <= 0) {
         doupdate();
         branch = getSkip();
      }

      float mod_sig = 0.0f;
      if (mod_depth != 0.0f) {
         if (depth_type == CarPercent)
            mod_sig = modulator->tick(mod_freq, mod_depth * car_freq);
         else {   // ModIndex
            float mdepth = mod_depth * mod_freq;  // convert mdepth to peak dev.
            mod_sig = modulator->tick(mod_freq, mdepth);
         }
      }
      float car_sig = carrier->tick(car_freq + mod_sig, amp);
#ifdef DEBUG2
      printf("carfreq=%f carsig=%f modsig=%f\n", car_freq, car_sig, mod_sig);
#endif

      float sig = car_sig;
      for (int j = 0; j < nfilts; j++)
         sig = filt[j]->tick(sig);

      if (do_balance)
         sig = balancer->tick(sig, car_sig);

      float out[2];
      if (outputChannels() == 2) {
         out[0] = sig * pan;
         out[1] = sig * (1.0f - pan);
      }
      else
         out[0] = sig;

      rtaddout(out);
      increment();
   }

   return nframes;
}