Discussion forum for G-Force users
	Moderators:  BTT , andy55 , b.dwall , juxtiphi 
			
		
		
			
				
																			
								jerohm 							 
						Senior Member 			
		Posts:  421  		Joined:  Fri Jan 09, 2009 5:19 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by jerohm   »  Wed Aug 29, 2018 8:58 am 
			
			
			
			
			I was bored and re-wrote ShohS's "noname4" (AKA Kana Kone) in a VectorC form.  IT IS IN NO WAY to imply ShohS's version isn't every bit as good... maybe even better, and SHOULD result in identical output.
It was ONLY an exercise in intellectual curiosity; for those stricken with such afflictions, it might prove useful...
Nice work ShohS!  
 
   
Code: Select all 
// noname4 By ShohS
Aspc=1 
stps="4000" 
Num="2 + round(rnd(4))" 
A0="2 * pi" 
A1=".3" 
A2="num*2" 
A3="{ sin( s * 6.28318530/A2)
    , cos( s * 6.28318530/A2)
    }"
//  A4="{ sin(-s * 6.28318530/A2 + A2 * pi)
//      , cos(-s * 6.28318530/A2 + A2 * pi)
//      }"                                             // Original Code
A4="{ sin(-s * 6.28318530/A2 )
    , cos(-s * 6.28318530/A2 )
    }"                                                 // Equivalent Code (JRM)
A5="{ sgn(cos(s*120/A2*pi))
    ,-sgn(cos(s*120/A2*pi))
    }"
B0="fft(s/num) * .3"
B1="A5 * B0 + .6" 
B2="A3 * row(B1, 0)"      // It is IMPORTANT to understand that A3 * B1 couldn't be used here
B3="A3 * row(B1, 1)" 
B4="A4 * row(B1, 0)" 
B5="A4 * row(B1, 1)" 
// A6="A0 * ( 1 + (vectorLR(NUM, 0, NUM-1) / NUM))"    // Original Code
A6="A0 * (vectorLR(NUM, 0, NUM-1) / NUM)"              // Equivalent Code (JRM)
B6="t * A1 + col(A6, ID)" 
X0="row(B2, 0) * cos( B6 ) + row(B2, 1) * sin( B6 )" 
Y0="row(B2, 0) * sin( B6 ) - row(B2, 1) * cos( B6 )" 
X1="row(B3, 0) * cos( B6 ) + row(B3, 1) * sin( B6 )" 
Y1="row(B3, 0) * sin( B6 ) - row(B3, 1) * cos( B6 )" 
X2="row(B4, 0) * cos( B6 ) + row(B4, 1) * sin( B6 )" 
Y2="row(B4, 0) * sin( B6 ) - row(B4, 1) * cos( B6 )" 
X3="row(B5, 0) * cos( B6 ) + row(B5, 1) * sin( B6 )" 
Y3="row(B5, 0) * sin( B6 ) - row(B5, 1) * cos( B6 )" 
ConB=1 
LWdt="1.5 + energy" 
Pen="1" 
Vers=540
 
 
I may  have leaped, before I looked... I think  everything was correct & in sync 
  
			
			
													
					Last edited by 
jerohm  on Mon Sep 03, 2018 3:21 am, edited 6 times in total.
									
 
			
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
								BTT 							 
						Administrator 			
		Posts:  2262  		Joined:  Sun Jun 20, 2010 9:34 pm 		
		
											Location:  United Kingdom 
							
						
		 
		
						
						 
													
							
						
									
						Post 
					 
								by BTT   »  Wed Aug 29, 2018 10:51 am 
			
			
			
			
			Hello All
Just so you can see the difference between the Shohs original and Jerhom's version.
Code: Select all 
// Kana Kone - WaveShape - Author ShohS
Aspc=1
stps="4000"
Num="2 + round(rnd(4))"
A0="2 * pi"
B0=".3"
B1="t * B0 + A0 + 2 * pi * ID / NUM"
B2="num*2"
C0="0.5 + .1 + sgn(cos(s*120/B2*pi)) * fft(s/num) * .3"
C1="0.5 + .1 + sgn(cos(s*120/B2*pi)) * fft(s/num) * -.3"
C2="s * 6.28318530/B2"
C3="-s * 6.28318530/B2 + B2 * pi"
C4="C0 * sin(C2)"
C5="C0 * cos(C2)"
C6="C1 * sin(C2)"
C7="C1 * cos(C2)"
C8="C0 * sin(C3)"
C9="C0 * cos(C3)"
C10="C1 * sin(C3)"
C11="C1 * cos(C3)"
X0="C4 * cos( B1 ) + C5 * sin( B1 )"
Y0="C4 * sin( B1 ) - C5 * cos( B1 )"
X1="C6 * cos( B1 ) + C7 * sin( B1 )"
Y1="C6 * sin( B1 ) - C7 * cos( B1 )"
X2="C8 * cos( B1 ) + C9 * sin( B1 )"
Y2="C8 * sin( B1 ) - C9 * cos( B1 )"
X3="C10 * cos( B1 ) + C11 * sin( B1 )"
Y3="C10 * sin( B1 ) - C11 * cos( B1 )"
ConB=1
LWdt="1.5 + energy"
Pen="1"
Vers=540  
			
			
									
									. 
Regards BTT 
 
ColorMap Creator for G-Force and Aeon --- SoundSpectrum Forum Administrator.
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
								DanPin 							 
									
		Posts:  161  		Joined:  Tue Mar 15, 2016 8:43 pm 		
		
											Location:  Los Angeles County, California 
							
						
		 
		
						
						 
													
							
						
									
						Post 
					 
								by DanPin   »  Thu Aug 30, 2018 10:38 pm 
			
			
			
			
			JRM, thanks for the rewrite, but the waveshape is rotating a bit too fast. I tried decreasing the value from .3 to .03 in A1, but this ends up with the same result. Can you identify which value is set for 't'?
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								jerohm 							 
						Senior Member 			
		Posts:  421  		Joined:  Fri Jan 09, 2009 5:19 pm 		
		
						
						
		 
		
						
						 
													
							
						
									
						Post 
					 
								by jerohm   »  Fri Aug 31, 2018 9:14 am 
			
			
			
			
			On the version I posted, spin timing is set using A1 and used in B6
Code: Select all 
A1=".3" 
 .
 .
 .
A6="A0 * ( 1 + (vectorLR(NUM, 0, NUM-1) / NUM))" 
B6="t * A1 + col(A6, ID)" 
Since .3 is a CONSTANT, I used an 'Avar'
I also calculated the other part of ShohS's equation ONCE (A6) for each thread, and reference the CORESPONDING CONSTANT values' array(col) position by ID
My code may
 look  less straight forward, but 
should  have a more efficient run time; I have a sick mind 
  
In ShohS's original version:
Code: Select all 
B0=".3" 
B1="t * B0 + A0 + 2 * pi * ID / NUM"
 
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								jerohm 							 
						Senior Member 			
		Posts:  421  		Joined:  Fri Jan 09, 2009 5:19 pm 		
		
						
						
		 
		
						
						 
													
							
						
									
						Post 
					 
								by jerohm   »  Mon Sep 03, 2018 9:20 am 
			
			
			
			
			If you have played along so far, you can use the fact that:
Code: Select all 
-sin(-x) == sin(x)
 cos(-x) == cos(x)
and reduce things even further.
If you think, "Hey!, you should also be able to reduce A5!!!"  Think again (hint: B1).
Code: Select all 
// noname4 By ShohS (optimized VectorC)
Aspc=1 
stps="4000" 
Num="2 + round(rnd(4))" 
A0="2 * pi" 
A1=".3" 
A2="s * Pi/Num" 
A3="sin(A2)"
A4="cos(A2)"
B0="fft(s/num) * .3"
A5="{ sgn(cos(60*A2))
    ,-sgn(cos(60*A2))
    }"
B1="A5 * B0 + .6"
B2="A3*B1"    // sin(A2) * B1
B3="A4*B1"    // cos(A2) * B1 
B4=""
B5=""
A6="A0 * (vectorLR(NUM, 0, NUM-1) / NUM)" 
B6="t * A1 + col(A6, ID)" 
X0=" row(B2, 0) * cos( B6 ) + row(B3, 0) * sin( B6 )" 
Y0=" row(B2, 0) * sin( B6 ) - row(B3, 0) * cos( B6 )" 
X1=" row(B2, 1) * cos( B6 ) + row(B3, 1) * sin( B6 )" 
Y1=" row(B2, 1) * sin( B6 ) - row(B3, 1) * cos( B6 )" 
X2="-row(B2, 0) * cos( B6 ) + row(B3, 0) * sin( B6 )" 
Y2="-row(B2, 0) * sin( B6 ) - row(B3, 0) * cos( B6 )" 
X3="-row(B2, 1) * cos( B6 ) + row(B3, 1) * sin( B6 )" 
Y3="-row(B2, 1) * sin( B6 ) - row(B3, 1) * cos( B6 )" 
ConB=1 
LWdt="1.5 + energy" 
Pen="1" 
Vers=540