diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-05-09 14:49:08 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:23:21 +0000 |
| commit | 61eb86951287667ca0ee305baa5c3cd6ad29ba36 (patch) | |
| tree | 7551d6b9c8af01c049adab0ee027dbad68f28808 /alv-lib/midi | |
| parent | more internal doc fixes (diff) | |
| download | alive-61eb86951287667ca0ee305baa5c3cd6ad29ba36.tar.gz alive-61eb86951287667ca0ee305baa5c3cd6ad29ba36.zip | |
add types.T, fix spec + docs
Diffstat (limited to 'alv-lib/midi')
| -rw-r--r-- | alv-lib/midi/core.moon | 14 | ||||
| -rw-r--r-- | alv-lib/midi/launchctl.moon | 22 |
2 files changed, 18 insertions, 18 deletions
diff --git a/alv-lib/midi/core.moon b/alv-lib/midi/core.moon index 3adc401..71d1e9f 100644 --- a/alv-lib/midi/core.moon +++ b/alv-lib/midi/core.moon @@ -1,4 +1,4 @@ -import ValueStream, IOStream, Op, Input, Error, val from require 'alv.base' +import Constant, IOStream, Op, Input, T, Error, val from require 'alv.base' import RtMidiIn, RtMidiOut, RtMidi from require 'luartmidi' bit = do @@ -31,7 +31,7 @@ find_port = (Klass, name) -> \openport id class MidiPort extends IOStream - new: => super 'midi/port' + new: => super T['midi/port'] setup: (inp, out) => @inp = inp and find_port RtMidiIn, inp @@ -63,7 +63,7 @@ class PortOp extends Op { :inp, :out } = @unwrap_all! @out\setup inp, out -input = ValueStream.meta +input = Constant.meta meta: name: 'input' summary: "Create a MIDI input port." @@ -74,7 +74,7 @@ input = ValueStream.meta name = val.str\match inputs super inp: Input.hot name -output = ValueStream.meta +output = Constant.meta meta: name: 'output' summary: "Create a MIDI output port." @@ -85,7 +85,7 @@ output = ValueStream.meta name = val.str\match inputs super out: Input.hot name -inout = ValueStream.meta +inout = Constant.meta meta: name: 'inout' summary: "Create a bidirectional MIDI port." @@ -99,7 +99,7 @@ inout = ValueStream.meta out: Input.hot out apply_range = (range, val) -> - if range\type! == 'str' + if range\type! == T.str switch range! when 'raw' then val when 'uni' then val / 128 @@ -108,7 +108,7 @@ apply_range = (range, val) -> when 'deg' then val / 128 * 360 else error Error 'argument', "unknown range '#{range!}'" - elseif range.type == 'num' + elseif range.type == T.num val / 128 * range! else error Error 'argument', "range has to be a string or number" diff --git a/alv-lib/midi/launchctl.moon b/alv-lib/midi/launchctl.moon index 90e8956..3f47a5d 100644 --- a/alv-lib/midi/launchctl.moon +++ b/alv-lib/midi/launchctl.moon @@ -1,10 +1,10 @@ -import ValueStream, EventStream, Op, Input, val, evt from require 'alv.base' +import Constant, Op, Input, T, val, evt from require 'alv.base' import apply_range, bit from require 'alv-lib.midi.core' import bor, lshift from bit color = (r, g) -> bit.bor 12, r, (bit.lshift g, 4) -cc_seq = ValueStream.meta +cc_seq = Constant.meta meta: name: 'cc-seq' summary: "MIDI CC-Sequencer." @@ -32,11 +32,11 @@ range can be one of: i: Input.hot i start: Input.hot start chan: Input.hot chan - steps: Input.hot steps or ValueStream.num 8 - range: Input.hot range or ValueStream.str 'uni' + steps: Input.hot steps or Constant.num 8 + range: Input.hot range or Constant.str 'uni' @state or= {} - @out or= ValueStream 'num', apply_range @inputs.range, 0 + @out or= T.num\mk_sig apply_range @inputs.range, 0 tick: => { :port, :i, :start, :chan, :steps, :range } = @inputs @@ -60,7 +60,7 @@ range can be one of: else @out\set apply_range range, @state[curr_i+1] -gate_seq = ValueStream.meta +gate_seq = Constant.meta meta: name: 'gate-seq' summary: "MIDI Gate-Sequencer." @@ -72,7 +72,7 @@ Send `true` or `false` for the `i`-th note-button (MIDI-notes starting from value: class extends Op pattern = -evt['midi/port'] + val.num + val.num + val.num + -val.num setup: (inputs, scope) => - @out or= ValueStream 'bool' + @out or= T.bool\mk_sig! @state or= {} { port, i, start, chan, steps } = pattern\match inputs @@ -81,7 +81,7 @@ Send `true` or `false` for the `i`-th note-button (MIDI-notes starting from i: Input.hot i start: Input.hot start chan: Input.hot chan - steps: Input.hot steps or ValueStream.num 8 + steps: Input.hot steps or Constant.num 8 light = (set, active) -> set = if set then 'S' else ' ' @@ -123,7 +123,7 @@ Send `true` or `false` for the `i`-th note-button (MIDI-notes starting from @out\set @state[curr_i+1] -trig_seq = ValueStream.meta +trig_seq = Constant.meta meta: name: 'trig-seq' summary: "MIDI Trigger-Sequencer." @@ -135,7 +135,7 @@ Send bangs for the `i`-th note-button (MIDI-notes starting from `start`). value: class extends Op pattern = -evt['midi/port'] + val.num + val.num + val.num + -val.num setup: (inputs, scope) => - @out or= EventStream 'bang' + @out or= T.bang\mk_evt! @state or= {} { port, i, start, chan, steps } = pattern\match inputs @@ -144,7 +144,7 @@ Send bangs for the `i`-th note-button (MIDI-notes starting from `start`). i: Input.hot i start: Input.hot start chan: Input.hot chan - steps: Input.hot steps or ValueStream.num 8 + steps: Input.hot steps or Constant.num 8 light = (set, active) -> set = if set then 'S' else ' ' |
