aboutsummaryrefslogtreecommitdiffstats
path: root/alv-lib/time.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-07-11 17:25:50 +0000
committers-ol <s-ol@users.noreply.github.com>2020-07-11 17:37:04 +0000
commitc6fa7aa7657647fffbbe8a0507e29bcd9a980dba (patch)
tree9b58942e0d5c2ad4be70fd7f628893e7f984dfc7 /alv-lib/time.moon
parentrename time/sequence to time/val-seq and add time/bang-seq (diff)
downloadalive-c6fa7aa7657647fffbbe8a0507e29bcd9a980dba.tar.gz
alive-c6fa7aa7657647fffbbe8a0507e29bcd9a980dba.zip
add vis field to Ops
Diffstat (limited to 'alv-lib/time.moon')
-rw-r--r--alv-lib/time.moon15
1 files changed, 11 insertions, 4 deletions
diff --git a/alv-lib/time.moon b/alv-lib/time.moon
index daa14ad..aeab467 100644
--- a/alv-lib/time.moon
+++ b/alv-lib/time.moon
@@ -110,6 +110,7 @@ lfo = Constant.meta
when 'saw' then @state % 1
when 'tri' then math.abs (2*@state % 2) - 1
else error Error 'argument', "unknown wave type '#{wave}'"
+ @vis.bar = @out!
ramp = Constant.meta
meta:
@@ -140,11 +141,12 @@ ramp = Constant.meta
{ :clock, :period, :max } = @unwrap_all!
max or= period
- @phase += clock.dt / period
- while @phase >= 1
- @phase -= 1
+ @state += clock.dt / period
+ while @state >= 1
+ @state -= 1
- @out\set @phase * max
+ @vis.bar = @state
+ @out\set @state * max
tick = Constant.meta
meta:
@@ -162,6 +164,7 @@ tick = Constant.meta
super ...
@state or= { phase: 0, count: 0 }
@out or= T.num\mk_sig @state.count
+ @vis.onchange = true
pattern = -evt.clock + sig.num
setup: (inputs, scope) =>
@@ -228,6 +231,7 @@ Emits `evt1`, `evt2`, … as events with delays `delay0`, `delay1`, … in betwe
new: (...) =>
super ...
@state or= { i: 1, t: 0 }
+ @vis.step = @state.i
pair = (sig! + sig.num)\named('value', 'delay')
pattern = -evt.clock + sig.num + pair*0
@@ -256,6 +260,7 @@ Emits `evt1`, `evt2`, … as events with delays `delay0`, `delay1`, … in betwe
if @state.t >= current.delay!
@state.t -= current.delay!
@state.i = 1 + (@state.i % #@inputs.steps)
+ @vis.step = @state.i
change = true
else
break
@@ -280,6 +285,7 @@ Emits `bang!`s with delays `delay0`, `delay1`, … in between.
super ...
@out = T.bang\mk_evt!
@state or= { i: 1, t: 0 }
+ @vis.step = @state.i
pattern = -evt.clock + sig.num*0
setup: (inputs, scope) =>
@@ -299,6 +305,7 @@ Emits `bang!`s with delays `delay0`, `delay1`, … in between.
if @state.t >= current
@state.t -= current
@state.i = 1 + (@state.i % #@inputs.steps)
+ @vis.step = @state.i
bang = true
else
break