Old 06-19-2018, 12:10 PM   #1
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default Recommended MEMSET primer?

Does anyone have a recommended educational source on using memsets as multi-dimensional arrays? Trying to wrap my head around EEL and the best way to implement arrays.
James Slanger is offline   Reply With Quote
Old 06-19-2018, 12:33 PM   #2
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,922
Default

Two dimensional array:

a = 12345; // some number denoting the start of the array in memory. Can be 0 if you only need a single array
n = 100; // the first index ruins 0.. 99
a[i+j*n] = value;

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 06-19-2018, 02:02 PM   #3
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default

Thanks Michael! I should have paid more attention in my CS for Musicians course...
One more basic question, how big is each memory slot? Sizeof(double)? Specifically how many bit flags can I store in each slot?
James Slanger is offline   Reply With Quote
Old 06-19-2018, 03:10 PM   #4
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default

For anyone else looking for similar fundamentals, it just occured to me to use search terms with “JSFX EEL” instead of “OSCii bot.” Most of my questions have been asked and answered on the JSFX forum.

Last edited by James Slanger; 06-19-2018 at 03:24 PM.
James Slanger is offline   Reply With Quote
Old 06-19-2018, 09:23 PM   #5
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,922
Default

Each slot is a floating point number. I once used such EEL floating point number to store Bytes (in fact JSFX sliders for characters of text), and found that I could store five bytes in each. So I suppose it's safe that here are least 40 bits in the mantissa. I guess in fact it should be 47 before it gets unnormalized, plus the sign and the exponent and the exponent's sign, which would be tricky to access.

For such numbers beware of the fact that EEL uses a "soft" compare with any "==" or equivalent compares. Here the symbol "===" is provided for binary compare.

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 06-19-2018 at 09:28 PM.
mschnell is online now   Reply With Quote
Old 06-20-2018, 07:23 AM   #6
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,922
Default

I just did a test and what I said seems not to be correct.

I found that 1<<31 is negative and 1<< 32 is zero.

So eel seems to do logical operations with 32 bit even on reaper 64 bit

But using multiplications, you seem to be able to store 52 bits in a slot:

Code:
descr: test1
@init
x = 0;
xf1 = 0;
xf2 = 0;
y = 0;
z = 0;
yf = 1;
yfa = 1;
loop(52,
  y = 1 << z;
  y != 0 ? (
    x += 1;
  );
  yf = yf * 2;
  yfa = yf + 1;
  yfb = yfa - 1;
  yf == yfb  ? (
    xf1 += 1;
  );
  yf === yfb ? (
    xf2 += 1;
  );
  z += 1;
);
Try changing the 52 to e.g. 53

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 06-22-2018, 02:17 PM   #7
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default

Thank you again Micheal!

How do we get a bitwise NOT in EEL? While working out my bit masks, ! ing my masks results in all 0's.
Some of the masks, binary print function, and test calls:
Code:
ZERO_MASK = $x00;
FULL_MASK = $~32;

Q_NUMBER_MASK = $xFFF00000; 
COLOR_MASK = $x000FF000; 

function printAsBinary(memSlot) (

	MSB_MASK = $x80000000;
	
	loop(32,
		memSlot & MSB_MASK ? printf("1") : printf("0");
		MSB_MASK = MSB_MASK >> 1;
	);
	printf( " \n");
);

printAsBinary(Q_NUMBER_MASK);
printAsBinary(!Q_NUMBER_MASK);
printAsBinary(COLOR_MASK);
printAsBinary(!COLOR_MASK);
Results:
Code:
11111111111100000000000000000000 
00000000000000000000000000000000 
00000000000011111111000000000000 
00000000000000000000000000000000
Any tips on what I'm missing?
James Slanger is offline   Reply With Quote
Old 06-22-2018, 02:38 PM   #8
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default

XOR'ing with FULL_MASK works, but is this the best way to invert a mask in EEL?
James Slanger is offline   Reply With Quote
Old 06-26-2018, 08:10 AM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,922
Default

For 32 bit operations you have the standard C operators.

If you want to use more bits, you need to do + and - with constants that you previously defined. This might be rater tricky.

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 06-27-2018, 12:32 PM   #10
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default

Quote:
Originally Posted by mschnell View Post
For 32 bit operations you have the standard C operators.
But not all the C operators correct? Shouldn't ~ do a bit-wise NOT then?
inverted = ~COLOR_MASK; // generates a syntax error

-Jim

EDIT: Still wrapping my brain around what is available via C vs EEL2 in OSCii-bot. My understanding is that everything is either a double-float or string. Yet match() includes format specifiers for unsigned, etc? Can I cast variables to unsigned?

Last edited by James Slanger; 06-27-2018 at 12:40 PM. Reason: Added questions about my continuing confusion.
James Slanger is offline   Reply With Quote
Old 06-27-2018, 02:30 PM   #11
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,922
Default

c = a ~ b; and c ~= b; do compile.

In format type functions the float values are internally converted to integers etc if the specifier requests this.

(Same happens for array indexes, of course.)

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 06-27-2018, 04:40 PM   #12
James Slanger
Human being with feelings
 
Join Date: Feb 2018
Posts: 24
Default

But just to confirm: there is no unary bitwise NOT operator in EEL?
James Slanger is offline   Reply With Quote
Old 06-27-2018, 09:28 PM   #13
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 5,922
Default

Seems like being forgotten. Seemingly you need to do $xFFFFFFFF ~ a instead. Maybe do a not() function

(...or implement it, as OSCII-Bot is open source )

Anyway, you should use constants for the positive and negative masks, constructed in @init.

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 06-27-2018 at 11:44 PM.
mschnell is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.