For those not in the no (Tips and Tricks)

Post any examples or modules that you want to share here
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

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

Post 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
Attachments
ROXY 21 step RUBY knob locater.fsm
Where's 'mono' on that pan pot, for real ?
Let Ruby help !
(80.85 KiB) Downloaded 1343 times
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

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

Post 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
Attachments
ROXY RUBY knob zero position locater.fsm
Zero locater updated to Rubycode, educational !
(80.8 KiB) Downloaded 1352 times
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

The Dreadful Stereo Clipper

Post 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 32527 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 32527 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 32527 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;
Last edited by martinvicanek on Tue Jan 26, 2016 10:17 pm, edited 1 time in total.
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

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

Post 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
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

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

Post 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.
Attachments
Clippers.fsm
(7.01 KiB) Downloaded 1387 times
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

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

Post 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
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

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

Post 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
Attachments
ROXY Float to Decimal Place Converter.fsm
Get those pesky decimal points under control !
(557 Bytes) Downloaded 1333 times
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

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

Post by Spogg »

Simple and elegant. Into my toolbox!
Cheers
Spogg
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

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

Post by rocknrollkat »

Spogg, I'm happy that you enjoy my work !!

ROXY :D
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

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

Post by Nubeat7 »

interesting way to do it :)
you can also use the format prim for this, it has the advantage of correct roundings...
Attachments
Float to Decimal Place Converter.fsm
(399 Bytes) Downloaded 1388 times
Post Reply