-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ac01f2
commit 73cf403
Showing
27 changed files
with
10,536 additions
and
2,278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CI | ||
run-name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
- run: npm ci | ||
- run: npm run lint | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules | ||
examples/*.js | ||
build/*.js | ||
/coverage.html | ||
/lib/osc-utilities.js | ||
dist/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
node_modules/ | ||
build/ | ||
coverage.html | ||
node_modules | ||
lib/ | ||
test/ | ||
examples/ | ||
eslint.config.mjs | ||
tsconfig.json | ||
.github/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import preferArrowFunctions from "eslint-plugin-prefer-arrow-functions"; | ||
import eslint from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import globals from "globals"; | ||
export default [ | ||
{ | ||
ignores: ["**/dist", "**/test", "**/eslint.config.mjs"], | ||
}, | ||
eslint.configs.recommended, | ||
...tseslint.configs.strict, | ||
...tseslint.configs.stylistic, | ||
{ | ||
plugins: { | ||
"prefer-arrow-functions": preferArrowFunctions, | ||
}, | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
argsIgnorePattern: "^_", | ||
caughtErrorsIgnorePattern: "^_", | ||
}, | ||
], | ||
|
||
"@typescript-eslint/no-non-null-assertion": "off", | ||
|
||
"@typescript-eslint/restrict-template-expressions": [ | ||
"error", | ||
{ | ||
allowNumber: true, | ||
}, | ||
], | ||
|
||
"@typescript-eslint/no-unnecessary-condition": [ | ||
"error", | ||
{ | ||
allowConstantLoopConditions: true, | ||
}, | ||
], | ||
|
||
"prefer-arrow-functions/prefer-arrow-functions": [ | ||
"error", | ||
{ | ||
returnStyle: "implicit", | ||
}, | ||
], | ||
|
||
"@typescript-eslint/consistent-type-definitions": ["error", "type"], | ||
"no-warning-comments": "error", | ||
}, | ||
}, | ||
{ | ||
files: ["**/examples/*.mjs", "**/examples/*.js"], | ||
...tseslint.configs.disableTypeChecked, | ||
}, | ||
{ | ||
files: ["**/examples/*.mjs", "**/examples/*.js"], | ||
languageOptions: { | ||
globals: globals.node, | ||
}, | ||
}, | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as osc from "osc-min"; | ||
import * as dgram from "dgram"; | ||
|
||
const inport = process.argv[2] != null ? parseInt(process.argv[2]) : 41234; | ||
const outport = process.argv[3] != null ? parseInt(process.argv[3]) : 41235; | ||
|
||
const float_to_int = (message) => { | ||
for (const arg of message.args) { | ||
if (arg.type === "float") { | ||
arg.type = "integer"; | ||
} | ||
} | ||
return message; | ||
}; | ||
|
||
const sock = dgram.createSocket("udp4", (msg) => { | ||
try { | ||
const edited = osc.applyMessageTransform(msg, (message) => | ||
float_to_int(message) | ||
); | ||
return sock.send(edited, 0, edited.byteLength, outport, "localhost"); | ||
} catch (error) { | ||
return console.log("error redirecting", error); | ||
} | ||
}); | ||
|
||
sock.bind(inport); | ||
|
||
console.log("OSC redirecter running at http://localhost:" + inport); | ||
|
||
console.log("translating messages to http://localhost:" + outport); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as osc from "osc-min"; | ||
import * as dgram from "dgram"; | ||
|
||
const inport = process.argv[2] != null ? parseInt(process.argv[2]) : 41234; | ||
const outport = process.argv[3] != null ? parseInt(process.argv[3]) : 41235; | ||
|
||
console.log(`OSC redirecter running at http://localhost:${inport}`); | ||
console.log(`redirecting messages to http://localhost:${outport}`); | ||
|
||
const sock = dgram.createSocket("udp4", (msg) => { | ||
try { | ||
const redirected = osc.applyAddressTransform( | ||
msg, | ||
(address) => `/redirect${address}` | ||
); | ||
return sock.send( | ||
redirected, | ||
0, | ||
redirected.byteLength, | ||
outport, | ||
"localhost" | ||
); | ||
} catch (e) { | ||
return console.log(`error redirecting: ${e}`); | ||
} | ||
}); | ||
|
||
sock.bind(inport); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as osc from "osc-min"; | ||
import * as dgram from "dgram"; | ||
|
||
const udp = dgram.createSocket("udp4"); | ||
|
||
const outport = process.argv[2] != null ? parseInt(process.argv[2]) : 41234; | ||
|
||
const sendHeartbeat = () => { | ||
const buf = osc.toBuffer({ | ||
timetag: new Date(new Date().getTime() + 50), | ||
elements: [ | ||
{ | ||
address: "/p1", | ||
args: new TextEncoder().encode("beat"), | ||
}, | ||
{ | ||
address: "/p2", | ||
args: "string", | ||
}, | ||
{ | ||
timetag: new Date(new Date().getTime() + 1000), | ||
elements: [ | ||
{ | ||
address: "/p3", | ||
args: 12, | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
return udp.send(buf, 0, buf.byteLength, outport, "localhost"); | ||
}; | ||
|
||
setInterval(sendHeartbeat, 2000); | ||
console.log(`sending heartbeat messages to http://localhost:${outport}`); |
Oops, something went wrong.