Commit f5e6c93b authored by Carlo Laurenzi's avatar Carlo Laurenzi

Major Update of the SpatLib, update v11.2 : xRandomSpace and x_RandomSpace_i...

Major Update of the SpatLib, update v11.2 : xRandomSpace and x_RandomSpace_i don't exist anymore, in favor of a more generical and all purpose ::RandSpace process.
parent f99f1e9a
......@@ -132,10 +132,10 @@ if (@is_undef($source))
$delay
$last_goto := {
;print igoto $prefix_namespace $idnum
;print FlyingEngine destination $destination duration ($dur - 0.01) coordinate $coordinates destination ($initlevels($destination))
print FlyingEngine delay $delay destination $dest duration ($dur - 0.01) coordinate $coordinates destination ($initlevels($dest))
curve FlyingEngine3
@tempo := ($mm == false ? $RT_TEMPO : $mm)
@Grain := 0.05s,
@Grain := 0.05s
@exclusive
@Action :=
{
......@@ -222,7 +222,7 @@ if (@is_undef($source))
abort $last_action
;;; Generate first randoms:
@local $grainsize, $randomconfig
$grainsize := @random() * ($grainrange_max - $grainrange_min) + $grainrange_min
$grainsize := (@random() * ($grainrange_max - $grainrange_min) + $grainrange_min )
print DEBUG RAN SPACE: Initial grain set to ($grainsize)
$last_action := {
......@@ -240,6 +240,7 @@ if (@is_undef($source))
;print "DEBUG: random space with grain" ($grainsize) "on" ($randomconfig)
; Generate a new period just before this loop is finishes! Looks like a harakiri!
$grainsize := @random() * ($grainrange_max - $grainrange_min) + $grainrange_min
print "grainsize" $grainsize
}
}
......@@ -250,7 +251,7 @@ if (@is_undef($source))
@fun_def @Space($src, $dest, $dur = 0., $stay = 0., $itp = "sine_in_out", $mm = false)
{
print "=================>>>>>>>>>>>>>> goto: " ($source[$src-1])
;print "=================>>>>>>>>>>>>>> goto: " ($source[$src-1]) $src $dest $mm
$source[$src-1].goto($dest, $dur, $stay, $itp, $mm)
}
......@@ -301,6 +302,7 @@ if (@is_undef($source))
; 3rd arg: duration (float, or time in seconds or milliseconds: ex. 3.0 or 3.0s or 3.0ms) to get to the
; new spatial position
; 4th arg: interpolation type (default: "sine_in_out")
/*
@macro_def Space_i($snum, $scfg, $sdur, $sitp)
{
; If $sdur is 0.0, use SPACE_JUMP method instead (conceptually cleaner)
......@@ -316,7 +318,7 @@ if (@is_undef($source))
;print Initial coordinate of source ($snum) is ($source[$snum].$coordinates)
;$sdur print Final coordinate of source ($snum) is ($source[$snum].$coordinates)
}
*/
;_________________________________________________________________________________________
......@@ -374,6 +376,8 @@ REMARK: spatial tables SHOULD have at lease TWO elements
@proc_def ::Traj_reader($src, $Traj, $dur, $itp)
{
@local $durscaler, $currtime
@local $stay := 0
@local $mm := $RT_TEMPO
if (($Traj.last()[0] == 0) && @size($Traj) > 1)
{ print "ERROR trajectory zero duration in multiple step trajectory" }
......@@ -381,7 +385,7 @@ REMARK: spatial tables SHOULD have at lease TWO elements
; if size Traj is only 1 step, do just a jump with @Space_i
if ( @size($Traj) == 1 )
{
@Space_i ($src, ($Traj[0, 1]), $dur, $itp)
@Space ($src, ($Traj[0, 1]), $dur, $stay, $itp, $mm)
; print @size($Traj) "if"
}
else
......@@ -391,7 +395,7 @@ REMARK: spatial tables SHOULD have at lease TWO elements
; Initialization: place the first element at the right time
; If the first time is not 0.0, reach the configuration after this time
@Space_i ($src, ($Traj[0, 1]), $currtime, $itp)
@Space ($src, ($Traj[0, 1]), $currtime, $stay, $itp, $mm)
; Generate a set of parallel processes, starting from the table's second point
forall $i in (@size ($Traj) - 1)
......@@ -403,7 +407,8 @@ REMARK: spatial tables SHOULD have at lease TWO elements
$cfg := $Traj[$cur, 1]
$scaled_dur := $t1 - $t0
$t0 @Space_i($src, $cfg, $scaled_dur, $itp)
$t0 @Space($src, $cfg, $scaled_dur, $stay, $itp, $mm)
print $t0 $src $cfg $durscaler $scaled_dur $itp
}
; print "else"
......@@ -413,6 +418,8 @@ REMARK: spatial tables SHOULD have at lease TWO elements
@proc_def ::Traj_reader_s($src, $Traj, $dur, $itp, $stay_percent)
{
@local $durscaler, $currtime
@local $stay := $stay_percent
@local $mm := $RT_TEMPO
if (($Traj.last()[0] == 0) && @size($Traj) > 1)
{ print "ERROR trajectory zero duration in multiple step trajectory" }
......@@ -420,7 +427,7 @@ REMARK: spatial tables SHOULD have at lease TWO elements
; if size Traj is only 1 step, do just a jump with @Space_i
if ( @size($Traj) == 1 )
{
@Space_i ($src, ($Traj[0, 1]), $dur, $itp)
@Space($src, ($Traj[0, 1]), $dur, $stay, $itp, $mm)
; print @size($Traj) "if"
}
else
......@@ -430,7 +437,7 @@ REMARK: spatial tables SHOULD have at lease TWO elements
; Initialization: place the first element at the right time
; If the first time is not 0.0, reach the configuration after this time
@Space_i ($src, ($Traj[0, 1]), $currtime, $itp)
@Space($src, ($Traj[0, 1]), $currtime, $stay, $itp, $mm)
; Generate a set of parallel processes, starting from the table's second point
forall $i in (@size ($Traj) - 1)
......@@ -442,7 +449,8 @@ REMARK: spatial tables SHOULD have at lease TWO elements
$cfg := $Traj[$cur, 1]
$scaled_dur := $t1 - $t0
$t0 @Space_is($src, $cfg, $scaled_dur, $itp, $stay_percent)
$t0 @Space($src, $cfg, $scaled_dur, $stay, $itp, $mm)
print $t0 $src $cfg $scaled_dur $stay_percent $itp
}
; print "else"
}
......@@ -530,6 +538,9 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
@proc_def ::Traj_looper($src, $Traj, $dur, $itp, $period, $totaldur)
; @abort := { print "abort ::trajLooper" }
{
@local $stay := 0
@local $mm := $RT_TEMPO
if ($dur > $period)
{
print "duration " $dur " is greater than period " $period
......@@ -541,7 +552,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
$currtime := ($Traj[0, 0]) * $durscaler
;$source[$src].igoto($stype,$sdur,$itp)
@Space_i ($src, ($Traj[0, 1]), $currtime, $itp)
@Space ($src, ($Traj[0, 1]), $currtime, $stay, $itp, $mm)
;print $durscaler $currtime
;print space $src ($Traj[0, 1]) $currtime $itp
......@@ -562,7 +573,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
}
{
;print "traj_loop_inside from " $NOW " with duration " ($interdate[$j % @size($interdate)]) "-- Space_i"
@Space_i($src, ($Traj[$j % @size($Traj), 1]), ($interdate[$j % @size($interdate)]), $itp)
@Space($src, ($Traj[$j % @size($Traj), 1]), ($interdate[$j % @size($interdate)]), $stay, $itp, $mm)
$j := $j + 1
}}
$totaldur abort $MYSELF
......@@ -570,6 +581,8 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
@proc_def ::Traj_looper_t($src, $Traj, $dur, $itp, $period, $tempolocal) ; takes a tempo argument
{
@local $stay := 0
if ($dur > $period)
{
print "duration " $dur " is greater than period " $period
......@@ -581,7 +594,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
$currtime := ($Traj[0, 0]) * $durscaler
;$source[$src].igoto($stype,$sdur,$itp)
@Space_i_t($src, ($Traj[0, 1]), $currtime, $itp, $tempolocal)
@Space($src, ($Traj[0, 1]), $currtime, $stay, $itp, $tempolocal)
;print $durscaler $currtime
;print space $src ($Traj[0, 1]) $currtime $itp
......@@ -604,13 +617,16 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
}
{
;print "traj_loop_inside from " $NOW " with duration " ($interdate[$j % @size($interdate)]) "-- Space_i"
@Space_i_t($src, ($Traj[$j % @size($Traj), 1]), ($interdate[$j % @size($interdate)]), $itp, $tempolocal)
@Space($src, ($Traj[$j % @size($Traj), 1]), ($interdate[$j % @size($interdate)]), $stay, $itp, $tempolocal)
$j := $j + 1
}}
}
@proc_def ::Traj_looper_rt($src, $Traj, $dur, $itp, $period) ; takes a tempo argument
{
@local $stay := 0
@local $mm := $RT_TEMPO
if ($dur > $period)
{
print "duration " $dur " is greater than period " $period
......@@ -622,7 +638,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
$currtime := ($Traj[0, 0]) * $durscaler
;$source[$src].igoto($stype,$sdur,$itp)
@Space_i_rt($src, ($Traj[0, 1]), $currtime, $itp)
@Space($src, ($Traj[0, 1]), $currtime, $stay, $itp, $mm)
;print $durscaler $currtime
;print space $src ($Traj[0, 1]) $currtime $itp
......@@ -645,7 +661,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
}
{
;print "traj_loop_inside from " $NOW " with duration " ($interdate[$j % @size($interdate)]) "-- Space_i"
@Space_i_rt($src, ($Traj[$j % @size($Traj), 1]), ($interdate[$j % @size($interdate)]), $itp)
@Space($src, ($Traj[$j % @size($Traj), 1]), ($interdate[$j % @size($interdate)]), $stay, $itp, $mm)
$j := $j + 1
}}
}
......@@ -673,7 +689,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
@local $currtime := ($Traj[0, 0]) * $durscaler
;$source[$src].igoto($stype,$sdur,$itp)
@Space_i ($src, ($Traj[0, 1]), $currtime, $itp)
@Space ($src, ($Traj[0, 1]), $currtime, $stay_percent, $itp, $tempol)
;print $durscaler $currtime
;print space $src ($Traj[0, 1]) $currtime $itp
......@@ -709,7 +725,7 @@ $T001 := [[0, "a" ], [4, "b"], [7, "c"], [10, "d"]]
; print "traj_loop_inside from " $NOW " with duration " $real_dur "-- Space_i"
$stay
@Space_i($src, ($Traj[$i, 1]), $real_dur, $itp)
@Space($src, ($Traj[$i, 1]), $real_dur, $stay, $itp, $current_tempo)
$j += 1
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment