# webrtc2osc

> Web to OSC bridge using PeerjS WebRTC

Latest version **1.0.1** (published 2023-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install webrtc2osc
pnpm add webrtc2osc
yarn add webrtc2osc
bun add webrtc2osc
```

Provides the command `webrtc2osc`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-04-18 |
| First published | 2023-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Mark Marijnissen |
| Maintainers | markm1337 |
| Keywords | webrtc, peerjs, osc, opensoundcontrol |

## Links

- npm: https://www.npmjs.com/package/webrtc2osc
- npm.io page: https://npm.io/package/webrtc2osc

## Dependencies (11)

- [ws](https://npm.io/package/ws.md) ^8.13.0
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [yargs](https://npm.io/package/yargs.md) ^17.7.1
- [osc-js](https://npm.io/package/osc-js.md) ^2.4.0
- [peerjs](https://npm.io/package/peerjs.md) ^2.0.0-beta.3
- [address](https://npm.io/package/address.md) ^1.2.2
- [filereader](https://npm.io/package/filereader.md) ^0.10.3
- [node-fetch](https://npm.io/package/node-fetch.md) ^3.3.1
- [@koush/wrtc](https://npm.io/package/@koush/wrtc.md) ^0.5.3
- [qrcode-terminal](https://npm.io/package/qrcode-terminal.md) ^0.12.0

## Recent versions

- 1.0.1 (latest) — 2023-04-18
- 1.0.0 — 2023-04-12
- 0.9.0 — 2023-04-11

## README

# webrtc2osc

Convert WebRTC messages to OSC (OpenSoundControl).

Browsers do not support the UDP-protocol, which is often used for OpenSoundControl. Instead, browsers have a similar low-latency lossy connection: the WebRTC data channel.

This is a commandline utility you run on your computer to act as a bridge, it will translate WebRTC messages to UDP, and vice versa.

It uses the excellent [PeerJS](https://peerjs.com/) and [osc-js](https://github.com/adzialocha/osc-js/) libraries.

## Usage

```
npx webrtc2osc 
    --peer-id MY_PEER_ID 
    --host localhost 
    --send 11000 
    --receive 11011 
    --url "http://{ip}:3000/?peerId={peerId}" 
    --qr 
    --log
```

- `--peer-id`: The peer id of the webrtc2osc bridge app.
- `--host`: The host address of the OSC server.
- `--send`: The port to send messages to.
- `--receive`: The port to receive messages from.
- `--url`: Generate an URL. `{peerId}` is replaced by the (generated) peerId, and `{ip}` is replaced by the IP address of your machine.
- `--qr`: Display QR code of the URL
- `--log`: log all messages

Settings are saved `webrtc2osc.json` in your HOME directory, so next time you can call `npx webrtc2osc` (without arguments).

## Client Usage

Use PeerJS to send and receive arrays of `[ address, ...args ]`. Use the `json` serialization, as the default (binary) is not supported in nodejs (yet).

```javascript
const peer = new Peer();
const conn = peer.connect("MY_PEER_ID", { serialization: "json" });
conn.send(['/say', 'hello world']); // note the array
conn.on('data', ([ address, ...args]) => { // note the array
    console.log(address, args);
})
```

PS. Creating an osc-js Plugin is not possible, because plugins need to send binary data, and there is no way I can unpack that on the server side.

## Changelog

- 1.0.1 Add --log parameter
- 1.0.0 Add URL and QR code.
- 0.9.0 Initial release.

---
_Source: https://npm.io/package/webrtc2osc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
