Merge branch 'main' into feature/autocomplete-sound-names
This commit is contained in:
commit
98a1573e27
2 changed files with 42 additions and 5 deletions
|
|
@ -14,16 +14,28 @@ You should see something like:
|
||||||
|
|
||||||
```log
|
```log
|
||||||
osc client running on port 57120
|
osc client running on port 57120
|
||||||
osc server running on port 7771
|
osc server running on port 57121
|
||||||
websocket server running on port 8080
|
websocket server running on port 8080
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### --port
|
||||||
|
|
||||||
By default it will use port 57120 for the osc client, which is what [superdirt](https://github.com/musikinformatik/SuperDirt) uses. You can change it via the `--port` option:
|
By default it will use port 57120 for the osc client, which is what [superdirt](https://github.com/musikinformatik/SuperDirt) uses. You can change it via the `--port` option:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npx @strudel/osc --port 7771 # classic dirt
|
npx @strudel/osc --port 7771 # classic dirt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### --debug
|
||||||
|
|
||||||
|
To log all incoming osc messages, add the `--debug` flag:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx @strudel/osc --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage in Strudel
|
||||||
|
|
||||||
To test it in strudel, you have can use `all(osc)` to send all events through osc:
|
To test it in strudel, you have can use `all(osc)` to send all events through osc:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
@ -32,7 +44,6 @@ $: s("bd*4")
|
||||||
all(osc)
|
all(osc)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[open in repl](https://strudel.cc/#JDogcygiYmQqNCIpCgphbGwob3NjKQ%3D%3D)
|
||||||
[open in repl](hhttps://strudel.cc/#JDogcygiYmQqNCIpCgphbGwob3NjKQ%3D%3D)
|
|
||||||
|
|
||||||
You can read more about [how to use Superdirt with Strudel the Tutorial](https://strudel.cc/learn/input-output/#superdirt-api)
|
You can read more about [how to use Superdirt with Strudel the Tutorial](https://strudel.cc/learn/input-output/#superdirt-api)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ function getArgValue(flag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let udpClientPort = Number(getArgValue('--port')) || 57120;
|
let udpClientPort = Number(getArgValue('--port')) || 57120;
|
||||||
// dirt = 7771
|
let debug = Number(getArgValue('--debug')) || 0;
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
receiver: 'ws', // @param {string} Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client
|
receiver: 'ws', // @param {string} Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client
|
||||||
|
|
@ -42,8 +42,34 @@ const config = {
|
||||||
|
|
||||||
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) });
|
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) });
|
||||||
|
|
||||||
osc.open(); // start a WebSocket server on port 8080
|
if (debug) {
|
||||||
|
osc.on('*', (message) => {
|
||||||
|
const { address, args } = message;
|
||||||
|
let str = '';
|
||||||
|
for (let i = 0; i < args.length; i += 2) {
|
||||||
|
str += `${args[i]}: ${args[i + 1]} `;
|
||||||
|
}
|
||||||
|
console.log(`${address} ${str}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
osc.on('error', (message) => {
|
||||||
|
if (message.toString().includes('EADDRINUSE')) {
|
||||||
|
console.log(`------ ERROR -------
|
||||||
|
osc server already running! to stop it:
|
||||||
|
1. run "lsof -ti :57121 | xargs kill -9" (macos / linux)
|
||||||
|
2. re-run the osc server
|
||||||
|
`);
|
||||||
|
} else {
|
||||||
|
console.log(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
osc.open();
|
||||||
|
|
||||||
console.log('osc client running on port', config.udpClient.port);
|
console.log('osc client running on port', config.udpClient.port);
|
||||||
console.log('osc server running on port', config.udpServer.port);
|
console.log('osc server running on port', config.udpServer.port);
|
||||||
console.log('websocket server running on port', config.wsServer.port);
|
console.log('websocket server running on port', config.wsServer.port);
|
||||||
|
if (debug) {
|
||||||
|
console.log('debug logs enabled. incoming messages will appear below');
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue