Example #1
0
void getDesiredBackbufferSize(int &sz_x, int &sz_y) {
	sz_x = display_xres;
	sz_y = display_yres;
	std::string config = NativeQueryConfig("hwScale");
	int scale;
	if (1 == sscanf(config.c_str(), "%d", &scale) && scale > 0) {
		correctRatio(sz_x, sz_y, scale);
	} else {
		sz_x = 0;
		sz_y = 0;
	}
}
Example #2
0
void getDesiredBackbufferSize(int &sz_x, int &sz_y) {
	sz_x = display_xres;
	sz_y = display_yres;
	std::string config = NativeQueryConfig("hwScale");
	int scale;
	if (1 == sscanf(config.c_str(), "%d", &scale) && scale > 0) {
		correctRatio(sz_x, sz_y, scale);
	} else {
		sz_x = 0;
		sz_y = 0;
	}
	// Round the size up to the nearest multiple of 4. While this may cause a tiny aspect ratio distortion,
	// there's some hope that #11151 is a driver bug that might be worked around this way. If this fixes it,
	// it'll be worth trying to round to a multiple of 2 instead.
	sz_x = (sz_x + 3) & ~3;
	sz_y = (sz_y + 3) & ~3;
}
Example #3
0
void MLProcRate::process(const int samples)
{	
	const MLSignal& x = getInput(1);
	const MLSignal& ratioSig = getInput(2);
	MLSignal& y = getOutput(1);
	const float isr = getContextInvSampleRate();
	const float kFeedback = isr*10.f; 
	
	// allow ratio change once per buffer
	float rIn = ratioSig[samples - 1];
	if (rIn != mFloatRatio)
	{	
		mCorrectedRatio = correctRatio(rIn);
		mFloatRatio = rIn;
	}
		
	// if input phasor is off, reset and return.
	if(x[0] < 0.f) 
	{
		mOmega = 0.f;
		y.fill(-0.0001f);
		return;
	}
	
	if(mCorrectedRatio)
	{
		// run the PLL, correcting the output phasor to the input phasor and ratio.
		float r = mCorrectedRatio.getFloat();
		float rInv = 1.0f/r;
		float numerator = mCorrectedRatio.top;			
		float numeratorInv = 1.0f/numerator;
		float error;
		for (int n=0; n<samples; ++n)
		{
			float px = x[n];
			float dxdt = px - mx1;
			mx1 = px;
			float dydt = ml::max(dxdt*r, 0.f);
			float dxy = px - mOmega*rInv;
			
			// get modOffset, such that phase difference is 0 at each integer value of modOffset
			float modOffset = dxy*numerator;
			
			// get error term, valid at any phase difference.
			error = roundf(modOffset) - modOffset;
			
			// convert back to absolute phase difference
			error *= numeratorInv;
			
			// feedback = negative error * time constant
			dydt -= kFeedback*error;
			
			// don't ever run clock backwards.
			dydt = ml::max(dydt, 0.f);
			
			// wrap phasor
			mOmega += dydt;
			if(mOmega >= 1.0f)
			{
				mOmega -= 1.0f;
			}		
						
			y[n] = mOmega;
		}
	}
	else
	{
		// don't correct the phase, just run phasor at float ratio of input rate.
		for (int n=0; n<samples; ++n)
		{
			float px = x[n];
			float dxdt = px - mx1;
			mx1 = px;
			float dydt = ml::max(dxdt*mFloatRatio, 0.f);
			
			// wrap phasor
			mOmega += dydt;
			if(mOmega >= 1.0f)
			{
				mOmega -= 1.0f;
			}		
			
			y[n] = mOmega;
		}
	}
}