aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-04-13 18:40:35 +0000
committers-ol <s-ol@users.noreply.github.com>2020-04-14 08:46:54 +0000
commit1a8debe87762072b3a63b769aa515ebf63b4c70d (patch)
tree33b42866307d11d2c0878b23e0ec0bb8925d3fcc /lib
parentspec base.match __tostring (diff)
downloadalive-1a8debe87762072b3a63b769aa515ebf63b4c70d.tar.gz
alive-1a8debe87762072b3a63b769aa515ebf63b4c70d.zip
move into proper Lua module (`alv`)
Diffstat (limited to 'lib')
-rw-r--r--lib/logic.moon2
-rw-r--r--lib/math.moon2
-rw-r--r--lib/midi.moon2
-rw-r--r--lib/midi/core.moon2
-rw-r--r--lib/midi/launchctl.moon2
-rw-r--r--lib/osc.moon2
-rw-r--r--lib/pilot.moon2
-rw-r--r--lib/random.moon2
-rw-r--r--lib/sc.moon41
-rw-r--r--lib/string.moon2
-rw-r--r--lib/time.moon2
-rw-r--r--lib/util.moon2
12 files changed, 51 insertions, 12 deletions
diff --git a/lib/logic.moon b/lib/logic.moon
index 27de579..62de1c1 100644
--- a/lib/logic.moon
+++ b/lib/logic.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, Input, Error, val from require 'core.base'
+import Op, ValueStream, Input, Error, val from require 'alv.base'
all_same = (first, list) ->
for v in *list
diff --git a/lib/math.moon b/lib/math.moon
index b2f4ce0..6f5f3fb 100644
--- a/lib/math.moon
+++ b/lib/math.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, Error, Input, val from require 'core.base'
+import Op, ValueStream, Error, Input, val from require 'alv.base'
unpack or= table.unpack
class ReduceOp extends Op
diff --git a/lib/midi.moon b/lib/midi.moon
index 2f3a109..e83b05d 100644
--- a/lib/midi.moon
+++ b/lib/midi.moon
@@ -1,4 +1,4 @@
-import ValueStream, EventStream, Op, Input, val, evt from require 'core.base'
+import ValueStream, EventStream, Op, Input, val, evt from require 'alv.base'
import input, output, inout, apply_range from require 'lib.midi.core'
gate = ValueStream.meta
diff --git a/lib/midi/core.moon b/lib/midi/core.moon
index e520bbf..ddb1e8a 100644
--- a/lib/midi/core.moon
+++ b/lib/midi/core.moon
@@ -1,4 +1,4 @@
-import ValueStream, IOStream, Op, Input, Error, val from require 'core.base'
+import ValueStream, IOStream, Op, Input, Error, val from require 'alv.base'
import RtMidiIn, RtMidiOut, RtMidi from require 'luartmidi'
bit = do
diff --git a/lib/midi/launchctl.moon b/lib/midi/launchctl.moon
index cbabe5a..42837f0 100644
--- a/lib/midi/launchctl.moon
+++ b/lib/midi/launchctl.moon
@@ -1,4 +1,4 @@
-import ValueStream, EventStream, Op, Input, val, evt from require 'core.base'
+import ValueStream, EventStream, Op, Input, val, evt from require 'alv.base'
import apply_range, bit from require 'lib.midi.core'
import bor, lshift from bit
diff --git a/lib/osc.moon b/lib/osc.moon
index 2819e97..b7e25e7 100644
--- a/lib/osc.moon
+++ b/lib/osc.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, Input, val, evt from require 'core.base'
+import Op, ValueStream, Input, val, evt from require 'alv.base'
import pack from require 'osc'
import dns, udp from require 'socket'
diff --git a/lib/pilot.moon b/lib/pilot.moon
index 00d2d3a..0d6eefb 100644
--- a/lib/pilot.moon
+++ b/lib/pilot.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, Input, val, evt from require 'core.base'
+import Op, ValueStream, Input, val, evt from require 'alv.base'
import udp from require 'socket'
local conn
diff --git a/lib/random.moon b/lib/random.moon
index 49da2b9..8c4d096 100644
--- a/lib/random.moon
+++ b/lib/random.moon
@@ -1,4 +1,4 @@
-import ValueStream, Error, Op, Input, val, evt from require 'core.base'
+import ValueStream, Error, Op, Input, val, evt from require 'alv.base'
apply_range = (range, val) ->
if range\type! == 'str'
diff --git a/lib/sc.moon b/lib/sc.moon
index c92d4f7..2857392 100644
--- a/lib/sc.moon
+++ b/lib/sc.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, Input, val, evt from require 'core.base'
+import Op, ValueStream, Input, val, evt from require 'alv.base'
import pack from require 'osc'
import dns, udp from require 'socket'
@@ -39,6 +39,45 @@ Plays the synth `synth` on the `udp/socket` `socket` whenever `trig` is live.
msg = pack '/s_new', synth, -1, 0, 1, unpack ctrls
socket\send msg
+play_ = ValueStream.meta
+ meta:
+ name: 'play!'
+ summary: 'Play a SuperCollider SynthDef on events.'
+ examples: { '(play [socket] synth [param evt/val…])' }
+ description: "
+Plays the synth `synth` on the `udp/socket` `socket` whenever any `evt` is live.
+
+- `socket` should be a `udp/socket` value. This argument can be omitted and the
+ value be passed as a dynamic definition in `*sock*` instead.
+- `synth` is the SC synthdef name. It should be a string-value.
+- `param` is the name of a synthdef parameter. It should be a string-value.
+- `val` and `evt` are the parameter values to send. They should be number
+ streams. Incoming events will cause a note to be played, while value changes
+ will not."
+ value: class extends Op
+ pattern = -val['udp/socket'] + val.str + (val.str + (val.num / evt.num))\rep 0
+ setup: (inputs, scope) =>
+ { socket, synth, trig, ctrls } = pattern\match inputs
+
+ flat = {}
+ for { key, value } in *ctrls
+ table.insert flat, Input.cold key
+ table.insert flat, if value\metatype! == 'event'
+ Input.hot value
+ else
+ Input.cold value
+
+ super
+ socket: Input.cold socket or scope\get '*sock*'
+ synth: Input.cold synth
+ ctrls: flat
+
+ tick: =>
+ { :socket, :synth, :ctrls } = @unwrap_all!
+ msg = pack '/s_new', synth, -1, 0, 1, unpack ctrls
+ socket\send msg
+
{
:play
+ 'play!': play_
}
diff --git a/lib/string.moon b/lib/string.moon
index 3f9b28b..faa7ab3 100644
--- a/lib/string.moon
+++ b/lib/string.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, Input from require 'core.base'
+import Op, ValueStream, Input from require 'alv.base'
str = ValueStream.meta
meta:
diff --git a/lib/time.moon b/lib/time.moon
index 344b5fa..2589d96 100644
--- a/lib/time.moon
+++ b/lib/time.moon
@@ -1,7 +1,7 @@
import
ValueStream, EventStream, IOStream,
Error, Op, Input, val, evt
-from require 'core.base'
+from require 'alv.base'
import monotime from require 'system'
class Clock extends IOStream
diff --git a/lib/util.moon b/lib/util.moon
index d760a64..dc133e4 100644
--- a/lib/util.moon
+++ b/lib/util.moon
@@ -1,4 +1,4 @@
-import Op, ValueStream, EventStream, Input, val, evt from require 'core.base'
+import Op, ValueStream, EventStream, Input, val, evt from require 'alv.base'
all_same = (list) ->
for v in *list[2,]