Wraping the signal.

For general discussion related FlowStone
Post Reply
joejoe
Posts: 23
Joined: Mon Oct 21, 2013 2:28 am

Wraping the signal.

Post 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?
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Wraping the signal.

Post 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;
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
joejoe
Posts: 23
Joined: Mon Oct 21, 2013 2:28 am

Re: Wraping the signal.

Post 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.
Post Reply