Please refer to Fri Oct 19, 2012 update...
There is absolutely NOTHING extraordinary about this code snippet EXCEPT for the length of time it took me to get it working, which is exactly WHY I am posting it. I started off writing a proof of concept piece for (writing) multi-dimensional vector syntax, which should have come off without a hitch... Instead, a logical expression syntax issue ran me in circles, until I finally started over and changed things one line at a time.
Code: Select all
/* Writing Multi-dimensional vectors (syntax)
Proof of concept - NOT a (great anyway) Waveshape
*/
Aspc=1
ConB=1
Num=8
// Stps="NUM_S_STEPS" // NUM_S_STEPS
// FNUM="Num" // NUM_FFT_BINS
A0="vectorLR(Num, 0, Num-1)"
A1="2*Pi*s"
B0="col(row(B6, 0), Id)" // radius defined???
B1="(B0 != 0) && (col(row(B6, 3), Id) > -(1+B0))"
B2="select(B1, col(row(B6, 0), Id) , .1+rnd(.5))" // radius
B3="select(B1, col(row(B6, 1), Id) , .005+rnd(.01))" // descent rate
B4="select(B1, col(row(B6, 2), Id) , 1-rnd(2))" // X
B5="select(B1, col(row(B6, 3), Id)-B3 , 1+B2)" // Y
X0="B2*sin(A1) + B4 * (X_EXTENTS/Y_EXTENTS) + .075*sin(t+Id)"
Y0="B2*cos(A1) + B5"
B6="{ select(Id != A0, row(B6, 0), B2)
, select(Id != A0, row(B6, 1), B3)
, select(Id != A0, row(B6, 2), B4)
, select(Id != A0, row(B6, 3), B5)
}" // Neatly Stored into B6
LWdt=".85"
Pen=1
Meta="reactive=5 detail=3 density=4 morphable=3"
Vers=400
( Is there anyway to get select() to deal with 'rows of columns' instead of just columns?? )
MY original
error was:
Code: Select all
B1="(B0) && (col(row(B5, 2), Id) > -(1+B0))"
try it, you WON'T like it
! [Although this exemplifies complete laziness on my part,
it really should have worked ]
If you
really want to challenge yourself, change all my:
Code: Select all
col(row(B6, r), Id)
to their equivalent:
Code: Select all
subrange( float inValue, int inCol1, int inRow1, int inCol2, int inRow2 );
calls (
It shouldn't be all that hard)
Why those... 'select()' statements work [the way they do] in the 'B6' assignment is really the (original) essence of the excerise. Grasping that, is truely the 'Ah Ha!' moment that I am not willing to rob you of! ... unless of course, you can enlighten me how to store things away in the form [row==Id, col=='elemental variable'] (i.e., utilizes the same amount of resources, but provides logically a more straight forward route to access), ... which is why I started this whole mess, to end up still unfulfilled
If you want to see what I was attempting, this code WORKS:
Code: Select all
/* Writing Multi-dimensional vectors (syntax)
*/
Aspc=1
ConB=1
Num=8
// Stps="NUM_S_STEPS" // NUM_S_STEPS
// FNUM="Num" // NUM_FFT_BINS
A0="vectorLR(Num, 0, Num-1)"
A1="2*Pi*s"
B0="row(B7, Id)" // All Variables for task(Id)
// radius defined???
B1="(col(B0, 0) != 0) && (col(B0, 3) > -(1+col(B0, 0)))"
B2="select(B1, col(B0, 0) , .1+rnd(.5))" // radius
B3="select(B1, col(B0, 1) , .005+rnd(.01))" // descent rate
B4="select(B1, col(B0, 2) , 1-rnd(2))" // X
B5="select(B1, col(B0, 3)-B3 , 1+B2)" // Y
X0="B2*sin(A1) + B4 * (X_EXTENTS/Y_EXTENTS) + .075*sin(t+Id)"
Y0="B2*cos(A1) + B5"
// float subrange( float inValue, int inCol1, int inRow1, int inCol2, int inRow2 );
B6="{ select(Id != A0, row(B6, 0), B2)
, select(Id != A0, row(B6, 1), B3)
, select(Id != A0, row(B6, 2), B4)
, select(Id != A0, row(B6, 3), B5)
}"
B7="transpose(B6)"
LWdt=".85"
Pen=1
Meta="reactive=5 detail=3 density=4 morphable=3"
Vers=400
Similar, but subtly elegant; I think it makes B1-B5 more straightforward/understandable, but the implementation syntax of B6 [& B7] is certainly
not as intuitive as I
would hope and should be able to be specified a little nicer.
Ideally (and logically) I would
have thought that B6
could have been defined:
Code: Select all
B6="select(Id != A0, {{B2, B3, B4, B5}}, B6)"
where the '{{ ... }}' construct defines the intended structure (of B6 in this case); '{ ... }' defines a single row of column(s), and '{{ ... }}' would imply multiple rows of column(s) [ I
didn't just
make up this syntax; if you manually set up a (multi-dimensional) vector, this is
how it is specified ] ... makes sense... right??
Single line of code and no need to transpose...
======================
Okay, I was
reminded "No reactivity!?!"
... well this was never intended to be a Waveshape, but has kind of evolved into something acceptable... so I have decided to accomodate. Here is a version with reactivity, albeit rather subtle...
Code: Select all
/* Bubbles - jrm
w/ gentle reactivity
*/
Aspc=1
ConB=1
Num=8
// Stps="NUM_S_STEPS" // NUM_S_STEPS
// FNUM="Num" // NUM_FFT_BINS
A0="vectorLR(Num, 0, Num-1)"
A1="2*Pi*s"
B0="row(B10, Id)" // All Variables for task(Id)
// radius defined???
B1="(col(B0, 0) != 0) && (col(B0, 3) > -(1+col(B0, 0)))"
B2="select(B1, col(B0, 0) , .1+rnd(.5))" // radius
B3="select(B1, col(B0, 1) , .005+rnd(.01))" // descent rate
B4="select(B1, col(B0, 2) , 1-rnd(2))" // X
B5="select(B1, col(B0, 3)-B3, 1+B2)" // Y
B6="select(B1, col(B0, 4) , 0)" // reactivity
B7="(B6*15 + (1+atan((1.5-B2)*fft(Id/Num))))/16"
B8="B2 * max(B7, max(B2, B6-.00005))" // tame things a bit
X0="B8*sin(A1) + B4 * (X_EXTENTS/Y_EXTENTS) + .075*sin(t+Id)"
Y0="B8*cos(A1) + B5"
// float subrange( float inValue, int inCol1, int inRow1, int inCol2, int inRow2 );
/**/
B9="{ select(Id != A0, row(B9, 0), B2)
, select(Id != A0, row(B9, 1), B3)
, select(Id != A0, row(B9, 2), B4)
, select(Id != A0, row(B9, 3), B5)
, select(Id != A0, row(B9, 4), B7)
}"
B10="transpose(B9)"
LWdt=".85"
Pen=1
Meta="reactive=3 detail=3 density=4 morphable=3"
Vers=400
Please refer to Fri Oct 19, 2012 update...