Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

First and last stupid Ruby question for the year...I hope

For general discussion related FlowStone

First and last stupid Ruby question for the year...I hope

Postby deraudrl » Fri Dec 27, 2019 4:06 am

Forgive me, my only previous exposure to Ruby was in Sketchup macros...

I encountered this snippet inside a toolbox module named 'Delay'. (The question of how it differs from the otherwise identical 'Delay' primitive just above it is best left for another time.)

Code: Select all
streamin in;
streamout out;
streamin delay;
float mem[44100];
float index;

stage(2)
{
   out = mem[index];
}

stage(3)
{
   mem[index] = in;
   index = index + 1;
   index = (index<delay)&index;
}

The last couple of lines look like they're just doing a standard increment-and-wrap, except the expression

index = (index<delay)&index;

screams "SYNTAX ERROR!!" in pretty much any language I've ever encountered. I can live with the idea that 'False' evaluates to 0 in a numeric context, but for this to work, it has to assume that 'True' evaluates to all 1s and 'index' is being treated as an array of bits. (I'm afraid to even ask why 'index' is declared "float".)
I keep a pair of oven mitts next to my computer so I don't get a concussion from slapping my forehead while I'm reading the responses to my questions.
deraudrl
 
Posts: 239
Joined: Thu Nov 28, 2019 9:12 pm
Location: SoCal

Re: First and last stupid Ruby question for the year...I hop

Postby tulamide » Fri Dec 27, 2019 4:21 am

Well, this isn't Ruby code. It's DSP code (a script specific to FS, but shares some ideas from C).

Although you didn't identify the correct language, you found out very well, what this is about. Indeed, what you discovered is a bitmask, with all implications you described. It has to be treated that way, because DSP code runs with SSE, which means up to 4 streams are processed in parallel and therefore only a bitmask can introduce some kind of conditional branching. You can read more about its use in the User Guide.

EDIT: The User Guide also explains why index is declared as a float ;)
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2688
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: First and last stupid Ruby question for the year...I hop

Postby deraudrl » Fri Dec 27, 2019 6:08 am

(massive forehead slap) D'oh!

Still trying to get my head around the mono/poly/mono4 business...

I've done SIMD before, but only on older special-purpose hardware, not SSE. All those applications processed the multiple data streams identically.
I keep a pair of oven mitts next to my computer so I don't get a concussion from slapping my forehead while I'm reading the responses to my questions.
deraudrl
 
Posts: 239
Joined: Thu Nov 28, 2019 9:12 pm
Location: SoCal


Return to General

Who is online

Users browsing this forum: No registered users and 17 guests