sc3nb.osc.parsing
Module for parsing OSC packets from sclang.
This implements an extension of the OSC protocol. A bundle is now allowed to consist of other bundles or lists.
This extension is needed as sclang is sending Arrays as this list or when nested as bundles with inner list
Module Contents
Function List
Get next multiple of NUM_SIZE from index |
|
Parse a OSC List |
|
Parse an element from an OSC bundle. |
|
Parsing bundle |
|
Parses the OSC packet from sclang. |
|
Preprocessing function for /return values |
Content
- exception sc3nb.osc.parsing.ParseError[source]
Bases:
ExceptionBase exception for when a datagram parsing error occurs.
Initialize self. See help(type(self)) for accurate signature.
- sc3nb.osc.parsing._get_aligned_index(index: int) int[source]
Get next multiple of NUM_SIZE from index
- Parameters:
- indexint
starting index
- Returns:
- int
next multiple of NUM_SIZE from index
- sc3nb.osc.parsing._parse_list(dgram: bytes, start_index: int) Tuple[Sequence[Any], int][source]
Parse a OSC List
List consists of the following bytes: 4 bytes (int) : list_size n bytes (string) : OSC type tag n bytes (x) : content as specified by type tag
- Parameters:
- dgrambytes
datagram with the list
- start_indexint
parsing starting index
- Returns:
- Tuple[Sequence[Any], int]
parsed list contents, starting index + number of consumed bytes
- Raises:
- ParseError
If datagram is invalid.
- sc3nb.osc.parsing._parse_osc_bundle_element(dgram: bytes, start_index: int) Tuple[Union[Sequence[Any], bytes], int][source]
Parse an element from an OSC bundle.
The element needs to be either an OSC bundle or a list
- Parameters:
- dgrambytes
datagram with the bundle element
- start_indexint
parsing starting index
- Returns:
- Tuple[Union[Sequence[Any], bytes], int]
parsed content of the bundle element, starting index + number of consumed bytes
- Raises:
- ParseError
If the datagram is invalid.
- sc3nb.osc.parsing._parse_bundle(dgram: bytes, start_index: int) Tuple[Sequence[Any], int][source]
Parsing bundle
- Parameters:
- dgrambytes
datagram with the bundle
- start_indexint
parsing starting index
- Returns:
- tuple[Sequence[Any], int]
parsed content, starting index + number of consumed bytes
- Raises:
- ParseError
If the datagram is invalid