mne_rt.OSCSender#
- class mne_rt.OSCSender(host: str = '127.0.0.1', port: int = 9000, prefix: str = '/ant', bundle: bool = False)[source]#
Bases:
objectThread-safe OSC client that broadcasts NF feature values.
Sends one UDP packet per NF value (or one bundle per update cycle) to an OSC server at the given host/port. Safe to call from any thread.
- Parameters:
- host
str, default “127.0.0.1” Destination IP address or hostname.
- port
int, default 9000 Destination UDP port.
- prefix
str, default “/ant” OSC address prefix. Each modality is sent to
<prefix>/<modality>.- bundlebool, default
False If
True, pack all modality values into a single OSC bundle per update cycle (one UDP packet) instead of one packet per modality.
- host
- Raises:
ImportErrorIf
python-oscis not installed (should not occur with a standard ANT install).
Examples
Basic usage:
sender = OSCSender(host="127.0.0.1", port=9000) sender.send("sensor_power", 0.35) sender.send_all(["sensor_power", "erd_ers"], [0.35, -12.4]) sender.close()
Custom prefix (maps to
/nf/sensor_power):sender = OSCSender(prefix="/nf")
Added in version 1.0.0.
- __init__(host: str = '127.0.0.1', port: int = 9000, prefix: str = '/ant', bundle: bool = False) None[source]#
Methods
__init__([host, port, prefix, bundle])close()Close the underlying UDP socket.
send(modality, value)Send a single NF value immediately.
send_all(modalities, values)Send all NF values for one update cycle.
send_raw(address, *args)Send an arbitrary OSC message to a custom address.
Attributes
Human-readable target as
"host:port".- send(modality: str, value: float) None[source]#
Send a single NF value immediately.
- Parameters:
Notes
The OSC message sent is:
<prefix>/<modality> float32 <value>
- send_all(modalities: Sequence[str], values: Sequence[float]) None[source]#
Send all NF values for one update cycle.
When
bundle=True(set in__init__()), packs everything into a single OSC bundle datagram. Otherwise sends one message per modality.- Parameters:
- Raises:
ValueErrorIf
modalitiesandvalueshave different lengths.
- send_raw(address: str, *args) None[source]#
Send an arbitrary OSC message to a custom address.
- Parameters:
- address
str Full OSC address (e.g.
"/my/custom/path").- *args
OSC arguments (int, float, str, bytes).
- address