Compare commits

...

10 Commits

Author SHA1 Message Date
Felix Roos 663229ecde bump osc to 1.2.8 2025-09-17 13:50:02 +02:00
Felix Roos cdb623cb66 overhaul osc readme 2025-09-17 13:39:35 +02:00
Felix Roos 28d7e0e489 export osc function to be able to do all(osc) 2025-09-17 13:39:28 +02:00
Felix Roos aba594b72a fix: bin field 2025-09-17 12:52:42 +02:00
Felix Roos 5d7c6c3e4b fix: add node shebang + bump osc to 1.2.6 2025-09-17 12:47:41 +02:00
Felix Roos 820744dc27 bump osc to 1.2.5 2025-09-17 12:42:11 +02:00
Felix Roos 5445f0812f configurable port for osc bridge + add bin field 2025-09-17 12:41:46 +02:00
Switch Angel AKA Jade Rose 98b7003504 Merge pull request 'dev: logger errors to console in dev mode' (#1585) from devlog into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1585
2025-09-16 16:59:57 +02:00
Jade (Rose) Rowland 9a8f8a051c rm comment 2025-09-16 01:48:37 -04:00
Jade (Rose) Rowland 3eb40ee7d3 working in dev 2025-09-16 01:44:01 -04:00
6 changed files with 45 additions and 30 deletions
+3 -2
View File
@@ -5,8 +5,9 @@ let debounce = 1000,
lastTime; lastTime;
export function errorLogger(e, origin = 'cyclist') { export function errorLogger(e, origin = 'cyclist') {
//TODO: add some kind of debug flag that enables this while in dev mode if (process.env.NODE_ENV === 'development') {
// console.error(e); console.error(e);
}
logger(`[${origin}] error: ${e.message}`); logger(`[${origin}] error: ${e.message}`);
} }
+18 -19
View File
@@ -4,36 +4,35 @@ OSC output for strudel patterns! Currently only tested with super collider / sup
## Usage ## Usage
OSC will only work if you run the REPL locally + the OSC server besides it: Assuming you have [node.js](https://nodejs.org/) installed, you can run the osc bridge server via:
From the project root: ```sh
npx @strudel/osc
```js
npm run repl
``` ```
and in a seperate shell: You should see something like:
```js
npm run osc
```
This should give you
```log ```log
osc client running on port 57120 osc client running on port 57120
osc server running on port 57121 osc server running on port 7771
websocket server running on port 8080 websocket server running on port 8080
``` ```
Now open Supercollider (with the super dirt startup file) 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:
Now open the REPL and type: ```sh
npx @strudel/osc --port 7771 # classic dirt
```js
s("<bd sd> hh").osc()
``` ```
or just [click here](https://strudel.cc/#cygiPGJkIHNkPiBoaCIpLm9zYygp)... To test it in strudel, you have can use `all(osc)` to send all events through osc:
```js
$: s("bd*4")
all(osc)
```
[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)
+2 -4
View File
@@ -6,7 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th
import OSC from 'osc-js'; import OSC from 'osc-js';
import { logger, parseNumeral, Pattern, isNote, noteToMidi, ClockCollator } from '@strudel/core'; import { logger, parseNumeral, register, isNote, noteToMidi, ClockCollator } from '@strudel/core';
let connection; // Promise<OSC> let connection; // Promise<OSC>
function connect() { function connect() {
@@ -81,6 +81,4 @@ export async function oscTrigger(hap, currentTime, cps = 1, targetTime) {
* @memberof Pattern * @memberof Pattern
* @returns Pattern * @returns Pattern
*/ */
Pattern.prototype.osc = function () { export const osc = register('osc', (pat) => pat.onTrigger(oscTrigger));
return this.onTrigger(oscTrigger);
};
+2 -1
View File
@@ -1,8 +1,9 @@
{ {
"name": "@strudel/osc", "name": "@strudel/osc",
"version": "1.2.4", "version": "1.2.8",
"description": "OSC messaging for strudel", "description": "OSC messaging for strudel",
"main": "osc.mjs", "main": "osc.mjs",
"bin": "./server.js",
"type": "module", "type": "module",
"publishConfig": { "publishConfig": {
"main": "dist/index.mjs" "main": "dist/index.mjs"
+16 -1
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env node
/* /*
server.js - <short description TODO> server.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://codeberg.org/uzu/strudel/src/branch/main/packages/osc/server.js> Copyright (C) 2022 Strudel contributors - see <https://codeberg.org/uzu/strudel/src/branch/main/packages/osc/server.js>
@@ -6,6 +8,19 @@ This program is free software: you can redistribute it and/or modify it under th
import OSC from 'osc-js'; import OSC from 'osc-js';
const args = process.argv.slice(2);
function getArgValue(flag) {
const i = args.indexOf(flag);
if (i !== -1) {
const nextIsFlag = args[i + 1]?.startsWith('--') ?? true;
if (nextIsFlag) return true;
return args[i + 1];
}
}
let udpClientPort = Number(getArgValue('--port')) || 57120;
// dirt = 7771
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
udpServer: { udpServer: {
@@ -17,7 +32,7 @@ const config = {
}, },
udpClient: { udpClient: {
host: 'localhost', // @param {string} Hostname of udp client for messaging host: 'localhost', // @param {string} Hostname of udp client for messaging
port: 57120, // @param {number} Port of udp client for messaging port: udpClientPort, // @param {number} Port of udp client for messaging
}, },
wsServer: { wsServer: {
host: 'localhost', // @param {string} Hostname of WebSocket server host: 'localhost', // @param {string} Hostname of WebSocket server
+4 -3
View File
@@ -1,8 +1,9 @@
let log = (msg) => console.log(msg); let log = (msg) => console.log(msg);
export function errorLogger(e, origin = 'cyclist') { export function errorLogger(e, origin = 'superdough') {
//TODO: add some kind of debug flag that enables this while in dev mode if (process.env.NODE_ENV === 'development') {
// console.error(e); console.error(e);
}
logger(`[${origin}] error: ${e.message}`); logger(`[${origin}] error: ${e.message}`);
} }