File: OSCArgsMatcher.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (46 lines) | stat: -rw-r--r-- 2,587 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
CLASS:: OSCArgsMatcher
summary:: Test for specific OSC arguments before evaluating a Function
categories:: External Control>OSC>Matchers
related:: Classes/OSCFunc, Guides/OSC_communication

DESCRIPTION::
OSCArgMatcher matches an argument template to a link::Classes/Function:: or similar object. When its value method is called, it evaluates the function if all of the arguments in its template pass a link::Reference/matchItem:: test.  This is used by link::Classes/OSCMessageDispatcher:: and link::Classes/OSCMessagePatternDispatcher:: to match incoming OSC messages to instances of link::Classes/OSCFunc:: or link::Classes/OSCdef:: using sender address. This class is private, and generally users should not need to address instances directly.

CLASSMETHODS::

METHOD:: new
Make a new OSCArgsMatcher

argument:: argTemplate
An link::Classes/Array:: comprising a template for determining if incoming arguments match. For each argument that you wish to test, you may include a constant (for exact matching), code::nil:: (indicating that all possible values and types will match), or a link::Classes/Function:: to test the incoming argument (see link::Reference/matchItem:: for examples). These should be in the same order as the items in the incoming OSC message, starting from index 1. (Index 0 is the OSC address.)

argument:: func
A link::Classes/Function:: or similar object which will respond to the incoming message. When evaluated it will be passed the arguments msg, time, addr, and recvPort, corresponding to the message as an link::Classes/Array:: in the form code::[OSCAddress, ...otherArgs]::, the time that the message was sent, a link::Classes/NetAddr:: corresponding to the IP address of the sender, and an link::Classes/Integer:: corresponding to the port on which the message was received.


INSTANCEMETHODS::
private:: init

METHOD:: value
Test if an incoming message's arguments match, and if so evaluate this object's function. In normal usage (within an OSCFunc) this is done behind the scenes.

argument:: testMsg
An link::Classes/Array:: in the form code::[OSCAddress, …msgArgs]::.

argument:: time
The time that the message was sent as a link::Classes/Float::.

argument:: addr
A link::Classes/NetAddr:: corresponding to the IP address of the sender.

argument:: recvPort
An link::Classes/Integer:: corresponding to the port on which the message was received.


EXAMPLES::

code::
// Basic example (standalone use)
m = OSCArgsMatcher([1, nil, 2], {'matches!'.postln});
m.value(['/myAddress', 1, 3, 2], 0.0, NetAddr.localAddr, NetAddr.langPort); // matches!
::