Пример #1
0
//-----------------------------------------------------------------------------------------
void skidder::processPlateau()
{

	// amp in the plateau is 1.0, i.e. this sample is unaffected
	amp = 1.0f;

	plateauSamples--;

	if (plateauSamples <= 0)
	{
		// average & then sqare the sample squareroots for the RMS value
		rms = powf((rms/(float)rmscount), 2.0f);
		// because RMS tends to be < 0.5, thus unfairly limiting rupture's range
		rms *= 2.0f;
		// avoids clipping or unexpected values (like wraparound)
		if ( (rms > 1.0f) || (rms < 0.0f) )
			rms = 1.0f;
		rmscount = 0;	// reset the RMS counter
		//
		// set up the random floor values
		useRandomFloor = fFloorRandMin < fFloor;
		randomFloor = ( ((float)rand()*ONE_DIV_RAND_MAX) * gainScaled(fFloor-fFloorRandMin) ) 
							+ gainScaled(fFloorRandMin);
		randomGainRange = 1.0f - randomFloor;	// the range of the skidding on/off gain
		//
		if (slopeDur > 0)
		{
			state = slopeOut;
			slopeSamples = slopeDur; // refill slopeSamples
			slopeStep = 1.0f / (float)slopeDur;	// calculate the fade increment scalar
		}
		else
			state = valley;
	}
}
Пример #2
0
void floorDisplayConvert(float value, char *string)
{
	if (value <= 0.0f)
		strcpy(string, "-oo  dB");
	else
		sprintf(string, "%.2f  dB", dBconvert(gainScaled(value)));
}
Пример #3
0
//-----------------------------------------------------------------------------------------
void skidder::processReplacing(float **inputs, float **outputs, long sampleFrames, bool replacing) {

  float *in1  = inputs[0];
  float *in2  = inputs[1];
  float *out1 = outputs[0];
  float *out2 = outputs[1];

  float SAMPLERATE = Samplerate();
	// just in case the host responds with something wacky
	if (SAMPLERATE <= 0.0f)   SAMPLERATE = 44100.0f;

  long samplecount;


	floor = gainScaled(fFloor);	// the parameter scaled real value
	gainRange = 1.0f - floor;	// the range of the skidding on/off gain
	useRandomFloor = (fFloorRandMin < fFloor);

	// figure out the current tempo if we're doing tempo sync
	if (onOffTest(fTempoSync))
	{
		// calculate the tempo at the current processing buffer
		currentTempoBPS = tempoScaled(fTempo) / 60.0f;

	}

	for (samplecount=0; (samplecount < sampleFrames); samplecount++)
	{
		switch (state)
		{
			case slopeIn:
				// get the average sqareroot of the current input samples
				rms += sqrtf( fabsf(((*in1)+(*in2))*0.5f) );
				rmscount++;	// this counter is later used for getting the mean
				processSlopeIn();
				break;
			case plateau:
				rms += sqrtf( fabsf(((*in1)+(*in2))*0.5f) );
				rmscount++;
				processPlateau();
				break;
			case slopeOut:
				processSlopeOut();
				break;
			case valley:
				processValley(SAMPLERATE);
				break;
		}

		// ((panRander*fPan)+1.0) ranges from 0.0 to 2.0
		if (replacing)
		{
			*out1 = processOutput( *in1, *in2, ((panRander*fPan)+1.0f) );
			*out2 = processOutput( *in2, *in1, (2.0f - ((panRander*fPan)+1.0f)) );
		}
		else
		{
			*out1 += processOutput( *in1, *in2, ((panRander*fPan)+1.0f) );
			*out2 += processOutput( *in2, *in1, (2.0f - ((panRander*fPan)+1.0f)) );
		}
		// move forward in the i/o sample streams
		in1++;
		in2++;
		out1++;
		out2++;
	}
}