Writing (or coding) waveshapes

Discussion forum for G-Force users

Moderators: BTT, andy55, b.dwall, juxtiphi

Post Reply
bnh
Posts: 59
Joined: Fri Jan 19, 2007 7:11 pm

Post by bnh »

jerohm wrote:This is a modified version of an example above... It relies on the ACTUAL underlying vector nature of the implementation... so you won't find any documentation (other than 'VectorC.h').
Evem without the documentation, I for one enjoy tearing into jerhom's configs wihout a chance of understanding the new expressions, e.g. vectorLR, col, vrap.

This particular config fits into both the WaveShape and Particle categories.

I found the movement caused by the fft expression extremely smooth in jerhom's config., and after breaking up the symetry (just a personal habit of mine), I was able to create some dancing, abstract lines. In these samples I'm using only the"Chill" Sound Generator, but "High Energy" also works fine.

Image In the first example, I generated only one figure without any FlowField just to watch the flow of the lines. The .mov file at http://www.bnh.net/gforce/array1.mov shows that at mid point I added the Particle version of the same WaveShape as a kind of "shadow" to join the WaveShape and complicate the movement.

Image In the second example, I wrapped a little FlowField (Gravity Ball) around the single WaveShape. The .mov can be seen here: http://www.bnh.net/gforce/array2.mov


Image In the third example, I generated a second identical WaveShape, moved it to the left of the screen where I added BASSS response to make it move along the X axis. This gives the illusion that both figures are "dancing", while only the left figure is actually moving laterally.

Here's the .mov of the third config. http://www.bnh.net/gforce/array4.mov

Thanks jerohm for the config.

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Post by jerohm »

Warning THIS Post is purely empirical based, and may be WRONG or subject to modification without notice.
Any corrections cheerfully accepted.


G-Force seems to be built incorporating the (Codeplay?) VectorC engine. Since the Flowfields and Waveshapes are text files, they are interpreted and pre-compiled into some intermediary code prior to execution, rather than directly into machine code (like an .exe application would be).
Therefore GF 'may' only support a subset of VectorC's complete functionality. And more importantly, the GF 'language' may, or may not, translate 1:1 to VectorC syntax.

If you follow the waveshape construction thread, you will notice until recently I never mentioned the vector nature of GF implementation. The explanations I gave, could be successfully followed and implemented, but were not exactly correct. It wasn't until I studied 'Gold\Sparks.txt' that I discovered how much MORE of a part the VectorC engine played and was implemented. For example, I never realized that 'A' and 'B' variables were implemented and USEABLE as vectors. 'C' Variables association with 's' made more sense of its vector identity... confused yet?

Even though the vectors 'can' be multi-dimensional, lets concentrate on 'N x 1'. That is, you can view a vector as an array of values. In general (but not always),
'Stps' a.k.a. 'NUM_S_STEPS' a.k.a. 'NUM_SAMPLE_BINS' define the number of elements (but NOT their values).

There are only two available functions that can 'explicitly' initialize a vector:

// Returns a N x 1 vector with each element set to inValue.
float vector( int N, float inValue );

// Returns a N x 1 vector going from inLeft to inRight (inclusive).
float vectorLR( int N, float inLeft, float inRight );

// Returns the number of columns in the specified value
int cols( float inValue );

>> I THINK 'cols(s)' SHOULD ALWAYS be equal to 'NUM_S_STEPS'


You can define a vector where all the elements have the SAME value OR one that has equally distributed elemental values between two inclusive limits.
So what does this MEAN???

A0="5" would be FUNCTIONALLY equivalent to:
A0="vector(NUM_S_STEPS, 5)" // Normally YOU would NOT want to be this Verbose (or do this)!

On the other hand, we KNOW that 'A' variables only gets evaluated ONCE at the beginning of the scripts execution and is SHARED among NUM="Whatever" invocations.

A0="vectorLR(cols(s), 0, NUM_S_STEPS-1)" would result in:
A0="{0, 1, 2, ..., NUM_S_STEPS-1}" // This IS ALSO valid Syntax!

AND

A1="A0+1" would result in:
A1="{1, 2, 3, ..., NUM_S_STEPS}" // Make sense????

Or trickier, I use "sign(1-rnd(2))" to generate random +/-1

A0="sign(1-rnd(vector(Num, 2))" would result in:
A0 containing 'Num' +/-1 elements that can be accessed by:

"col(A0, Id)" // where Id could be replaced by any value [0 .. Num-1]

CAUTION, If you try doing math on vectors with different number of elements, you will probably NOT get the result you are expecting

If you notice, the VectorC(.h) documentation talk of 'vector()' and 'vectorLR()' in terms of 'N x 1', which "I" take to mean 'N' number, of 1 column rows. Yet I use 'col()' to access the elements. Does this seem transposed to anyone else? When trying to figure out how to retain elemental values in 'B' variables across frames, this caused me a great deal of confusion... hence, as previously surmized, logical mapping within G-Force may NOT necessarily follow. My attempts to make use of 'subset()' have been less than successful. This is an admission that I have more to learn (not a BAD admission, for most everyone... ALWAYS!).

With the use of the native VectorC functions, you CAN basically eliminate the need for 'C' variables altogether (for the most part anyway). Their use imposes another level of abstraction, that has few examples, but DOES provide a means of accomplishing things that can't(?) be accomplished in any other way... other times however, just an alternative syntax. I wrestle with the quandary if this somewhat flies in the face of Andy's original intentions, and I shouldn't depend that said constructs will neccessarily continue to be supported.




( more to follow... )

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Possible modification to: E R Triangle Warp (particle)

Post by jerohm »

(^^ read the Post Subject, do'h! ^^ :P )

Find "E R Triangle Warp.txt" and edit ONLY the 5 original lines with My suggested replacements (only if you WANT, of course!) ... UNDERSTAND, that the OTHER ORIGINAL lines, that are NOT part of the alternate modification Set... remain AS IS/UNTOUCHED!

Code: Select all

// CircWarp(Andy O'Meara) begot Triangle Warp(Erlend Robaye)
//   begot StarWarp(JRM)... (50% of the time anyway!  ;0)


// REPLACE the Original Lines with these:

Stps="4 + 7*pos(sign(1-rnd(2)))"

A0="(Num_S_Steps == 11)"

A3="(1- A0 * (.615 * ( vectorLR(Num_S_Steps, 0, Num_S_Steps-1) % 2))) 
    * { cos( vectorLR(Num_S_Steps, -Pi, Pi) ) 
      , sin( vectorLR(Num_S_Steps, -Pi, Pi) ) }"

C0="B4 * row(A3, 0)"
C1="B4 * row(A3, 1)"

You need to edit(replace actually) a total of 5 lines... the rest remain as is!

these changes were made easy to slip in and preserve Erlend's original intentions (but only half of the time 8) ) ... not necessarily how I would do it otherwise, but the original config is so teriffic, I didn't want to mess with it too much ...

"the hallmark of brilliance, is directly proportional to the ease of mutability"
...but that is (only?) MY opinion of course!
:wink:
Last edited by jerohm on Mon Dec 20, 2010 8:31 pm, edited 2 times in total.

User avatar
JayPro
Posts: 738
Joined: Sat May 01, 2004 10:51 pm
Location: Huntington Station, Long Island, New York

Post by JayPro »

I'm thoroughly confused.......

Ostensibly I'm to replace code in ER's Warp configs with this...(?)

TriangleWarp has no C vars, tho. ANd one of the B vars you propose to replace contains an apparently necessary t function call-up.

I (tried to) read your post before this; but it just threw me off all the more.

:?:


Regards;

Easily Flusterable
"God is syntax."

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Possible modification to: E R Triangle Warp

Post by jerohm »

Houston, we have a problem :P !

Find "E R Triangle Warp.txt" and edit ONLY the 5 original lines with My suggested replacements ... UNDERSTAND, that the OTHER ORIGINAL lines, that are NOT part of the alternate modification Set...
remain AS IS/UNTOUCHED!

For example(s) the original code:

Code: Select all

Stps="4" 
gets replaced by:

Code: Select all

Stps="4 + 7*pos(sign(1-rnd(2)))"

AND

Code: Select all

A0="t"     					// Record start time
gets replaced by:

Code: Select all

A0="(Num_S_Steps == 11)"
You need to edit three more lines... A total of 5 lines get editted/replaced ... the rest remain as is! This make MORE sense??? I guess I wasn't cut out to be a teacher
:P

( gfclean.pl would have given you some insight about the orignal code. :wink: ... but don't get fooled by 'B0' ... IT is necessary!! :oops: )

If I made this TOO easy, all you would do is cut and paste ... and how much good would THAT be ??

User avatar
JayPro
Posts: 738
Joined: Sat May 01, 2004 10:51 pm
Location: Huntington Station, Long Island, New York

Post by JayPro »

Not your fault...I was just not paying attention to the fact that my text editor wasn't scrolled all the way down to show the C vars.
"God is syntax."

User avatar
BTT
Administrator
Posts: 2169
Joined: Sun Jun 20, 2010 9:34 pm
Location: United Kingdom

Post by BTT »

Hello All

Well, I always liked the Particle E R Triangle Warp however, now that it has received the 'jerohm' treatment it is awesome.

By the way jerohm, I didn't have any problem understanding the instructions in your original post.


Seasons Greetings

BTT

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

VectorC.h:: dot() ... and more!

Post by jerohm »

I will leave it as an exercise for those who are interested to determine WHY each IS True, but rest assure, they are ... :wink:

Code: Select all

// Refer to VectorC.h :: dot()
//
A3="{ 3, 4 }"
A4="{ 5, 5 }"

  (dot(A3) == 25)    // This one Surprised me ... (squaring occurs)
  (dot(A3,A4) == 35)
  (dot(A3,1) == 3)
  (dot(A3,2) == 6)
  (dot(A3,{1,1}) == 7)
  (dot(A3,{0,1}) == 4)

A5="{ .75, .24, .01 }"

  (dot(A5) == .6202)
  (dot(A5,vector(cols(A5),1)) == 1)

The above was tested on my old 32bit machine, and I have discovered certain nuances on the i7/64bit when comparing to Zero... For example, I can't assume (BASS == 0), (s == 0) or (s == 1) under all circimstances... so if there is some degree of error when testing for equality, don't blame me ... ASSUME the above is ABSOLUTE TRUTH.

Code: Select all

/* Vector Concatenation Example - jrm
    (informational Only - 'cause its is really boring)
*/
Aspc=1
ConB=1
Num=1

Stps=8	// or 10 for alternate A2 line

A0="{ { 1, 0,  9 }
    , { 3, 0, 11 }
    , { 5, 0, 13 }
    , { 7, 0, 15 }
}"

A1="transpose( subrange( A0,   0,  0,   0, -1 ))"    //        { {1},  {3},  {5},  {7} }
A2="transpose( subrange( A0,  -1,  0,  -1, -1 ))"    // or A2="{ {9}, {11}, {13}, {15}, {17}, {19}}"

A3="vectorLR(Num_S_Steps, 0, Num_S_Steps-1)"
//
// A4="select&#40;&#40;A3 <= 3&#41;		// Stps=8 Only!
//    , map1D&#40;A1, A3/3, 0&#41;
//    , map1D&#40;A2, &#40;A3-4&#41;/3, 0&#41;&#41;"

// Generalized Solution&#58;
//  &#40; this is somewhat hideous &#40;ya think?!&#41;, but informative and 'may' prove useful ... or not ... ;0&#41;
//
A4="select&#40;&#40; s <= &#40;&#40;cols&#40;A1&#41;-1&#41;/&#40;Num_S_Steps-1&#41;&#41;&#41;
   , map1D&#40; A1, &#40;&#40;Num_S_Steps-1&#41;/&#40;cols&#40;A1&#41;-1&#41;&#41;* s, 0&#41;
   , map1D&#40; A2, &#40;&#40;Num_S_Steps-1&#41;/&#40;cols&#40;A2&#41;-1&#41;&#41;*&#40;s-&#40;cols&#40;A1&#41;/&#40;Num_S_Steps-1&#41;&#41;&#41;, 0&#41;&#41;"


X0="A4/10"
Y0="&#123;.25, 0, .25, 0, .25, 0, .25, 0, .25, 0  &#125;"

Pen=1
Lwdt=5

Meta="reactive=3 detail=3 density=3 morphable=5"
Vers=400
2011Jan01
Somebody might have caught the above line:

Code: Select all

A2="transpose&#40; subrange&#40; A0,  -1,  0,  -1, -1 &#41;&#41;"    // or A2="&#123; &#123;9&#125;, &#123;11&#125;, &#123;13&#125;, &#123;15&#125;, &#123;17&#125;, &#123;19&#125;&#125;"
and said: "Hey, why wouldn't the alternate line in the comment need to be transposed too???"
... and I would have said: "Damn you are good, my Bad!"
As it turns out 'map1D()' possesses still other characteristics that I have yet to fully grasp... So it WILL still work, BUT the line as I originally intended, should be:

Code: Select all

A2="transpose&#40; subrange&#40; A0,  -1,  0,  -1, -1 &#41;&#41;"    // or A2="&#123; 9, 11, 13, 15, 17, 19&#125;"
and I can hear "Moron, you still didn't transpose it" ... and I would sigh, and say "THAT is something I wanted you to figure out on your own" :wink:

So what is it this good for :roll: ??

Code: Select all

/* BASS/2 Recorder, Example - jrm
    &#40;stack operations&#41;
    Flowfield&#58; Gravity Ball or the likes is nice

    *** Informative Use Only ***
*/
Aspc=0
ConB=1
Num=1

// 'Push' on to end
//
B0="select&#40;&#40;s < 1&#41;
    , map1D&#40; subrange&#40;B0, 1, 0, -1, 0&#41;, &#40;&#40;Num_S_Steps-1&#41;/&#40;Num_S_Steps-2&#41;&#41;* s, 0 &#41;
    , &#40;Bass/2&#41;&#41;"

// 'Unshift' &#40;prepend&#41; to beginning
//
B1="select&#40;&#40;s != 0&#41;
    , map1D&#40; B1, s-&#40;1/&#40;Num_S_Steps-1&#41;&#41;, 0 &#41;
    , &#40;Bass/2&#41;&#41;"


X0="&#40;s*2&#41;-1"
Y0="-&#40;B0-.9&#41;"

X1="&#40;s*2&#41;-1"
Y1="&#40;B1-.9&#41;"

Pen=1
Lwdt=1

Meta="reactive=3 detail=3 density=3 morphable=5"
Vers=400
and still more...

Code: Select all

// just for fun & play
// &#40; http&#58;//programmedlessons.org/VectorLessons/vectorIndex.html#01 &#41;
//
// remember ... modify 'til ya break it

Aspc=1
ConB=1
Num=4	// Set to 1

Stps=5	// "NUM_SAMPLE_BINS"	// NUM_S_STEPS



A0="-&#40; transpose&#40; &#123; &#123;-1, 1&#125;
                  , &#123; 1, 1&#125;
                  , &#123; 1, 2&#125;
                  , &#123;-1, 2&#125;
                  , &#123;-1, 1&#125; &#125;/&#123;2,1&#125; - &#123;0, 1.5&#125; &#41; &#41;"	// Must wrap to A0&#91;row0&#93;

// 14Jan11
// Now that I gave you a little time to THINK about it ...
//  why don't you try instead&#58;
//   A0=".707 * &#123; cos&#40;&#40;Pi/4&#41;+2*Pi*s&#41;
//              , sin&#40;&#40;Pi/4&#41;+2*Pi*s&#41; &#125;"
//
// situation &#40;can, usually will&#41; dictate&#91;s&#93; syntax


B0="t+&#40;Id*Pi/Num&#41;"
B1="1+&#40;cos&#40;Pi/2+B0&#41;+1&#41;/4"
B2="1+&#40;sin&#40;B0&#41;+1&#41;/4"
B3="row&#40;A0, 1&#41; * cos&#40;B0&#41;"

X0="row&#40;A0, 0&#41; * &#123;B1,B1,B2,B2,B1&#125;"
Y0="B3"

LWdt="1"
Pen="1-&#40;Id/Num&#41;"

Meta="reactive=4 detail=4 density=4 morphable=4"
Vers=400

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Spinning Plane.txt, alternate version (Waveshape invocation)

Post by jerohm »

Replace (only if ya wanna... do'h!) original lines with these. As a particle, things should remain as always ... With these, it can exist as a Waveshape also. I always develop with Flowfields: '(Empty)' ... so YOU may feel this is TOO busy... and you may be right. It is what it is ...
j

Code: Select all

C9="C8 + A3"   // final z

C10=" min&#40; 10, 2.7 / &#40; C9 - A3 + 1.7 &#41; + .3  &#41;"
C11="select&#40;dt, 0, C10*fft&#40;s&#41;/4&#41;"

C12="C7 + C11"  // final y
// Perform perspective transformation
X0=" A3 * A4 *  C5 / C9"
Y0=" A3 * A4 * C12 / C9"


LWdt="C10"
Pen="1-C11"   // NEW line
Meta="reactive=3 detail=4 density=3 morphable=3"
another possible variation to the above modification might be

Code: Select all

A10="sin&#40;vectorLR&#40;Num_S_Steps, 0, Pi*A0&#41;&#41;"       // Replace Original

C11="select&#40;dt, 0, atan&#40;fft&#40;s/2&#41;&#41;/2&#41; * A10"      // Substitute Above
Pen="1-abs&#40;C11&#41;"                                 // Substitute Above

The idea has merit; I don't know if I really like the effect or not. Feel free to make it more appealing.

2011Jan17
fft(x), x wraps 1->0 ... Soooo (I think) timeshifting the wave is probably more appealing. I KNOW it CAN be busy depending on the perspective angle and Flowfield, but (I think) it is still worthwhile 8) .

Code: Select all

C11="select&#40;dt, 0, atan&#40;fft&#40;&#40;t/8&#41;+&#40;s/2&#41;&#41;&#41;/2&#41; * A10"
enjoy... or Not
j

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

nothing revolutionary ...

Post by jerohm »

... and certainly nothing that hasn't been previously discussed, but a good example in a manageable size bite. Yesterday I wrote a ridiculously complicated version that did the same thing. This is the result of a little more straight forward thinking. There is probably more going on than may be first apparent, UNLESS YOU have really been following along.
The (Particle) effect isn't all that special, but take note of the rounded corners. That was the challenge I was working against.

Code: Select all

/* Lil' Boxes
	2011Mar07 JRM - Creation
	2011Mar08 JRM - reWrite
*/
Aspc=0
ConB=1
Num=10

// Stps="NUM_S_STEPS"	// NUM_S_STEPS
// FNUM="Num"		// NUM_FFT_BINS

A0="vectorLR&#40;Num, 0, Num-1&#41;"

A1="cos&#40;vectorLR&#40;NUM_S_STEPS, 0, 2*Pi&#41;&#41;"
A2="sin&#40;vectorLR&#40;NUM_S_STEPS, 0, 2*Pi&#41;&#41;"

B0="wrap&#40;&#40;t/8&#41; + &#40;Id/Num&#41;&#41;"
B1="min&#40;B0, col&#40;B2, Id&#41;&#41; + .000375"

A3="sign&#40;A1&#41;"
A4="sign&#40;A2&#41;"

X0="A1 * B1 + A3 * B0"	// X
Y0="A2 * B1 + A4 * B0"	// Y

B2="select&#40;&#40;A0 != Id&#41;, B2, B1&#41;"

Pen="1-&#40;Id/Num&#41;+&#40;B0/Num&#41;"

// LWdt="1"
Meta="reactive=1 detail=3 density=4 morphable=2"
Vers=400
enjoy (humor me) or ignore

j

User avatar
BTT
Administrator
Posts: 2169
Joined: Sun Jun 20, 2010 9:34 pm
Location: United Kingdom

Post by BTT »

Hello All

Have just been reading this thread again, still does not make any sense to me but, I got to wondering what ever happened to bnh who to me appeared to be a promising contributor of WaveShapes for G-Force?

Seems like a wasted talent.


Regards BTT

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Post by jerohm »

"..\G-Force\WaveShapes\JRM\(N) Color Organ.txt" :

Code: Select all

/* Color Organ - jrm
   Written using Standalone, but some attempts to compensate for WinAmp levels,
     BUT fft&#40;&#41; spectrums are totally different and WinAmp run may be a bit frenetic.
   18Apr slight tune for WinAmp &#40;better?&#41;
   
   Probably the best locking down&#58;
     Flowfield&#58; "&#40;Empty&#41;"
     ColorMap&#58;  "The Haight"
     Particles Shuffle&#58; ON &#40;Maybe?&#41;
     Images Shuffle&#58; OFF &#40;Probably?&#41;

   This looks best BIG and viewed at a distance
   &#40;IMHO&#41;
*/
Num=40

Aspc=0
ConB=0
Stps="15"

A0="1-s"

B0="-1 + &#40;2*&#40;Id+1&#41;&#41;/&#40;Num+1&#41;"
B1="&#40;Id/Num + s/Num&#41;"


B2="1/&#40;2*Num&#41; * 5 * fft&#40;B1+t&#41;"
B3="&#40;&#40;B3*59&#41; + clamp&#40;&#40;24-3*B6&#41;*dot&#40;mag&#40;s&#41;&#41;&#41;&#41;/60"
B4="&#40;B4*99 + B6 * log10&#40;1 + BASS&#41;&#41;/100"
B5="&#40;1+2*B4&#41;"

B6="min&#40;2, B6 + sign&#40;1.3-B5&#41;/10&#41;"	// Normalize&#40;?&#41; Reactivity

C0="B0* &#40;&#40;1-abs&#40;B0&#41;*sin&#40;s*Pi&#41;/50&#41; + B4&#41; + sign&#40;B0&#41;* B2"
C1="&#40;2-cos&#40;B0*Pi/2&#41;&#41;*&#40;s-.5&#41;"

X0="C0"
Y0="B5*C1"

Lwdt="B3 * &#40;5-2.5*hypot&#40;C0,C1&#41;&#41;"
Pen="wrap&#40;1-abs&#40;B0&#41;+5*&#40;fft&#40;s&#41;+fft&#40;A0&#41;&#41;&#41;"

Meta="reactive=5 detail=3 density=4 morphable=4"
Vers=400
[Win7] "C:\Users\Your Account\AppData\Roaming\SoundSpectrum\G-Force\Scripts\Key A.txt" :

Code: Select all

0&#58;00

// WaveShape "&#40;N&#41; Color Organ.txt"
//

SetWaveShape&#40; "&#40;N&#41; Color Organ", WAVESHAPE_QUICK_MORPH &#41;;

SetFlowField&#40; "&#40;Empty&#41;", 0 &#41;;    // DOESN'T ALWAYS Work!!
SetColorMap&#40; "The Haight", COLORMAP_QUICK_MORPH &#41;;
SetSlideShow&#40; CONFIG_WAVESHAPE | CONFIG_COLORMAP | CONFIG_FLOWFIELD | CONFIG_UNION, false &#41;;

SetSlideShow&#40; CONFIG_PARTICLE, true &#41;;
SetSlideShow&#40; CONFIG_SPRITE, false &#41;;
Execute (this is new to 4.2 I think) (fixed :oops: ):

Code: Select all

Shift-R A
Scripts SHOULD be able to be a shuffled slideshow (, but not today :? )

carman200l's romps (My YouTube experiments)
(and generally not a bad way for email contact ... :wink: )
Last edited by jerohm on Mon Apr 18, 2011 9:09 am, edited 7 times in total.

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Controlled Reactivity

Post by jerohm »

Code: Select all

/* Study in controlled reactivity jrm 23Apr2011

  *** THIS is NOT a Config intended to be slideshowed. *** It is meant to be an aid in designing controlled
	reactivity across a wide range of music types and players &#40;and be APPLIED in true Config design&#41;.
	
	Run locked down as the &#40;sole&#41; WaveShape with FlowField&#58; "&#40;Empty&#41;".  Subject it to all sorts of audio
	input content to understand the resulting reactivity.

	This is "AN EXAMPLE" and not to imply the best, or only solution. Tune to YOUR particular needs...
	Probably best with Standalone &#40;WinAmp acts funny when you hit the Stop button&#41;

	&#40; You will most likely won't appreciate this until AFTER you bang your head up against the wall a while ;0&#41;
*/
Num=1
Aspc=0
ConB=1
FNum=1				// Actually THIS Doesn't Work AT ALL! unless set in the preference file, which is an UNACCEPTABLE solution
					   // I was EXPECTING a single averaged value &#58;0&#40;

A0=".75*&#40;&#40;2*s&#41;-1&#41;"		// ".75 * vectorLR&#40;Num_S_Steps, -1, 1&#41;" , happy?

B0="&#40;1-B1&#41;*atan&#40;Bass+5*&#40;1-B1&#41;*fft&#40;0&#41;&#41;/&#40;Pi/2&#41;"	// Instantaneous &#40;Frame&#41; Sample

A1="12"				// Damping Factor
B1="&#40;&#40;B1*&#40;A1-1&#41;&#41;+B0&#41;/A1"	// Damping Function&#40;&#41;
B2="B2+B1"			// Run Rate

B3="&#40;&#40;B3*&#40;A1-1&#41;&#41;+2*Bass&#41;/A1"	// Damped Bass*2


X0="A0"
Y0="&#40;B1&#41;/2*sin&#40;Pi*&#40;1+B3&#41;*A0+B2+t&#41;
    * atan&#40;2*sin&#40;s*Pi&#41;&#41;"		// Display Fuction


Lwdt=1
Pen=1

Meta="reactive=5 detail=3 density=3"
Vers=400

/***************/

jerohm
Senior Member
Posts: 421
Joined: Fri Jan 09, 2009 5:19 pm

Post by jerohm »

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 &#40;syntax&#41;
   Proof of concept - NOT a &#40;great anyway&#41; Waveshape
*/
Aspc=1
ConB=1
Num=8

// Stps="NUM_S_STEPS"	// NUM_S_STEPS
// FNUM="Num"		// NUM_FFT_BINS

A0="vectorLR&#40;Num, 0, Num-1&#41;"
A1="2*Pi*s"


B0="col&#40;row&#40;B6, 0&#41;, Id&#41;"				// radius defined???
B1="&#40;B0 != 0&#41; && &#40;col&#40;row&#40;B6, 3&#41;, Id&#41; > -&#40;1+B0&#41;&#41;"

B2="select&#40;B1, col&#40;row&#40;B6, 0&#41;, Id&#41;    , .1+rnd&#40;.5&#41;&#41;"	   // radius
B3="select&#40;B1, col&#40;row&#40;B6, 1&#41;, Id&#41;    , .005+rnd&#40;.01&#41;&#41;"	//  descent rate
B4="select&#40;B1, col&#40;row&#40;B6, 2&#41;, Id&#41;    ,  1-rnd&#40;2&#41;&#41;"	    //  X
B5="select&#40;B1, col&#40;row&#40;B6, 3&#41;, Id&#41;-B3 ,  1+B2&#41;"		     //  Y

X0="B2*sin&#40;A1&#41; + B4 * &#40;X_EXTENTS/Y_EXTENTS&#41; + .075*sin&#40;t+Id&#41;"
Y0="B2*cos&#40;A1&#41; + B5"

B6="&#123; select&#40;Id != A0, row&#40;B6, 0&#41;, B2&#41;
    , select&#40;Id != A0, row&#40;B6, 1&#41;, B3&#41;
    , select&#40;Id != A0, row&#40;B6, 2&#41;, B4&#41;
    , select&#40;Id != A0, row&#40;B6, 3&#41;, B5&#41;
    &#125;"						// 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="&#40;B0&#41; && &#40;col&#40;row&#40;B5, 2&#41;, Id&#41; > -&#40;1+B0&#41;&#41;"
try it, you WON'T like it :( ! [Although this exemplifies complete laziness on my part, it really should have worked :wink: ]

:idea: If you really want to challenge yourself, change all my:

Code: Select all

col&#40;row&#40;B6, r&#41;, Id&#41;
to their equivalent:

Code: Select all

subrange&#40; float inValue, int inCol1, int inRow1, int inCol2, int inRow2 &#41;;
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 :cry:

If you want to see what I was attempting, this code WORKS:

Code: Select all

/* Writing Multi-dimensional vectors &#40;syntax&#41;
*/
Aspc=1
ConB=1
Num=8

// Stps="NUM_S_STEPS"   // NUM_S_STEPS
// FNUM="Num"           // NUM_FFT_BINS

A0="vectorLR&#40;Num, 0, Num-1&#41;"
A1="2*Pi*s"

B0="row&#40;B7, Id&#41;"        // All Variables for task&#40;Id&#41;
                        // radius defined???

B1="&#40;col&#40;B0, 0&#41; != 0&#41; && &#40;col&#40;B0, 3&#41; > -&#40;1+col&#40;B0, 0&#41;&#41;&#41;"

B2="select&#40;B1, col&#40;B0, 0&#41;    , .1+rnd&#40;.5&#41;&#41;"     // radius
B3="select&#40;B1, col&#40;B0, 1&#41;    , .005+rnd&#40;.01&#41;&#41;"  //  descent rate
B4="select&#40;B1, col&#40;B0, 2&#41;    ,  1-rnd&#40;2&#41;&#41;"      //  X
B5="select&#40;B1, col&#40;B0, 3&#41;-B3 ,  1+B2&#41;"          //  Y

X0="B2*sin&#40;A1&#41; + B4 * &#40;X_EXTENTS/Y_EXTENTS&#41; + .075*sin&#40;t+Id&#41;"
Y0="B2*cos&#40;A1&#41; + B5"

// float subrange&#40; float inValue, int inCol1, int inRow1, int inCol2, int inRow2 &#41;; 

B6="&#123; select&#40;Id != A0, row&#40;B6, 0&#41;, B2&#41;
    , select&#40;Id != A0, row&#40;B6, 1&#41;, B3&#41;
    , select&#40;Id != A0, row&#40;B6, 2&#41;, B4&#41;
    , select&#40;Id != A0, row&#40;B6, 3&#41;, B5&#41;
    &#125;"

B7="transpose&#40;B6&#41;"


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.

:idea: Ideally (and logically) I would have thought that B6 could have been defined:

Code: Select all

B6="select&#40;Id != A0, &#123;&#123;B2, B3, B4, B5&#125;&#125;, B6&#41;"
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&#40;Num, 0, Num-1&#41;"
A1="2*Pi*s"

B0="row&#40;B10, Id&#41;"        // All Variables for task&#40;Id&#41;
                        // radius defined???

B1="&#40;col&#40;B0, 0&#41; != 0&#41; && &#40;col&#40;B0, 3&#41; > -&#40;1+col&#40;B0, 0&#41;&#41;&#41;"

B2="select&#40;B1, col&#40;B0, 0&#41;   , .1+rnd&#40;.5&#41;&#41;"     // radius
B3="select&#40;B1, col&#40;B0, 1&#41;   , .005+rnd&#40;.01&#41;&#41;"  //  descent rate
B4="select&#40;B1, col&#40;B0, 2&#41;   ,  1-rnd&#40;2&#41;&#41;"      //  X
B5="select&#40;B1, col&#40;B0, 3&#41;-B3,  1+B2&#41;"          //  Y
B6="select&#40;B1, col&#40;B0, 4&#41;   ,  0&#41;"             //  reactivity

B7="&#40;B6*15 + &#40;1+atan&#40;&#40;1.5-B2&#41;*fft&#40;Id/Num&#41;&#41;&#41;&#41;/16"
B8="B2 * max&#40;B7, max&#40;B2, B6-.00005&#41;&#41;"          // tame things a bit

X0="B8*sin&#40;A1&#41; + B4 * &#40;X_EXTENTS/Y_EXTENTS&#41; + .075*sin&#40;t+Id&#41;"
Y0="B8*cos&#40;A1&#41; + B5"

// float subrange&#40; float inValue, int inCol1, int inRow1, int inCol2, int inRow2 &#41;; 

/**/
B9="&#123; select&#40;Id != A0, row&#40;B9, 0&#41;, B2&#41;
    , select&#40;Id != A0, row&#40;B9, 1&#41;, B3&#41;
    , select&#40;Id != A0, row&#40;B9, 2&#41;, B4&#41;
    , select&#40;Id != A0, row&#40;B9, 3&#41;, B5&#41;
    , select&#40;Id != A0, row&#40;B9, 4&#41;, B7&#41;
    &#125;"
B10="transpose&#40;B9&#41;"

LWdt=".85"
Pen=1
Meta="reactive=3 detail=3 density=4 morphable=3"
Vers=400
Please refer to Fri Oct 19, 2012 update...
Last edited by jerohm on Fri Oct 19, 2012 8:35 am, edited 1 time in total.

User avatar
BTT
Administrator
Posts: 2169
Joined: Sun Jun 20, 2010 9:34 pm
Location: United Kingdom

Post by BTT »

Hello Jerohm

Just wanted to say that your latest version of "Bubbles" with gentle reactivity has put your creation right up there with the best.

I recommend everyone should Copy & Paste this into their WaveShape folder.

Well done and thank you Jerohm.


Regards BTT

Post Reply