TypeScript implementation of OSC (Open Sound Control)
import { encodeOSC } from "@deno-plc/adapter-osc"; const packet = encodeOSC("/foo/bar", [5, true]);
This might throw an OSCProtocolError if the supplied data is invalid
import { decodeOSC } from "@deno-plc/adapter-osc"; const [address, args] = decodeOSC(packet);
This might throw an OSCProtocolError if the supplied data is invalid
string
)number
)Uint8Array
)number
)number
)boolean
)While the specs only covers ASCII strings, you might encounter situations where you need Unicode characters. Please note that the following is non-standard behavior.
decodeOSC
will treat everything it receives as UTF-8.
encodeOSC
is able to encode UTF-8 strings, but in the default configuration it
will throw an error on multi-byte characters because the allocated buffer is not
large enough. You can increase the buffer size with the oversize
option.
Alternatively you can use encodeOSC_UTF8
(not recommended as default, 1.5-2x
slower than the standard encoder)
This package has support for OSC-over-TCP (=OSC packets are transmitted
SLIP (Serial Line Internet Protocol)
encoded over a TCP socket) usable in conjunction with
adapter-tcp. For usage instructions see
examples/tcposc.ts
This package contains two implementations of OSC. While the default version is around 10x faster than the so-called slow version, it contains a lot of string/array manipulation functions with offset calculations (which could possibly be buggy). For this reason the slow version is kept and used as a testing reference.
(C) 2024 Hans Schallmoser
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Add Package
deno add jsr:@deno-plc/adapter-osc
Import symbol
import * as adapter_osc from "@deno-plc/adapter-osc";
---- OR ----
Import directly with a jsr specifier
import * as adapter_osc from "jsr:@deno-plc/adapter-osc";
Add Package
npx jsr add @deno-plc/adapter-osc
Import symbol
import * as adapter_osc from "@deno-plc/adapter-osc";
Add Package
yarn dlx jsr add @deno-plc/adapter-osc
Import symbol
import * as adapter_osc from "@deno-plc/adapter-osc";
Add Package
pnpm dlx jsr add @deno-plc/adapter-osc
Import symbol
import * as adapter_osc from "@deno-plc/adapter-osc";
Add Package
bunx jsr add @deno-plc/adapter-osc
Import symbol
import * as adapter_osc from "@deno-plc/adapter-osc";