Example #1
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();
}
Example #2
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();
}
Example #3
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();
}
void SuperColliderLoopElement::guiEvent(ofxUIEventArgs &e) {
    if (e.getName() == "Play") {
        setPlaying(isPlay);
    }
    else if (e.getName() == "Rec") {
        setToRecord(toRecord);
    }
    else if (e.getName() == "Solo") {
        setSolo(solo);
        SuperColliderLoopElement *ref = this;
        ofNotifyEvent(soloEvent, ref);
    }
    else if (e.getName() == "Del") {
        SuperColliderLoopElement *ref = this;
        ofNotifyEvent(deleteEvent, ref);
    }
    else if (e.getName() == "Skip") {
        skip = pow((float) 2, (float) ((ofxUIRadio *) gui->getWidget("Skip"))->getValue());
        count = beat % (numBeats * getSkip());
    }
    else if (e.getName() == "BusIn") {
        int channel = ((ofxUIRadio *) gui->getWidget("BusIn"))->getValue();
        bufWriter->set("channel", channel);
    }
    else if (e.getName() == "Volume") {
        cout << "write vol " << volume << endl;
        bufReader->set("volume", volume);
    }
}
Example #5
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();
}
Example #6
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();
}
Example #7
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;
}
Example #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();
}
Example #10
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;
}
Example #11
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();
}
Example #12
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();
}
Example #13
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();
}
int TRANS3::run()
{
   const int outframes = framesToRun();
   const int inchans = inputChannels();
   float *outp = outbuf;     // point to inst private out buffer
   double frac;

   for (int i = 0; i < outframes; i++) {
      if (--branch <= 0) {
         doupdate();
         branch = getSkip();
      }
      while (getframe) {
         if (inframe >= RTBUFSAMPS) {
            rtgetin(in, this, RTBUFSAMPS * inchans);
            inframe = 0;
         }
         oldersig = oldsig;
         oldsig = newsig;
         newsig = newestsig;

         newestsig = in[(inframe * inchans) + inchan];

         inframe++;
         incount++;

         if (counter - (double) incount < 0.0)
            getframe = false;
      }

//      const double frac = (counter - (double) incount) + 2.0;
      const double frac = (counter - (double) incount) + 1.0;
      outp[0] = interp3rdOrder(oldersig, oldsig, newsig, newestsig, frac) * amp;

#ifdef DEBUG_FULL
      printf("i: %d counter: %g incount: %d frac: %g inframe: %d cursamp: %d\n",
             i, counter, incount, frac, inframe, currentFrame());
      printf("interping %g, %g, %g, %g => %g\n", oldersig, oldsig, newsig, newestsig, outp[0]);
#endif

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

      outp += outputChannels();
      increment();

      counter += _increment;         // keeps track of interp pointer
      if (counter - (double) incount >= 0.0)
         getframe = true;
   }

#ifdef DEBUG
   printf("OUT %d frames\n\n", i);
#endif

   return framesToRun();
}
void SuperColliderLoopElement::setBeat(int beat) {
    this->beat = beat;
    if (beat % getNumBeats() == 0 && getPlaying())
    {
        count = (count + 1) % getSkip();
        if (count % (numBeats * getSkip()) == 0) {
            if (!mute) play();
            count = 0;
        }
    }
    
    if (beat == 0 && getToRecord()) {
        beginRecording();
    }
    else if (isRecord && (beat >= numBeats || beat == 0)) {
        setRecording(false);
    }
}
Example #16
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();
}
Example #18
0
int MBASE::getInput(int currentFrame, int frames)
{
    // number of samples to process this time through
	const int inChans = inputChannels();

    int rsamps = frames * inChans;

    rtgetin(in, this, rsamps);
	
    int n = 0;
    int lCurSamp;	// local copy for inner loops
    float insig;
#ifdef LOOP_DEBUG
    int nsig = 0, nzeros = 0;
#endif
	float scale = 1.0/inChans;
    // apply curve to input signal and mix down to mono if necessary

    for (int s = 0, curFrm = currentFrame; s < rsamps; s += inChans, curFrm++)
    {
		if (curFrm < insamps) {	/* processing input signal */
#ifdef LOOP_DEBUG
			nsig++;
#endif
			if (--m_branch < 0) {
			   inamp = update(3, insamps, curFrm);
			   if (amparray)
    			  inamp *= tablei(curFrm, amparray, amptabs);
			   m_branch = getSkip();
			}
			if (m_inchan == AVERAGE_CHANS) {
			   insig = 0.0;
			   for (int c = 0; c < inChans; c++)
    			  insig += in[s + c];
			   insig *= scale;
			}
			else
			   insig = in[s + m_inchan];
			insig *= inamp;
		}
		else  {                               /* flushing delays & reverb */
#ifdef LOOP_DEBUG
			nzeros++;
#endif
 			insig = 0.0;
		}
	    in[n++] = insig;	// write back into input array to save space
    }
#ifdef LOOP_DEBUG
	DBG1(printf("getInput(): %d signal, %d zero padded\n", nsig, nzeros));
#endif
	return 0;
}
Example #19
0
File: var.c Project: dioptre/SABR
varData *getGenVar(indexList *varList,varType type,int *vals,int size){

	indexList *indList = varList;
	skipList *sList = indList->keyList;

	varInd ind;
	ind.key = vals;
	ind.size = size;

	varInd *retInd = getSkip(sList,&ind);
	if(!retInd)
		return NULL;

	varData *retData = retInd->vdat;
	return retData;
}
Example #20
0
int FREEVERB :: run()
{
   float *inL, *inR, *outL, *outR;

   inL = in;
   inR = inputChannels() > 1 ? in + 1 : in;
   outL = outbuf;
   outR = outputChannels() > 1 ? outbuf + 1 : outbuf;

   int samps = framesToRun() * inputChannels();

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

   // Scale input signal by amplitude multiplier and setline curve.
   for (int i = 0; i < samps; i += inputChannels()) {
      if (--branch <= 0) {
         double p[11];
         update(p, 11, kRoomSize | kPreDelay | kDamp | kDry | kWet | kWidth);
         if (currentFrame() < insamps) {  // amp is pre-effect
            amp = update(3, insamps);
            if (amparray)
               amp *= tablei(currentFrame(), amparray, amptabs);
         }
         updateRvb(p);
         branch = getSkip();
      }
      if (currentFrame() < insamps) {     // still taking input from file
         in[i] *= amp;
         if (inputChannels() == 2)
            in[i + 1] *= amp;
      }
      else {                              // in ringdown phase
         in[i] = 0.0;
         if (inputChannels() == 2)
            in[i + 1] = 0.0;
      }
      increment();
   }

   // Hand off to Freeverb to do the actual work.
   rvb->processreplace(inL, inR, outL, outR, framesToRun(), inputChannels(),
                                                         outputChannels());

   return framesToRun();
}
Example #21
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();
}
Example #22
0
int CONVOLVE1::run()
{
	const int inchans = inputChannels();
	const int outchans = outputChannels();
	const int nframes = framesToRun();

	if (currentFrame() < _inframes) {
		const int insamps = nframes * inchans;
		rtgetin(_inbuf, this, insamps);
		for (int i = _inchan; i < insamps; i += inchans)
			_bucket->drop(_inbuf[i]);
	}
	else {
		for (int i = 0; i < nframes; i++)
			_bucket->drop(0.0f);
	}
	// If in last run invocation, make sure everything in bucket is processed.
	if (currentFrame() + nframes >= nSamps())
		_bucket->flush();

	float drypct = 1.0 - _wetpct;

	for (int i = 0; i < nframes; i++) {
		if (--_branch <= 0) {
			doupdate();
			drypct = 1.0 - _wetpct;
			_branch = getSkip();
		}

		float out[2];
		out[0] = (_wet[_outReadIndex] * _wetpct) + (_dry[_outReadIndex] * drypct);
		incrementOutReadIndex();
		out[0] *= _amp;

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

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Example #23
0
// ---------------------------------------------------------------------- run --
int SPECTACLE2_BASE::run()
{
	const int nframes = framesToRun();
	const int inchans = inputChannels();
	const int outchans = outputChannels();

	// If still taking input, store framesToRun() frames into <_inbuf>.
	const bool input_avail = (currentFrame() < _input_frames);
	const int insamps = nframes * inchans;
	if (input_avail)
		rtgetin(_inbuf, this, insamps);

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

		float insig;
		if (input_avail)
			insig = _inbuf[(i * inchans) + _inchan] * _iamp;
		else
			insig = 0.0f;
		_bucket->drop(insig);	// may process <_decimation> input frames

		float outsig = _outbuf[_out_read_index] * _wet;
		increment_out_read_index();

		float drysig = _dry_delay->next(insig);
		outsig += drysig * _dry;

		float out[outchans];
		out[0] = outsig * _oamp;
		if (outchans == 2) {
			out[1] = out[0] * (1.0f - _pan);
			out[0] *= _pan;
		}

		rtaddout(out);
		increment();
	}

	return nframes;
}
Example #24
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;
}
Example #25
0
int MSITAR :: run()
{
	int   i;
	float out[2];

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

			// "amp" is now separate from the internal string amp
			// string amp is controlled by makegen 1, or a table, or it is 1.0
			amp = p[2];
			if (amptable)
				stramp = theEnv->next(currentFrame());
			else if (nargs > 6)
				stramp = p[6];
			else 
				stramp = 1.0;

			if (freq != p[3]) {
				theSitar->setFrequency(p[3]);
				freq = p[3];
			}

			if (nargs > 5) pctleft = p[5];

			branch = getSkip();
		}

		out[0] = theSitar->tick(stramp) * amp;

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

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Example #26
0
int VOCODE3::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) {
			doupdate();
			_branch = getSkip();
		}
		const float carsig = _in[i];
		const float modsig = _in[i + 1];

		float out[2];
		out[0] = 0.0f;
		for (int j = 0; j < _numfilts; j++) {
			float mod;
			if (_hold)
				mod = _lastmod[j];
			else
				mod = _modulator_filt[j]->next(modsig);
			float car = _carrier_filt[_maptable[j]]->next(carsig);
			float balsig = _balancer[j]->next(car, mod);
			if (_scaletable != NULL)
				balsig *= _scaletable[j];
			out[0] += balsig;
		}

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

		rtaddout(out);
		increment();
	}

	return framesToRun();
}
Example #27
0
int DELAY::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[9];
			update(p, 9, kDelTime | kDelRegen | kPan);
			amp = update(3, insamps);
			if (amptable)
				amp *= tablei(cursamp, amptable, amptabs);
			float deltime = p[4];
			delsamps = deltime * SR;
			regen = p[5];
			pctleft = p[8];
			branch = getSkip();
		}

		float sig, out[2];

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

		out[0] = sig + (delay->getsamp(delsamps) * regen);
		delay->putsamp(out[0]);

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

		rtaddout(out);
		increment();
	}
	return framesToRun();
}
Example #28
0
/* ------------------------------------------------------------------ run --- */
int RVB::run()
{
	double rvbsig[2][8192];
	const int frames = framesToRun();
	const int inChans = inputChannels();

    rtgetin(in, this, frames * inChans);

	register float *outptr = &this->outbuf[0];
	/* run summed 1st and 2nd generation paths through reverberator */
 	for (int n = 0; n < frames; n++) {
		if (--_branch <= 0) {
			double p[4];
			update(p, 4);
			m_amp = p[3];
			_branch = getSkip();
		}
		if (m_amp != 0.0) {
			double rmPair[2];
			double rvbPair[2];
			rmPair[0] = in[n*inChans+2];
			rmPair[1] = in[n*inChans+3];
			doRun(rmPair, rvbPair, currentFrame() + n);
			rvbsig[0][n] = rvbPair[0] * m_amp;
			rvbsig[1][n] = rvbPair[1] * m_amp;
		}
		else
			rvbsig[0][n] = rvbsig[1][n] = 0.0;
		/* sum the input signal (which includes early response) & reverbed sigs  */
		*outptr++ = in[n*inChans] + rvbsig[0][n];
		*outptr++ = in[n*inChans+1] + rvbsig[1][n];
	}
	increment(frames);
		
	DBG(printf("FINAL MIX:\n"));
	DBG(PrintInput(&this->outbuf[0], RTBUFSAMPS));
	DBG(PrintInput(&this->outbuf[1], RTBUFSAMPS));
	
	return frames;
}
Example #29
0
int FILTSWEEP :: run()
{
   const 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;
      if (currentFrame() < insamps)
         insig = in[i + inchan];
      else
         insig = 0.0;

      float out[2];
      out[0] = insig;
      if (!bypass) {
         for (int j = 0; j < nfilts; j++)
            out[0] = filt[j]->tick(out[0]);
         if (do_balance)
            out[0] = balancer->tick(out[0], insig);
      }

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

      rtaddout(out);
      increment();
   }

   return framesToRun();
}
Example #30
0
int REV :: run()
{
   int samps = framesToRun() * inputChannels();

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

   for (int i = 0; i < samps; i += inputChannels()) {
      if (--branch <= 0) {
         amp = update(3, insamps);
         if (amparray)
            amp *= tablei(cursamp, amparray, amptabs);
         const double wetdrymix = update(6);
         reverb->setEffectMix(wetdrymix);
         branch = getSkip();
      }

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

      reverb->tick(insig);

      float out[2];
      if (outputChannels() == 2) {
         out[0] = reverb->lastOutputL();
         out[1] = reverb->lastOutputR();
      }
      else
         out[0] = reverb->lastOutput();

      rtaddout(out);
      increment();
   }

   return framesToRun();
}