Page 2 of 2

Re: Schmitt triggers

PostPosted: Fri Jul 29, 2022 6:00 pm
by RJHollins
:lol:

Straight to the toolbox.

Re: Schmitt triggers

PostPosted: Sat Jul 30, 2022 12:30 pm
by Tepeix
Here's a Tulamide Switch in asm !)

Interesting sound ;) Act as distortion, gate, and a sort of sequencer.. With ton of aliasing !)
Maybe other's use are possible !)

This one is more hard to do.
Maybe it's possible to optimize it further.
This solution need 4 comparison.
Comparing the in and the last in value 2 time.


Also a new Schmith Trigger.
I think this one is the most optimized but not so sure.
It use 1 comparison, 2 andps, and a boolean output.
If you need a boolean this is better.
(in asm seams that it's not possible to declare boolean variable ?)

Re: Schmitt triggers

PostPosted: Sun Jul 31, 2022 12:51 am
by tulamide
Cool! Thanks a lot. I have no knowledge of Assembler, so I will just assume it's the fastest. But honestly I wouldn't use it for manipulating audio. I could rather think of some transient detection or stuff like that. But there sure are better algorithms for those purposes already. :lol:

Re: Schmitt triggers

PostPosted: Sun Jul 31, 2022 8:59 am
by Spogg
Tepeix wrote:Here's a Tulamide Switch in asm !)

... Also a new Schmith Trigger ...


Clever stuff Tepeix!

Re: Schmitt triggers

PostPosted: Sun Jul 31, 2022 6:38 pm
by Tepeix
That's a very interesting thing to do in asm !)
Maybe specially because i'm just in the learn of how to compare efficiently in complex logic.

If using only one or some Tulamide Switch, there's not much gain to find optimization.
But i like to imagine a very big amount of switch feeding some neural network that detect pitch or peak...
Héhé maybe that's not possible and there's no utility for large amount..

I find another code but it take just a little more cpu..
But it was interesting..

This one use no classic comparison. But abs and sign.
If y >= x, then sign of y-x is positive.
also max (x,0) could be replaced by x+abs(x) (but it double the result..)
also the output of this one is -0.5 to 0.5..

Code: Select all
streamin in; streamout out;
streamin t; streamin u;
int abs=2147483647;
int sgn=-2147483648;
float n5=0.5;
float a=0; float b=0;
movaps xmm5,n5;
movaps xmm6,sgn;
movaps xmm7,abs;

movaps xmm0,in;
movaps xmm4,xmm0;
subps xmm0,t;
//sign(in-t)//
andps xmm0,xmm6;
orps xmm0,xmm5;
//sign - last sign  > positive if last one negative
movaps xmm1,a;
movaps a,xmm0;
subps xmm0,xmm1;
movaps xmm1,xmm0;
//+abs could not be negative
andps xmm1,xmm7;
addps xmm0,xmm1;

addps xmm0,out;
//sign(in-u)//
subps xmm4,u;
andps xmm4,xmm6;
orps xmm4,xmm5;
//sign - last sign
movaps xmm1,b;
movaps b,xmm4;
subps xmm4,xmm1;
//-abs could not be positive
movaps xmm1,xmm4;
andps xmm1,xmm7;
subps xmm4,xmm1;
//
addps xmm0,xmm4;

// "min+max" >  x<0.5 or x>0.5  => x=-0.5 or 0.5
subps xmm0,xmm5;
andps xmm0,xmm6;
orps xmm0,xmm5;

movaps out,xmm0;

I'm happy that this work.. But it take more cpu..