aboutsummaryrefslogtreecommitdiffstats
path: root/lib/midi/init.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-02 11:41:33 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-02 11:41:33 +0000
commit03853b35a473161f377fb74a05723cacc5cbf36b (patch)
tree2e3df044cc0ff3ed24a07d6b5ee31682f077e5fa /lib/midi/init.moon
parentnew op interface part one (diff)
downloadalive-03853b35a473161f377fb74a05723cacc5cbf36b.tar.gz
alive-03853b35a473161f377fb74a05723cacc5cbf36b.zip
IO system
Diffstat (limited to 'lib/midi/init.moon')
-rw-r--r--lib/midi/init.moon39
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/midi/init.moon b/lib/midi/init.moon
index 0cbe5e0..3bfba48 100644
--- a/lib/midi/init.moon
+++ b/lib/midi/init.moon
@@ -1,7 +1,5 @@
-import Value, Op from require 'core'
+import Value, Op, ValueInput, IOInput, match from require 'core'
import input, output, inout, apply_range from require 'lib.midi.core'
-import ValueInput, EventInput from require 'core.base'
-import match from require 'core.pattern'
class gate extends Op
@doc: "(midi/gate port note [chan]) - gate from note-on and note-off messages"
@@ -10,9 +8,9 @@ class gate extends Op
super 'bool', false
setup: (inputs) =>
- { port, note, chan } = match '=midi/port num num?', inputs
+ { :port, :note, :chan } = match 'midi/port num num?', inputs
super
- port: EventInput port.value!
+ port: IOInput port
note: ValueInput note
chan: ValueInput chan or Value.num -1
@@ -22,12 +20,13 @@ class gate extends Op
if note\dirty! or chan\dirty!
@out\set false
- for msg in port\receive!
- if msg.a == note! and (chan == -1 or msg.chan == chan!)
- if msg.status == 'note-on'
- @out\set true
- elseif msg.status == 'note-off'
- @out\set false
+ if port\dirty!
+ for msg in port!\receive!
+ if msg.a == note! and (chan! == -1 or msg.chan == chan!)
+ if msg.status == 'note-on'
+ @out\set true
+ elseif msg.status == 'note-off'
+ @out\set false
class cc extends Op
@doc: "(midi/cc port cc [chan [range]]) - MIDI CC to number
@@ -42,11 +41,10 @@ range can be one of:
new: =>
super 'num'
-
setup: (inputs) =>
- { port, cc, chan, range } = match '=midi/port num num? any?', inputs
+ { port, cc, chan, range } = match 'midi/port num num? any?', inputs
super
- port: EventInput port.value!
+ port: IOInput port
cc: ValueInput cc
chan: ValueInput chan or Value.num -1
range: ValueInput range or Value.str 'uni'
@@ -55,12 +53,13 @@ range can be one of:
@out\set apply_range @inputs.range, 0
tick: =>
- { port, cc, chan, range } = @inputs
- for msg in port\receive!
- if msg.status == 'control-change' and
- (chan == -1 or msg.chan == chan!) and
- msg.a == cc!
- @out\set apply_range range, msg.b
+ { :port, :cc, :chan, :range } = @inputs
+ if port\dirty!
+ for msg in port!\receive!
+ if msg.status == 'control-change' and
+ (chan! == -1 or msg.chan == chan!) and
+ msg.a == cc!
+ @out\set apply_range range, msg.b
{
:input