Using SIMDRegister<double> for an LFO?


#1

Hi, I’m trying to look at the SIMD stuff in JUCE and I made a quick sine LFO using 2D rotation

	SIMDRegister<double> mod1XY;
	SIMDRegister<double> mod1SC;
	SIMDRegister<double> mod1CS;
setup...
	mod1XY.set(0, 0.0);
	mod1XY.set(1, 1.0);
	double a = .0001;
	mod1CS.set(0,cos(a));
	mod1CS.set(1,sin(a));
	mod1SC.set(0, -sin(a));
	mod1SC.set(1, cos(a));

	double getLFO()
	{
	
		SIMDRegister<double> mod  = mod1XY * mod1CS;
		SIMDRegister<double> mod2 = mod1XY * mod1SC;
		mod1XY.set(0, mod.get(0)  + mod.get(1));
		mod1XY.set(1, mod2.get(0) + mod2.get(1));
		return (mod1XY.get(0));
	}

But it seems quite long winded for doubles, especially without the swizzling. Plus the get and set seem to go though a lot of code. Is it a waste of time, or am I doing something wrong?
Thanks,
Dave


#2

OK I get the idea I should do 2 LFO’s with the code and put all the answers in a single SIMD.
I think I might use normal SSE2 though. :slight_smile:
Revised for two LFOs:-
modSinM is all negative sine of the angle.

	forcedinline SIMDRegister<double>  modOsc()
	{

		SIMDRegister<double> px   = modX * modCos;
		SIMDRegister<double> py = modX * modSinM;
		modX = SIMDRegister<double>::multiplyAdd(px,  modY, modSin);
		modY = SIMDRegister<double>::multiplyAdd(py,  modY, modCos);
		return modX;
	}