diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-03-02 14:40:00 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-03-02 16:48:09 +0000 |
| commit | 4ebb6f4408600f3c0f2a745b7ed0ba951bf521b3 (patch) | |
| tree | cdf0953fdee07a6c83c510470a7b8ab8d832d25d /lib/midi/init.moon | |
| parent | update lib.math and lib.logic to new op interface (diff) | |
| download | alive-4ebb6f4408600f3c0f2a745b7ed0ba951bf521b3.tar.gz alive-4ebb6f4408600f3c0f2a745b7ed0ba951bf521b3.zip | |
lift remaining libs to new op interface
Diffstat (limited to 'lib/midi/init.moon')
| -rw-r--r-- | lib/midi/init.moon | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/midi/init.moon b/lib/midi/init.moon index 3bfba48..daf0088 100644 --- a/lib/midi/init.moon +++ b/lib/midi/init.moon @@ -8,14 +8,14 @@ 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: IOInput port note: ValueInput note chan: ValueInput chan or Value.num -1 tick: => - { port, note, chan } = @inputs + { :port, :note, :chan } = @inputs if note\dirty! or chan\dirty! @out\set false @@ -28,6 +28,32 @@ class gate extends Op elseif msg.status == 'note-off' @out\set false +class trig extends Op + @doc: "(midi/trig port note [chan]) - gate from note-on and note-off messages" + + new: => + super 'bang', false + + setup: (inputs) => + { port, note, chan } = match 'midi/port num num?', inputs + super + port: IOInput port + note: ValueInput note + chan: ValueInput chan or Value.num -1 + + tick: => + { :port, :note, :chan } = @inputs + + if note\dirty! or chan\dirty! + @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 + + class cc extends Op @doc: "(midi/cc port cc [chan [range]]) - MIDI CC to number @@ -36,6 +62,7 @@ range can be one of: - 'uni' [ 0 - 1[ (default) - 'bip' [-1 - 1[ - 'rad' [ 0 - tau[ +- 'deg' [ 0 - 360[ - (num) [ 0 - num[" new: => @@ -66,5 +93,6 @@ range can be one of: :output :inout :gate + :trig :cc } |
