06-19-2018, 12:10 PM | #1 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
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.
|
06-19-2018, 12:33 PM | #2 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
|
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 |
06-19-2018, 02:02 PM | #3 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
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? |
06-19-2018, 03:10 PM | #4 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
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. |
06-19-2018, 09:23 PM | #5 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
|
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 Last edited by mschnell; 06-19-2018 at 09:28 PM. |
06-20-2018, 07:23 AM | #6 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
|
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; ); -Michael |
06-22-2018, 02:17 PM | #7 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
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); Code:
11111111111100000000000000000000 00000000000000000000000000000000 00000000000011111111000000000000 00000000000000000000000000000000 |
06-22-2018, 02:38 PM | #8 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
XOR'ing with FULL_MASK works, but is this the best way to invert a mask in EEL?
|
06-26-2018, 08:10 AM | #9 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
|
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 |
06-27-2018, 12:32 PM | #10 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
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. |
06-27-2018, 02:30 PM | #11 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
|
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 |
06-27-2018, 04:40 PM | #12 |
Human being with feelings
Join Date: Feb 2018
Posts: 24
|
But just to confirm: there is no unary bitwise NOT operator in EEL?
|
06-27-2018, 09:28 PM | #13 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,785
|
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 Last edited by mschnell; 06-27-2018 at 11:44 PM. |
Thread Tools | |
Display Modes | |
|
|