Page 1 of 1

Wraping the signal.

Posted: Fri Nov 08, 2013 4:49 am
by joejoe
Has anyone made any components that wrap the signal between -1 and 1 or 0 and 1? Would you be able to share with me?

Re: Wraping the signal.

Posted: Fri Nov 08, 2013 12:40 pm
by trogluddite
Hi joejoe,

Not at my FS machine at the moment - but copy/pasting this code into an assembly primitive should get you what you need (not tested!)

Code: Select all

streamin in;
streamout out;

float one = 1.0;
float two = 2.0;
float half = 0.5;

movaps xmm0,in;

//Scale -1..1 to 0..1
addps xmm0,one;
mulps xmm0,half;

//Wrap to 0..1 by removing integer part.
movaps xmm1,xmm0;
addps xmm1,half;
cvtps2dq xmm1,xmm1;
cvtdq2ps xmm1,xmm1;
subps xmm0,xmm1;

//Scale 0..1 to -1..1
mulps xmm0,two;
subps xmm0,one;

movaps out,xmm0;

Re: Wraping the signal.

Posted: Fri Nov 08, 2013 2:47 pm
by joejoe
Thank you Tro, I do get sound out of it and when I bring my osc to 1 I get distortion which I suppose should be the case. Correct? When plugging a scope into it I don't get an output reading.