65 | 65 |
add_item msg, @inputs[i]\type!, args[i]
|
66 | 66 |
socket\send msg.pack msg.content
|
67 | 67 |
|
|
68 |
send_arr = Constant.meta
|
|
69 |
meta:
|
|
70 |
name: 'send-arr'
|
|
71 |
summary: "Send an OSC message using arrays."
|
|
72 |
examples: { '(osc/send [socket] path val…)' }
|
|
73 |
description: "Sends an OSC message to `path` with `val…` as arguments.
|
|
74 |
|
|
75 |
- `socket` should be a `udp/socket` value. This argument can be omitted and the
|
|
76 |
value be passed as a dynamic definition in `*sock*` instead.
|
|
77 |
- `path` is the OSC path to send the message to. It should be a string-value.
|
|
78 |
- the arguments can be any type:
|
|
79 |
- `num` will be sent as `f`
|
|
80 |
- `str` will be sent as `s`
|
|
81 |
- `bool` will be sent as `T`/`F`
|
|
82 |
- `bang` will be sent as `T`
|
|
83 |
- arrays will be sent as a series of values surrounded by `[…]`
|
|
84 |
- structs will be sent as a series of key (`s`)/value tuples surrounded by `[…]`
|
|
85 |
|
|
86 |
This is a pure op, so between the values at most one !-stream input is allowed."
|
|
87 |
|
|
88 |
value: class extends PureOp
|
|
89 |
pattern: any!^0
|
|
90 |
|
|
91 |
full_pattern = -sig['udp/socket'] + sig.str + any!^0
|
|
92 |
setup: (inputs, scope) =>
|
|
93 |
{ socket, path, values } = full_pattern\match inputs
|
|
94 |
super values, scope, {
|
|
95 |
socket: Input.cold socket or scope\get '*sock*'
|
|
96 |
path: Input.cold path
|
|
97 |
}
|
|
98 |
|
|
99 |
tick: =>
|
|
100 |
args = @unwrap_all!
|
|
101 |
{ :socket, :path } = args
|
|
102 |
msg = new_message path
|
|
103 |
for i=1,#args
|
|
104 |
add_item msg, @inputs[i]\type!, args[i], true
|
|
105 |
socket\send msg.pack msg.content
|
|
106 |
|
68 | 107 |
Constant.meta
|
69 | 108 |
meta:
|
70 | 109 |
name: 'osc'
|