Gen Codebox Compiling Inputs Incorrectly

Emmett Palaima's icon

Emmett Palaima

9月 12 2024 | 12:00 午前

Hi I am trying to use gen codebox to do custom programatic routing of 64 inputs to 64 outputs.

When I save and my gen codebox compiles, in1 doesn't work, and the code output shows that in1 is being treated as a value of zero by the compiler:

In my gen codebox I have the line:

out10 = in1;

This shows up as the following in the code tab:

expr_2 = 0; 
... 
out10 = expr_2;

This seems like my code is simply being compiled wrong. How do I fix this?

All the other input -> output routing is working as expected.

Here is my complete gen patcher:

Max Patch
Copy patch and select New From Clipboard in Max.

Here is my full gen codebox code:


out10 = in1;
out11 = in2;
out19 = in3;
out18 = in4;
out17 = in5;
out9 = in6;
out1 = in7;
out2 = in8;
out3 = in9;
out4 = in10;
out12 = in11;
out20 = in12;
out28 = in13;
out27 = in14;
out26 = in15;
out25 = in16;

out15 = in17;
out14 = in18;
out22 = in19;
out23 = in20;
out24 = in21;
out16 = in22;
out8 = in23;
out7 = in24;
out6 = in25;
out5 = in26;
out13 = in27;
out21 = in28;
out29 = in29;
out30 = in30;
out31 = in31;
out32 = in32;

out50 = in33;
out51 = in34;
out43 = in35;
out42 = in36;
out41 = in37;
out49 = in38;
out57 = in39;
out58 = in40;
out59 = in41;
out60 = in42;
out52 = in43;
out44 = in44;
out36 = in45;
out35 = in46;
out34 = in47;
out33 = in48;

out55 = in49;
out54 = in50;
out46 = in51;
out47 = in52;
out48 = in53;
out56 = in54;
out64 = in55;
out63 = in56;
out62 = in57;
out61 = in58;
out53 = in59;
out45 = in60;
out37 = in61;
out38 = in62;
out39 = in63;
out40 = in64;

Here is the compiled output in the code view tab:

expr_1 = 0;
expr_2 = 0;
expr_3 = in2;
expr_4 = in3;
expr_5 = in4;
expr_6 = in5;
expr_7 = in6;
expr_8 = in7;
expr_9 = in8;
expr_10 = in9;
expr_11 = in10;
expr_12 = in11;
expr_13 = in12;
expr_14 = in13;
expr_15 = in14;
expr_16 = in15;
expr_17 = in16;
expr_18 = in17;
expr_19 = in18;
expr_20 = in19;
expr_21 = in20;
expr_22 = in21;
expr_23 = in22;
expr_24 = in23;
expr_25 = in24;
expr_26 = in25;
expr_27 = in26;
expr_28 = in27;
expr_29 = in28;
expr_30 = in29;
expr_31 = in30;
expr_32 = in31;
expr_33 = in32;
expr_34 = in33;
expr_35 = in34;
expr_36 = in35;
expr_37 = in36;
expr_38 = in37;
expr_39 = in38;
expr_40 = in39;
expr_41 = in40;
expr_42 = in41;
expr_43 = in42;
expr_44 = in43;
expr_45 = in44;
expr_46 = in45;
expr_47 = in46;
expr_48 = in47;
expr_49 = in48;
expr_50 = in49;
expr_51 = in50;
expr_52 = in51;
expr_53 = in52;
expr_54 = in53;
expr_55 = in54;
expr_56 = in55;
expr_57 = in56;
expr_58 = in57;
expr_59 = in58;
expr_60 = in59;
expr_61 = in60;
expr_62 = in61;
expr_63 = in62;
expr_64 = in63;
expr_65 = in64;
out15 = expr_18;
out23 = expr_21;
out18 = expr_5;
out19 = expr_4;
out30 = expr_31;
out28 = expr_14;
out20 = expr_13;
out10 = expr_2;
out55 = expr_50;
out11 = expr_3;
out60 = expr_43;
out61 = expr_59;
out41 = expr_38;
out56 = expr_55;
out42 = expr_37;
out32 = expr_33;
out22 = expr_20;
out54 = expr_51;
out53 = expr_60;
out59 = expr_42;
out31 = expr_32;
out40 = expr_65;
out58 = expr_41;
out43 = expr_36;
out3 = expr_10;
out13 = expr_28;
out1 = expr_8;
out38 = expr_63;
out14 = expr_19;
out51 = expr_35;
out62 = expr_58;
out4 = expr_11;
out44 = expr_45;
out39 = expr_64;
out63 = expr_57;
out35 = expr_47;
out50 = expr_34;
out9 = expr_7;
out24 = expr_22;
out57 = expr_40;
out34 = expr_48;
out33 = expr_49;
out17 = expr_6;
out7 = expr_25;
out6 = expr_26;
out21 = expr_29;
out2 = expr_9;
out64 = expr_56;
out37 = expr_62;
out36 = expr_46;
out5 = expr_27;
out49 = expr_39;
out8 = expr_24;
out12 = expr_12;
out48 = expr_54;
out52 = expr_44;
out16 = expr_23;
out29 = expr_30;
out25 = expr_17;
out45 = expr_61;
out26 = expr_16;
out27 = expr_15;
out46 = expr_52;
out47 = expr_53;
👽'tW∆s ∆lienz👽's icon

👽'tW∆s ∆lienz👽

9月 12 2024 | 6:16 午後

this looks similar to an issue i found here:

...but i wonder if yours might work better if you assign inlets first to intermediate variables, and then assign the outlets to those variables... try rearranging your code to something like this:

one = in1;
two = in2;
three = in3;   //etc...

out1 = two;
out2 = three;
out3 = one;   // or however you'd like, etc...

Graham Wakefield's icon

Graham Wakefield

9月 13 2024 | 4:52 午後

OK grab the codebox and drag it to the side, it will reveal everything :-)

Happy to find that this wasn't a bug