git.s-ol.nu alive / 66410c4
rename Op:update_out → setup_out s-ol 1 year, 7 months ago
10 changed file(s) with 25 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
168168 -- @tparam string metatype (one of `!` or `~`)
169169 -- @tparam Type type
170170 -- @tparam[opt] any val initial value
171 update_out: (metatype, type, val) =>
171 setup_out: (metatype, type, val) =>
172172 if @out and @out.type == type and @out.metatype == metatype
173173 -- we can just keep it. do nothing.
174174 return false
5656 if typ
5757 assert (ancestor typ.__class) == Type, "not a type: #{typ}"
5858 metatype = if trigger then '!' else '~'
59 @update_out metatype, typ
59 @setup_out metatype, typ
6060
6161 map_fn = if trigger then hot_if_trigger trigger else Input.hot
6262 inputs = deep_map args, map_fn
338338 { i, values } = pattern\match inputs
339339
340340 val1 = values[1]
341 @update_out val1.result.metatype, val1.result.type
341 @setup_out val1.result.metatype, val1.result.type
342342
343343 if i\type! == T.bang
344344 @state or= 1
461461
462462 super event: Input.hot event
463463
464 @update_out '~', event\type!, initial.result!
464 @setup_out '~', event\type!, initial.result!
465465
466466 tick: => @out\set @inputs.event!
467467
491491 else
492492 super sig: Input.hot sig_
493493
494 @update_out '!', @inputs.sig\type!
494 @setup_out '!', @inputs.sig\type!
495495
496496 tick: (setup) =>
497497 return if setup
513513 setup: (inputs) =>
514514 values = pattern\match inputs
515515 super [Input.hot v for v in *values]
516 @update_out '!', @inputs[1]\type!
516 @setup_out '!', @inputs[1]\type!
517517
518518 tick: =>
519519 for input in *@inputs
8181 error "no port opened"
8282
8383 @state or= {}
84 @update_out '~', type
84 @setup_out '~', type
8585
8686 tick: =>
8787 if @inputs.inp and @inputs.inp\dirty!
357357 press: Input.hot COPILOT.mouse_presses
358358 release: Input.hot COPILOT.mouse_releases
359359
360 @update_out '~', T.bool, false
360 @setup_out '~', T.bool, false
361361
362362 poll: =>
363363
465465 press: Input.hot COPILOT.key_presses
466466 release: Input.hot COPILOT.key_releases
467467
468 @update_out '~', T.bool, false
468 @setup_out '~', T.bool, false
469469
470470 poll: =>
471471
1818
1919 internal: Input.hot T.bool\mk_sig!
2020
21 @update_out '~', T.bool
21 @setup_out '~', T.bool
2222
2323 poll: =>
2424 { :port, :note, :chan, :internal } = @inputs
106106 internal: Input.hot T.bang\mk_evt!
107107
108108 @state or= 0
109 @update_out '~', T.num, apply_range @inputs.range, @state
109 @setup_out '~', T.num, apply_range @inputs.range, @state
110110
111111 poll: =>
112112 { :port, :cc, :chan, :internal } = @inputs
1717 host: Input.hot host
1818 port: Input.hot port
1919
20 @update_out '~', T['udp/socket']
20 @setup_out '~', T['udp/socket']
2121
2222 tick: =>
2323 { :host, :port } = @unwrap_all!
3535 value: class extends Op
3636 new: (...) =>
3737 super ...
38 @update_out '~', T.num
38 @setup_out '~', T.num
3939 @state or @gen!
4040
4141 gen: => @state = math.random!
6363 value: class extends Op
6464 new: (...) =>
6565 super ...
66 @update_out '~', typ
66 @setup_out '~', typ
6767 @state or @gen!
6868
6969 gen: => @state = for i=1,n do math.random!
1919 fps: Input.cold fps or Constant.num 60
2020 io: Input.hot T.bang\mk_evt!
2121
22 @update_out '!', T.clock
22 @setup_out '!', T.clock
2323
2424 poll: =>
2525 time = monotime!
6464 clock: Input.hot clock or scope\get '*clock*'
6565 scale: Input.cold scale
6666
67 @update_out '!', T.clock
67 @setup_out '!', T.clock
6868
6969 tick: =>
7070 { :clock, :scale } = @unwrap_all!
9595 wave: Input.hot wave or default_wave
9696
9797 @state or= 0
98 @update_out '~', T.num
98 @setup_out '~', T.num
9999
100100 tau = math.pi * 2
101101 tick: =>
135135 max: max and Input.cold max
136136
137137 @state or= 0
138 @update_out '~', T.num, 0
138 @setup_out '~', T.num, 0
139139
140140 tick: =>
141141 { :clock, :period, :max } = @unwrap_all!
174174 period: Input.cold period
175175
176176 @state or= { phase: 0, count: 0 }
177 @update_out '~', T.num, @state.count
177 @setup_out '~', T.num, @state.count
178178
179179 tick: =>
180180 { :clock, :period } = @unwrap_all!
210210 evt: Input.cold evt or T.bang\mk_const true
211211
212212 @state or= 0
213 @update_out '!', @inputs.evt\type!
213 @setup_out '!', @inputs.evt\type!
214214
215215 tick: =>
216216 { :clock, :period, :evt } = @unwrap_all!
256256 clock: Input.hot clock or scope\get '*clock*'
257257 steps: [inputify step for step in *steps]
258258
259 @update_out '!', steps[1].value\type!
259 @setup_out '!', steps[1].value\type!
260260
261261 tick: =>
262262 if tick = @inputs.clock!
342342 rate: Input.cold rate
343343 value: Input.cold value
344344
345 @update_out '~', T.num, @inputs.value!
345 @setup_out '~', T.num, @inputs.value!
346346
347347 tick: =>
348348 { :clock, :rate, :value } = @unwrap_all!
376376 evt: Input.hot evt
377377
378378 @state or= {}
379 if @update_out '!', @inputs.evt\type!
379 if @setup_out '!', @inputs.evt\type!
380380 @state = {}
381381
382382 tick: =>
2121 min: Input.cold min or Constant.num 0
2222 max: Input.cold max or Constant.num 1
2323
24 @update_out val.result.metatype, val\type!
24 @setup_out val.result.metatype, val\type!
2525
2626 tick: =>
2727 { :val, :min, :max } = @unwrap_all!
5757 val: Input.hot val
5858 max: Input.cold max or Constant.num 1
5959
60 @update_out val.result.metatype, val\type!
60 @setup_out val.result.metatype, val\type!
6161
6262 tick: =>
6363 { :val, :max } = @unwrap_all!