diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-02-03 19:26:51 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 9d8157e75ae706c757fc3f93912f1e1f6d2647b7 (patch) | |
| tree | dc797e1376a9a944992a1e53816fae199277334c | |
| parent | fix input caching/lazy ticking at evaltime (diff) | |
| download | alive-9d8157e75ae706c757fc3f93912f1e1f6d2647b7.tar.gz alive-9d8157e75ae706c757fc3f93912f1e1f6d2647b7.zip | |
lib: only reinitialize midi ports if necessary
| -rw-r--r-- | alv-lib/_midi.moon | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/alv-lib/_midi.moon b/alv-lib/_midi.moon index c456a01..7f99063 100644 --- a/alv-lib/_midi.moon +++ b/alv-lib/_midi.moon @@ -69,18 +69,36 @@ class OutPort class PortOp extends Op setup: (inputs) => super inputs - { :inp, :out } = @unwrap_all! - if inp and out - type = Struct in: T['midi/in'], out: T['midi/out'] - @out = type\mk_const { 'in': InPort(inp), out: OutPort(out) } + { :inp, :out } = @inputs + + type = if inp and out + Struct in: T['midi/in'], out: T['midi/out'] elseif inp - @out = T['midi/in']\mk_const InPort inp + T['midi/in'] elseif out - @out = T['midi/out']\mk_const OutPort out + T['midi/out'] else error "no port opened" + if not @out or @out.type != type + @out = type\mk_sig! + + @state or= {} + + tick: => + if @inputs.inp and @inputs.inp\dirty! + @state.inp = InPort @inputs.inp! + + if @inputs.out and @inputs.out\dirty! + @state.out = OutPort @inputs.out! + + { :inp, :out } = @state + @out\set if inp and out + { 'in': inp, :out } + else + inp or out + input = Constant.meta meta: name: 'input' |
