https://github.com/ssilverman/liteoscparser
A lightweight OSC parser.
https://github.com/ssilverman/liteoscparser
arduino osc structured-data teensy
Last synced: about 2 months ago
JSON representation
A lightweight OSC parser.
- Host: GitHub
- URL: https://github.com/ssilverman/liteoscparser
- Owner: ssilverman
- License: bsd-3-clause-clear
- Created: 2018-03-13T07:04:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-12T03:26:04.000Z (about 7 years ago)
- Last Synced: 2025-06-30T22:41:42.308Z (12 months ago)
- Topics: arduino, osc, structured-data, teensy
- Language: C++
- Size: 242 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Readme for LiteOSCParser v1.4.0
This library parses and constructs OSC messages. It is designed to minimize
memory usage by providing a way to pre-allocate the internal buffers.
Bundles are supported via a simple container class.
## Features
Notable features of this library:
1. Ability to control memory usage.
2. Lightweight API.
## How to use
The classes you'll need are in the `qindesign::osc` namespace:
`LiteOSCParser` and possibly `OSCBundle`. A complete example of how to use
the parser is in the `AllInOne` example.
The main class documentation can be found in `src/LiteOSCParser.h`.
OSC bundles are managed using the simple `OSCBundle` container class.
## Installing as an Arduino library
Not all the files in this project are necessary in an installed library.
Only the following files and directories need to be there:
* `*.md`
* `LICENSE`
* `examples/`
* `library.json`
* `library.properties`
* `src/`
## Running the tests
There are tests included in this project that rely on a project called
[ArduinoUnit](https://github.com/mmurdoch/arduinounit).
Note that the code for ArduinoUnit is not included in this library and needs
to be downloaded separately.
## Notes on use
### Retrieving values
By default, if a value does not exist at a given index, a default value will be
returned. For example, `getFloat(2)` will try to return a 32-bit float value at
index 2. If the index is out of range or if the value type at that index is not
a float then a value of 0.0f will be returned.
To avoid this scenario, the following code is useful:
```c++
if (isFloat(2)) {
float f = getFloat(2);
// Do something with the value
}
```
Internally, `getFloat` also calls `isFloat` with the same index, and so
`isFloat` is actually called twice. To avoid two calls, there exist other getter
functions named `getIfXXX` (replacing _XXX_ with the appropriate type). For
example, `getIfFloat` to retrieve a float. These functions return a `bool`:
`true` if the value exists and was retrieved, and `false` otherwise.
For example:
```c++
float f;
if (getIfFloat(2, &f)) {
// Do something with 'f'
}
```
## Code style
Code style for this project mostly follows the
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
## References
1. [OSC 1.0 Specification](http://opensoundcontrol.org/spec-1_0)
2. [OSC 1.1 Specification](http://opensoundcontrol.org/spec-1_1)
3. [NIME 2009 paper](https://hangar.org/webnou/wp-content/uploads/2012/01/Nime09OSCfinal.pdf)
4. [TouchOSC](https://hexler.net/docs/touchosc)
---
Copyright (c) 2018-2019 Shawn Silverman