aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sc.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-21 19:06:18 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-21 19:06:18 +0000
commite83df1af2cdad8c2d61ba790a96875cd260eceaf (patch)
tree5766654329675bd5259be772bc2537c7fdd8ab1c /lib/sc.moon
parentdocs/guide: document supported interpreter versions (diff)
downloadalive-e83df1af2cdad8c2d61ba790a96875cd260eceaf.tar.gz
alive-e83df1af2cdad8c2d61ba790a96875cd260eceaf.zip
new meta/doc system
Diffstat (limited to 'lib/sc.moon')
-rw-r--r--lib/sc.moon49
1 files changed, 28 insertions, 21 deletions
diff --git a/lib/sc.moon b/lib/sc.moon
index 7562620..dd9e826 100644
--- a/lib/sc.moon
+++ b/lib/sc.moon
@@ -1,30 +1,37 @@
-import Op, Input, Error, match from require 'core.base'
+import Op, Value, Input, Error, match from require 'core.base'
import pack from require 'osc'
import dns, udp from require 'socket'
-class play extends Op
- @doc: "(sc/play socket synth trigger [name-str val]...) - play a SC SynthDef"
+play = Value.meta
+ meta:
+ name: 'play'
+ summary: 'Play a SuperCollider SynthDef.'
+ examples: { '(play socket synth trig [param val…])' }
+ description: "
+Plays the synth `synth` on the `udp/socket` `socket` whenever `trig` is live.
+Any number of parameter-value pairs can be specified and are captured and sent
+together with the note when triggered."
+ value: class extends Op
+ setup: (inputs) =>
+ { socket, synth, trig, ctrls } = match 'udp/socket str bang *any?', inputs
- setup: (inputs) =>
- { socket, synth, trig, ctrls } = match 'udp/socket str bang *any?', inputs
+ assert #ctrls % 2 == 0, Error 'argument', "parameters need to be specified as pairs"
+ for key in *ctrls[1,,2]
+ assert key\type! == 'str', Error 'argument', "ony strings are supported as control names"
+ for val in *ctrls[2,,2]
+ assert val\type! == 'num', Error 'argument', "only numbers are supported as control values"
- assert #ctrls % 2 == 0, Error 'argument', "parameters need to be specified as pairs"
- for key in *ctrls[1,,2]
- assert key\type! == 'str', Error 'argument', "ony strings are supported as control names"
- for val in *ctrls[2,,2]
- assert val\type! == 'num', Error 'argument', "only numbers are supported as control values"
+ super
+ trig: Input.event trig
+ socket: Input.cold socket
+ synth: Input.cold synth
+ ctrls: [Input.cold v for v in *ctrls]
- super
- trig: Input.event trig
- socket: Input.cold socket
- synth: Input.cold synth
- ctrls: [Input.cold v for v in *ctrls]
-
- tick: =>
- if @inputs.trig\dirty! and @inputs.trig!
- { :socket, :synth, :ctrls } = @unwrap_all!
- msg = pack '/s_new', synth, -1, 0, 1, unpack ctrls
- socket\send msg
+ tick: =>
+ if @inputs.trig\dirty! and @inputs.trig!
+ { :socket, :synth, :ctrls } = @unwrap_all!
+ msg = pack '/s_new', synth, -1, 0, 1, unpack ctrls
+ socket\send msg
{
:play