void ATKSideChainCompressor::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
  // Mutex is already locked for us.

  if (IsInChannelConnected(2))
  {
    inSideChainLFilter.set_pointer(inputs[2], nFrames);
  }
  else
  {
    inSideChainLFilter.set_pointer(inputs[0], nFrames);
  }
  if (IsInChannelConnected(3))
  {
    inSideChainRFilter.set_pointer(inputs[3], nFrames);
  }
  else
  {
    inSideChainRFilter.set_pointer(inputs[1], nFrames);
  }
  inLFilter.set_pointer(inputs[0], nFrames);
  outLFilter.set_pointer(outputs[0], nFrames);
  inRFilter.set_pointer(inputs[1], nFrames);
  outRFilter.set_pointer(outputs[1], nFrames);
  endpoint.process(nFrames);
}
Example #2
0
void IPlugDistortion::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
  bool isMono = !IsInChannelConnected(1);

  for (int i = 0; i < nFrames; ++i)
  {
    double sample = isMono ? inputs[0][i] : 0.5 * (inputs[0][i] + inputs[1][i]);
    double output;

    for (int j = 0; j < mOversampling; ++j)
    {
      // Upsample
      if (j > 0) sample = 0.;
      mUpsample.Process(sample, mAntiAlias.Coeffs());
      sample = (double)mOversampling * mUpsample.Output();

      // Distortion
      if (WDL_DENORMAL_OR_ZERO_DOUBLE_AGGRESSIVE(&sample))
        sample = 0.;
      else
        sample = mGain * (fast_tanh(mDC + mDrive * sample) - mDistortedDC);

      // Downsample
      mDownsample.Process(sample, mAntiAlias.Coeffs());
      if (j == 0) output = mDownsample.Output();
    }

    outputs[0][i] = outputs[1][i] = output;
  }
}
Example #3
0
void FreakkTrem::ProcessDoubleReplacing(double** inputs, double** outputs, int sampleFrames)
{
	double* in1 = inputs[0];
	double* in2 = inputs[1];
	double* out1 = outputs[0];
	double* out2 = outputs[1];

	bool isMono = !IsInChannelConnected(1);
	
	double samplerate = GetSampleRate();
	double sineMod, squareMod;
	int window = 0;
	
	for (int s = 0; s < sampleFrames; ++s, ++in1, ++in2, ++out1, ++out2)
	{
	
	// increment our counter
	if(counter < ((1/mFreq) * samplerate)) // counter goes from 0 to T = 1/f
	{
	 counter++;
	}
	else
	{
	counter = 0;
	}
		// f = counter/mSampleRate
		// T = 1/f = mSampleRate/counter
		// calculate SINE multiplier: 
		// 1) SINE WAVE CARRIER:
		// v(t) = (Ec + em) * sin(2*PI*Freq*t) ==> [ Ec + Em * sin(2*PI*Freq*t) ] sin(2*PI*Freq*t) 
		// Ec = carrier wave
		// em = Em*sin(2*PI*Freq*t) instantaneous amplitude of the modulating signal
		// panL = panR = 1;
		
			// A
			sineMod = (1.0 - mDepth) + mDepth * ( sin((2 * 3.14 *(mFreq/2)) * (counter/samplerate)) ) * (sin((2 *3.14 * (mFreq/2)) * (counter/samplerate)));
			// B
			//sineMod = (1.0 - mDepth) + mDepth *  ( 0.5 + 0.5 * sin((2 *3.14 * (mFreq)) * (counter/samplerate)));
			squareMod = (1.0 - mDepth) + mDepth *  ( 0.5 + 0.5 * tanh( 10 * sin((2 *3.14 * (mFreq)) * (counter/samplerate)) ) );
			*out1 = *in1 * ((1-mModMix) * sineMod + mModMix * squareMod) * mGain * panL;
			*out2 = *in2 * ((1-mModMix) * sineMod + mModMix * squareMod) * mGain * panR;	

		
	}
	/*	
	for (int s = 0; s < sampleFrames; ++s, ++in1, ++in2, ++out1, ++out2)
	  {
		*out1 = *in1 * mGain;
		*out2 = *in2 * mGain;
	  }
	*/
}
Example #4
0
void IPlugSideChain::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
  // Mutex is already locked for us.

  bool in1ic = IsInChannelConnected(0);
  bool in2ic = IsInChannelConnected(1);
  bool in3ic = IsInChannelConnected(2);
  bool in4ic = IsInChannelConnected(3);

  printf("%i %i %i %i, ------------------------- \n", in1ic, in2ic, in3ic, in4ic);

#ifdef RTAS_API
  double* in1 = inputs[0];
  double* in2 = inputs[1];
  double* scin1 = inputs[2];

  double* out1 = outputs[0];
  double* out2 = outputs[1];

  double peakL = 0.0, peakR = 0.0, peakLS = 0.0;

  for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++scin1, ++out1, ++out2)
  {
    *out1 = *in1 * mGain;
    *out2 = *in2 * mGain;

    peakL = IPMAX(peakL, fabs(*in1));
    peakR = IPMAX(peakR, fabs(*in2));
    peakLS = IPMAX(peakLS, fabs(*scin1));
  }

  double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK);
  double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK);
  double xLS = (peakLS < mPrevLS ? METER_DECAY : METER_ATTACK);

  peakL = peakL * xL + mPrevL * (1.0 - xL);
  peakR = peakR * xR + mPrevR * (1.0 - xR);
  peakLS = peakLS * xLS + mPrevLS * (1.0 - xLS);

  mPrevL = peakL;
  mPrevR = peakR;
  mPrevLS = peakLS;

  if (GetGUI())
  {
    GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL);
    GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR);
    GetGUI()->SetControlFromPlug(mMeterIdx_LS, peakLS);
  }

#else
  double* in1 = inputs[0];
  double* in2 = inputs[1];
  double* scin1 = inputs[2];
  double* scin2 = inputs[3];

  double* out1 = outputs[0];
  double* out2 = outputs[1];

  double peakL = 0.0, peakR = 0.0, peakLS = 0.0, peakRS = 0.0;

//Stupid hack because logic connects the sidechain bus to the main bus when no sidechain is connected
//see coreaudio mailing list
#ifdef AU_API
  if (GetHost() == kHostLogic)
  {
    if(!memcmp(in1, scin1, nFrames * sizeof(double)))
    {
      memset(scin1, 0, nFrames * sizeof(double));
      memset(scin2, 0, nFrames * sizeof(double));
    }
  }
#endif

  for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++scin1, ++scin2, ++out1, ++out2)
  {
    *out1 = *in1 * mGain;
    *out2 = *in2 * mGain;

    peakL = IPMAX(peakL, fabs(*in1));
    peakR = IPMAX(peakR, fabs(*in2));
    peakLS = IPMAX(peakLS, fabs(*scin1));
    peakRS = IPMAX(peakRS, fabs(*scin2));
  }

  double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK);
  double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK);
  double xLS = (peakLS < mPrevLS ? METER_DECAY : METER_ATTACK);
  double xRS = (peakRS < mPrevRS ? METER_DECAY : METER_ATTACK);

  peakL = peakL * xL + mPrevL * (1.0 - xL);
  peakR = peakR * xR + mPrevR * (1.0 - xR);
  peakLS = peakLS * xLS + mPrevLS * (1.0 - xLS);
  peakRS = peakRS * xRS + mPrevRS * (1.0 - xRS);

  mPrevL = peakL;
  mPrevR = peakR;
  mPrevLS = peakLS;
  mPrevRS = peakRS;

  if (GetGUI())
  {
    GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL);
    GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR);
    GetGUI()->SetControlFromPlug(mMeterIdx_LS, peakLS);
    GetGUI()->SetControlFromPlug(mMeterIdx_RS, peakRS);
  }
#endif
}