SuperCollider CLASSES

OSCArgsMatcher

Test for specific OSC arguments before evaluating a Function

Description

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

Class Methods

*new (argTemplate, func)

Make a new OSCArgsMatcher

Arguments:

argTemplate

An 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), nil (indicating that all possible values and types will match), or a Function to test the incoming argument (see 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.)

func

A 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 Array in the form [OSCAddress, ...otherArgs], the time that the message was sent, a NetAddr corresponding to the IP address of the sender, and an Integer corresponding to the port on which the message was received.

Inherited class methods

Instance Methods

-value (testMsg, time, addr, recvPort)

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.

Arguments:

testMsg

An Array in the form [OSCAddress, …msgArgs].

time

The time that the message was sent as a Float.

addr

A NetAddr corresponding to the IP address of the sender.

recvPort

An Integer corresponding to the port on which the message was received.

Inherited instance methods

Examples

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