Page 4 of 6

Re: For those not in the no (Tips and Tricks)

PostPosted: Fri Jan 22, 2016 5:03 pm
by rocknrollkat
Jan. 22, 2016
Waiting for the snow here in N.Y.C., time to come up with another dead simple schematic, and learn some Ruby as well.
I'm 'teaching' myself Ruby, since I haven't found any really comprehensive 'Start Here' lessons for Audio development in Ruby, I'm doing it the old fashioned way, what we call "Brute Force" methodology, just keep punching away in one direction and sooner or later....
Effective ??
Yes, when you compare it to the amount of time it takes to slog through many lessons in non Flowstone Ruby, try to translate into the Flowstone dialect of Ruby, etc.
Cutting to the chase, here a nifty way to get that 'knob' centered, if that's what you need to do.
Think 'pan pot', etc.
Here's a 21 step 'pot' that indicates dead center at the 11th step, the LEDs show you when you've arrived.
I created the simplest code possible, used 3 different 'operators', and came up with this.
I hope some noobs to Ruby (like me) can learn from this type of thing.

Enjoy !!

ROXY

Re: For those not in the no (Tips and Tricks)

PostPosted: Fri Jan 22, 2016 5:27 pm
by rocknrollkat
Jan. 22, 2016
It's me again, with another dead simple Ruby example.
A few days ago I built that knob 'zero' locater using operators, etc.
Here's the same schematic in Ruby, notice that I'm using FLOATS and a NON step knob this time.
Using integers, as I did a few minutes ago, Ruby only increments, decrements in integer values, hence the need for a 'step' knob with a large range to arrive at dead center.
Floats (floating point numbers) get around that, and here's how in this schematic.
Open it up, horse around with the values, learn from what I did.
Have fun and learn along with me, I'm a Roobynoob too !!

ROXY

The Dreadful Stereo Clipper

PostPosted: Tue Jan 26, 2016 7:53 am
by martinvicanek
I often see this dreadful stereo clipper module in schematics right before the audio output:
dreadfulStereoClipper.png
dreadfulStereoClipper.png (14.85 KiB) Viewed 29325 times
To be sure, it is a good idea to have a clipper there in order to prevent overloading the hardware, which would sound much worse! Of course it is best to stay within the (-1,+1) range in the first place, so the clipper is just a safeguard.

So why do I call it dreadful? Because it is extremely inefficient! Ironically, the design indicates an intention to save CPU by exploiting SIMD for the two min/max operations. However, due to the overhead from the Pack/Unpack modules the savings are more than undone: the dreadful stereo clipper uses 85 cycles on my computer. To put this into perspective, you can build a 4-band parametric EQ with less CPU cost!

Actually you would be much better off with a naive replication of two clippers (15 cycles):
twoClippers.png
twoClippers.png (13.15 KiB) Viewed 29325 times

That's not bad, however if you really want to go efficient I'd recommend this optimized stereo clipper (4 cycles):
MVsClipper.png
MVsClipper.png (16.99 KiB) Viewed 29325 times

Here is the code:
Code: Select all
streamin Lin;
streamin Rin;
streamout Lout;
streamout Rout;

float FP99=.99;
float MP99=-.99;

movaps xmm0,Lin;
movaps xmm1,Rin;
shufps xmm0,xmm1,68;
minps xmm0,FP99;
maxps xmm0,MP99;
movaps Lout,xmm0;
shufps xmm0,xmm0,78;
movaps Rout,xmm0;

Re: For those not in the no (Tips and Tricks)

PostPosted: Tue Jan 26, 2016 2:16 pm
by rocknrollkat
Hi Martin,
GREAT post !!
Very informative, my experience has been that the pack-unpack routine usually encompasses a much larger schematic and the 'stereo clip' module is just a safety valve at the end of the schematic, so overall, the clock overhead would only rise by a tiny percentage.
Very informative though, that you show us how clock cycles add up while we're not looking !
It's nice that you offer a mono schematic and an optimized stereo pair.
I would be very interested in learning how you measure clock cycles.
If you have a minute, could you spell it out for us ?

Thanks-a-plenty,

ROXY

Re: For those not in the no (Tips and Tricks)

PostPosted: Tue Jan 26, 2016 10:14 pm
by martinvicanek
Sure, here is my test kit. Press and hold the black button until the reading stabilizes. You may get different results depending on what other background tasks your PC is busy with while you measure. Also if you stack two modules you won't necessarily get twice the CPU load as you might expect. How much CPU a certain module will eventually use in your schematic depends quite a lot on context.

Re: For those not in the no (Tips and Tricks)

PostPosted: Wed Jan 27, 2016 12:05 am
by rocknrollkat
Hi Martin,
This is one of the KOOOOLEST pieces of gear I have EVER seen !!
Thank you SO much for your generosity !!
This is like having a 'carb synchronizer' when setting up an XKE, sure, you can do it without one, but the RIGHT tool makes life SO much easier !!
I will put it to good use and keep you posted.
Thank you again from New York City !!

ROXY

Re: For those not in the no (Tips and Tricks)

PostPosted: Wed Jan 27, 2016 2:26 pm
by rocknrollkat
Jan. 27, 2016
Hi gang,
Here's something that I've been meaning to sort out, it's another dead simple schematic to convert those unpredictable floats into something with a fixed decimal point.
Integers are no help since they don't acknowledge decimals at all, and floats try to be so helpful in supplying as many decimal places as possible.
That can drive displays crazy with decimals that float left and right.
Now your displays can deliver 1,2 or 3 decimal places every time.
Here's how....

Enjoy !!

ROXY

Re: For those not in the no (Tips and Tricks)

PostPosted: Wed Jan 27, 2016 2:56 pm
by Spogg
Simple and elegant. Into my toolbox!
Cheers
Spogg

Re: For those not in the no (Tips and Tricks)

PostPosted: Wed Jan 27, 2016 3:40 pm
by rocknrollkat
Spogg, I'm happy that you enjoy my work !!

ROXY :D

Re: For those not in the no (Tips and Tricks)

PostPosted: Wed Jan 27, 2016 4:55 pm
by Nubeat7
interesting way to do it :)
you can also use the format prim for this, it has the advantage of correct roundings...