mirror of
https://github.com/jwetzell/osc-js.git
synced 2026-08-21 14:59:01 +00:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f214396ae | |||
| 925ff2a409 | |||
| 5a5a6ab0a5 | |||
| 512b2d63c0 | |||
| e592229815 | |||
| 768d6d5a4b | |||
| 119574743d | |||
| 709312585f | |||
| fdaa8b8ed1 | |||
| 91fdf60737 | |||
| e5d559eb1a | |||
| 1c68227aac | |||
| f32b8ce679 | |||
| 0df2dec5e9 | |||
| d587b0cf19 | |||
| eca0639b38 | |||
| 7601cfb096 | |||
| f9f763d6c4 | |||
| 786e71fd82 | |||
| a2adc3d2f4 | |||
| 4ec6bae5fe | |||
| f75b663812 | |||
| 7a72853e41 | |||
| 81e0a542c5 | |||
| 278d09bb6f | |||
| 4b56f09a64 | |||
| b44e5d306a | |||
| 7a3ad57482 | |||
| 13a8334504 | |||
| e0bae3b386 | |||
| 2716ccc349 | |||
| acc93189a9 | |||
| 180c9ff76a | |||
| 25fe42415e | |||
| fd6949c897 |
@@ -1,25 +0,0 @@
|
|||||||
name: Check makeosc builds
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'apps/makeosc/**'
|
|
||||||
jobs:
|
|
||||||
build-webui:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: 'package-lock.json'
|
|
||||||
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
run: npm ci --workspace makeosc
|
|
||||||
|
|
||||||
- run: npm run build --workspace makeosc
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
name: Check readosc builds
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'apps/readosc/**'
|
|
||||||
jobs:
|
|
||||||
build-webui:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: 'package-lock.json'
|
|
||||||
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
run: npm ci --workspace readosc
|
|
||||||
|
|
||||||
- run: npm run build --workspace readosc
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
name: Check sendosc builds
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'apps/sendosc/**'
|
|
||||||
jobs:
|
|
||||||
build-webui:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: 'package-lock.json'
|
|
||||||
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
run: npm ci --workspace sendosc
|
|
||||||
|
|
||||||
- run: npm run build --workspace sendosc
|
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jwetzell/osc": "0.2.2",
|
"@jwetzell/osc": "0.2.2",
|
||||||
"commander": "^11.0.0",
|
"commander": "^12.1.0",
|
||||||
"slip": "^1.0.2"
|
"slip": "^1.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "readosc",
|
"name": "readosc",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"description": "Simple NodeJS utility for parsing osc buffers from stdin",
|
"description": "Simple NodeJS utility for parsing osc buffers from stdin",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jwetzell/osc": "0.2.2",
|
"@jwetzell/osc": "1.0.0",
|
||||||
"commander": "^11.0.0"
|
"commander": "^12.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,16 @@ program.description('simple util to read osc packets from stdin');
|
|||||||
program.action(() => {
|
program.action(() => {
|
||||||
process.stdin.on('data', (data) => {
|
process.stdin.on('data', (data) => {
|
||||||
try {
|
try {
|
||||||
const message = osc.messageFromBuffer(data);
|
let remainingBytes = data;
|
||||||
console.log(JSON.stringify(message));
|
while (remainingBytes.length > 0) {
|
||||||
|
try {
|
||||||
|
const [message, bytesAfterMessage] = osc.messageFromBuffer(remainingBytes);
|
||||||
|
remainingBytes = bytesAfterMessage;
|
||||||
|
console.log(JSON.stringify(message));
|
||||||
|
} catch (error) {
|
||||||
|
console.error({ error: error.toString() });
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error({ error: error.toString() });
|
console.error({ error: error.toString() });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jwetzell/osc": "0.2.2",
|
"@jwetzell/osc": "0.2.2",
|
||||||
"commander": "^11.0.0",
|
"commander": "^12.1.0",
|
||||||
"slip": "^1.0.2"
|
"slip": "^1.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+21
-18
@@ -23,7 +23,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jwetzell/osc": "0.2.2",
|
"@jwetzell/osc": "0.2.2",
|
||||||
"commander": "^11.0.0",
|
"commander": "^12.1.0",
|
||||||
"slip": "^1.0.2"
|
"slip": "^1.0.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -36,27 +36,27 @@
|
|||||||
"integrity": "sha512-HobCAMnDDSrKfrMBrF5ySA8fKO8Qjkn2HDKysuV51sHrpXABKJFQt5OemIQgbnSMNWU0kZ0+FF9xRrivHHaDTg=="
|
"integrity": "sha512-HobCAMnDDSrKfrMBrF5ySA8fKO8Qjkn2HDKysuV51sHrpXABKJFQt5OemIQgbnSMNWU0kZ0+FF9xRrivHHaDTg=="
|
||||||
},
|
},
|
||||||
"apps/readosc": {
|
"apps/readosc": {
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jwetzell/osc": "0.2.2",
|
"@jwetzell/osc": "1.0.0",
|
||||||
"commander": "^11.0.0"
|
"commander": "^12.1.0"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"readosc": "src/main.js"
|
"readosc": "src/main.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apps/readosc/node_modules/@jwetzell/osc": {
|
"apps/readosc/node_modules/@jwetzell/osc": {
|
||||||
"version": "0.2.2",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@jwetzell/osc/-/osc-0.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/@jwetzell/osc/-/osc-1.0.0.tgz",
|
||||||
"integrity": "sha512-HobCAMnDDSrKfrMBrF5ySA8fKO8Qjkn2HDKysuV51sHrpXABKJFQt5OemIQgbnSMNWU0kZ0+FF9xRrivHHaDTg=="
|
"integrity": "sha512-242gA8R4k9vBbRJydqoKAG1WiQ9BUO6tFoemuC3eywRt5ns5qrlzIBEIwX0poQyMZdZB7XyzvR5rtbFC5tadKg=="
|
||||||
},
|
},
|
||||||
"apps/sendosc": {
|
"apps/sendosc": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jwetzell/osc": "0.2.2",
|
"@jwetzell/osc": "0.2.2",
|
||||||
"commander": "^11.0.0",
|
"commander": "^12.1.0",
|
||||||
"slip": "^1.0.2"
|
"slip": "^1.0.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -255,9 +255,10 @@
|
|||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.7.4",
|
"version": "22.7.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz",
|
||||||
|
"integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.19.2"
|
"undici-types": "~6.19.2"
|
||||||
}
|
}
|
||||||
@@ -611,10 +612,11 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/commander": {
|
"node_modules/commander": {
|
||||||
"version": "11.1.0",
|
"version": "12.1.0",
|
||||||
"license": "MIT",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
|
||||||
|
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
@@ -3406,9 +3408,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.6.2",
|
"version": "5.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
|
||||||
|
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
@@ -3648,12 +3651,12 @@
|
|||||||
},
|
},
|
||||||
"packages/osc": {
|
"packages/osc": {
|
||||||
"name": "@jwetzell/osc",
|
"name": "@jwetzell/osc",
|
||||||
"version": "1.0.0",
|
"version": "1.3.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "22.7.4",
|
"@types/node": "22.7.5",
|
||||||
"rimraf": "6.0.1",
|
"rimraf": "6.0.1",
|
||||||
"typescript": "5.6.2"
|
"typescript": "5.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@jwetzell/osc",
|
"name": "@jwetzell/osc",
|
||||||
"version": "1.0.0",
|
"version": "1.3.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "22.7.4",
|
"@types/node": "22.7.5",
|
||||||
"rimraf": "6.0.1",
|
"rimraf": "6.0.1",
|
||||||
"typescript": "5.6.2"
|
"typescript": "5.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-31
@@ -22,42 +22,52 @@ export function bundleFromBuffer(bytes: Uint8Array): [OSCBundle | undefined, Uin
|
|||||||
|
|
||||||
let endOfBundle = false;
|
let endOfBundle = false;
|
||||||
|
|
||||||
let [contentSize, remainingBytes] = oscTypeConverterMap.i.fromBuffer(bytesAfterTimeTag);
|
// let [contentSize, remainingBytes] = oscTypeConverterMap.i.fromBuffer(bytesAfterTimeTag);
|
||||||
if (typeof contentSize === 'number') {
|
let remainingBytes = bytesAfterTimeTag;
|
||||||
while (!endOfBundle) {
|
|
||||||
if (remainingBytes.length < contentSize) {
|
|
||||||
throw new Error('bundle does not contain enough data');
|
|
||||||
}
|
|
||||||
|
|
||||||
const bundleContentBytes = remainingBytes.subarray(0, contentSize);
|
while (!endOfBundle) {
|
||||||
|
let [contentSize, bytesAfterContentSize] = oscTypeConverterMap.i.fromBuffer(remainingBytes);
|
||||||
|
|
||||||
if (bundleContentBytes[0] === 35) {
|
if (typeof contentSize !== 'number') {
|
||||||
// # character indicating contents is a bundle
|
throw new Error('problem decoding content size');
|
||||||
const [content, bytesAfterContent] = bundleFromBuffer(bundleContentBytes);
|
}
|
||||||
if (content) {
|
|
||||||
bundleContents.push(content);
|
remainingBytes = bytesAfterContentSize;
|
||||||
}
|
|
||||||
} else if (bundleContentBytes[0] === 47) {
|
if (remainingBytes.length < contentSize) {
|
||||||
const [content, bytesAfterContent] = messageFromBuffer(bundleContentBytes);
|
throw new Error('bundle does not contain enough data');
|
||||||
if (content && content !== undefined) {
|
}
|
||||||
bundleContents.push(content);
|
|
||||||
}
|
const bundleContentBytes = bytesAfterContentSize.subarray(0, contentSize);
|
||||||
} else {
|
|
||||||
throw new Error('bundle contents does not look like a OSC message or bundle');
|
if (bundleContentBytes[0] === 35) {
|
||||||
}
|
// # character indicating contents is a bundle
|
||||||
|
const [content, bytesAfterContent] = bundleFromBuffer(bundleContentBytes);
|
||||||
remainingBytes = remainingBytes.subarray(contentSize);
|
if (content) {
|
||||||
if (remainingBytes.length === 0) {
|
bundleContents.push(content);
|
||||||
endOfBundle = true;
|
}
|
||||||
}
|
} else if (bundleContentBytes[0] === 47) {
|
||||||
|
const [content, bytesAfterContent] = messageFromBuffer(bundleContentBytes);
|
||||||
|
if (content && content !== undefined) {
|
||||||
|
bundleContents.push(content);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('bundle contents does not look like a OSC message or bundle');
|
||||||
|
}
|
||||||
|
|
||||||
|
remainingBytes = bytesAfterContentSize.subarray(contentSize);
|
||||||
|
if (remainingBytes.length === 0) {
|
||||||
|
endOfBundle = true;
|
||||||
}
|
}
|
||||||
return [{
|
|
||||||
timeTag,
|
|
||||||
contents: bundleContents,
|
|
||||||
},remainingBytes];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [undefined, undefined]
|
return [
|
||||||
|
{
|
||||||
|
timeTag,
|
||||||
|
contents: bundleContents,
|
||||||
|
},
|
||||||
|
remainingBytes,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bundleToBuffer(bundle: OSCBundle): Uint8Array {
|
export function bundleToBuffer(bundle: OSCBundle): Uint8Array {
|
||||||
|
|||||||
+55
-10
@@ -33,12 +33,29 @@ export function messageToBuffer(message: OSCMessage): Uint8Array {
|
|||||||
throw new Error('problem encoding address');
|
throw new Error('problem encoding address');
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeString = message.args.map((arg) => arg.type).join('');
|
let typeString = ','
|
||||||
const typesBuffer = oscTypeConverterMap.s.toBuffer(`,${typeString}`);
|
|
||||||
|
const flatOSCArgs: OSCArg[] = []
|
||||||
|
|
||||||
|
message.args.forEach((oscArg)=> {
|
||||||
|
if(Array.isArray(oscArg)){
|
||||||
|
typeString += '['
|
||||||
|
oscArg.forEach((oscArg)=>{
|
||||||
|
typeString += oscArg.type
|
||||||
|
flatOSCArgs.push(oscArg)
|
||||||
|
})
|
||||||
|
typeString += ']'
|
||||||
|
}else {
|
||||||
|
typeString += oscArg.type
|
||||||
|
flatOSCArgs.push(oscArg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const typesBuffer = oscTypeConverterMap.s.toBuffer(typeString);
|
||||||
if (typesBuffer === undefined) {
|
if (typesBuffer === undefined) {
|
||||||
throw new Error('problem encoding types');
|
throw new Error('problem encoding types');
|
||||||
}
|
}
|
||||||
const argsBuffer = argsToBuffer(message.args);
|
const argsBuffer = argsToBuffer(flatOSCArgs);
|
||||||
const buffer = new Uint8Array(addressBuffer.length + typesBuffer.length + argsBuffer.length);
|
const buffer = new Uint8Array(addressBuffer.length + typesBuffer.length + argsBuffer.length);
|
||||||
buffer.set(addressBuffer, 0);
|
buffer.set(addressBuffer, 0);
|
||||||
buffer.set(typesBuffer, addressBuffer.length);
|
buffer.set(typesBuffer, addressBuffer.length);
|
||||||
@@ -51,7 +68,7 @@ export function messageFromBuffer(bytes: Uint8Array): [OSCMessage | undefined, U
|
|||||||
throw new Error('osc message must start with a /');
|
throw new Error('osc message must start with a /');
|
||||||
}
|
}
|
||||||
|
|
||||||
const oscArgs: OSCArg[] = [];
|
const oscArgs: (OSCArg | OSCArg[])[] = [];
|
||||||
|
|
||||||
const [address, bytesAfterAddress] = oscTypeConverterMap.s.fromBuffer(bytes);
|
const [address, bytesAfterAddress] = oscTypeConverterMap.s.fromBuffer(bytes);
|
||||||
if (typeof address === 'string') {
|
if (typeof address === 'string') {
|
||||||
@@ -61,9 +78,30 @@ export function messageFromBuffer(bytes: Uint8Array): [OSCMessage | undefined, U
|
|||||||
throw new Error('osc type string must start with a ,');
|
throw new Error('osc type string must start with a ,');
|
||||||
}
|
}
|
||||||
let argsBuffer = bytesAfterType;
|
let argsBuffer = bytesAfterType;
|
||||||
|
let oscArrayArg: OSCArg[] = [];
|
||||||
|
let insideArgArray = false;
|
||||||
for (let index = 1; index < typeString.length; index++) {
|
for (let index = 1; index < typeString.length; index++) {
|
||||||
const argType = typeString.charAt(index) as OSCType;
|
const argType = typeString.charAt(index) as OSCType;
|
||||||
|
|
||||||
|
if (argType === '['){
|
||||||
|
if (insideArgArray){
|
||||||
|
throw new Error('osc arg array opened without closing previous arg array')
|
||||||
|
}
|
||||||
|
oscArrayArg = [];
|
||||||
|
insideArgArray = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argType === ']'){
|
||||||
|
if (!insideArgArray){
|
||||||
|
throw new Error('osc arg array closed without opening arg array')
|
||||||
|
}
|
||||||
|
oscArgs.push(oscArrayArg);
|
||||||
|
oscArrayArg = [];
|
||||||
|
insideArgArray = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const oscTypeConverter = oscTypeConverterMap[argType];
|
const oscTypeConverter = oscTypeConverterMap[argType];
|
||||||
if (oscTypeConverter === undefined) {
|
if (oscTypeConverter === undefined) {
|
||||||
throw new Error('unknown OSC type');
|
throw new Error('unknown OSC type');
|
||||||
@@ -74,15 +112,22 @@ export function messageFromBuffer(bytes: Uint8Array): [OSCMessage | undefined, U
|
|||||||
type: argType,
|
type: argType,
|
||||||
value: value,
|
value: value,
|
||||||
};
|
};
|
||||||
oscArgs.push(arg);
|
if(insideArgArray){
|
||||||
|
oscArrayArg.push(arg)
|
||||||
|
}else {
|
||||||
|
oscArgs.push(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
argsBuffer = remainingBytes;
|
argsBuffer = remainingBytes;
|
||||||
}
|
}
|
||||||
return [{
|
return [
|
||||||
address,
|
{
|
||||||
args: oscArgs,
|
address,
|
||||||
}, argsBuffer];
|
args: oscArgs,
|
||||||
|
},
|
||||||
|
argsBuffer,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [undefined, undefined]
|
return [undefined, undefined];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
export type OSCType = 's' | 'i' | 'f' | 'b' | 'T' | 'F' | 't';
|
export type OSCType = 's' | 'i' | 'f' | 'b' | 'T' | 'F' | 't' | 'r' | 'N' | '[' | ']';
|
||||||
export type OSCArg = {
|
export type OSCArg = {
|
||||||
type: OSCType;
|
type: OSCType;
|
||||||
value: string | number | Uint8Array | boolean | OSCTimeTag;
|
value: string | number | Uint8Array | boolean | OSCTimeTag | OSCColor | bigint | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OSCTimeTag = [number, number];
|
export type OSCTimeTag = [number, number];
|
||||||
|
|
||||||
|
export type OSCColor = {
|
||||||
|
r: number;
|
||||||
|
g: number;
|
||||||
|
b: number;
|
||||||
|
a: number;
|
||||||
|
};
|
||||||
|
|
||||||
export type OSCBundle = {
|
export type OSCBundle = {
|
||||||
timeTag: OSCTimeTag;
|
timeTag: OSCTimeTag;
|
||||||
contents: (OSCBundle | OSCMessage)[];
|
contents: (OSCBundle | OSCMessage)[];
|
||||||
@@ -13,10 +20,14 @@ export type OSCBundle = {
|
|||||||
|
|
||||||
export type OSCMessage = {
|
export type OSCMessage = {
|
||||||
address: string;
|
address: string;
|
||||||
args: OSCArg[];
|
args: (OSCArg | OSCArg[])[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OSCTypeConverter = {
|
export type OSCTypeConverter = {
|
||||||
toBuffer: (value: string | number | Uint8Array | boolean | OSCTimeTag) => Uint8Array | undefined;
|
toBuffer: (
|
||||||
fromBuffer: (buffer: Uint8Array) => [string | number | Uint8Array | boolean | OSCTimeTag | undefined, Uint8Array];
|
value: string | number | Uint8Array | boolean | OSCTimeTag | OSCColor | null | bigint
|
||||||
|
) => Uint8Array | undefined;
|
||||||
|
fromBuffer: (
|
||||||
|
buffer: Uint8Array
|
||||||
|
) => [string | number | Uint8Array | boolean | OSCTimeTag | OSCColor | null | bigint | undefined, Uint8Array];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
},
|
},
|
||||||
fromBuffer: (buffer) => {
|
fromBuffer: (buffer) => {
|
||||||
if (buffer.length < 8) {
|
if (buffer.length < 8) {
|
||||||
throw new Error('osc time tag must be greater than 8 bytes');
|
throw new Error('osc time tag must be at least 8 bytes');
|
||||||
}
|
}
|
||||||
const [seconds, bytesAfterSeconds] = oscTypeConverterMap.i.fromBuffer(buffer);
|
const [seconds, bytesAfterSeconds] = oscTypeConverterMap.i.fromBuffer(buffer);
|
||||||
const [fractional, bytesAfterFractional] = oscTypeConverterMap.i.fromBuffer(bytesAfterSeconds);
|
const [fractional, bytesAfterFractional] = oscTypeConverterMap.i.fromBuffer(bytesAfterSeconds);
|
||||||
@@ -171,4 +171,118 @@ export const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
return [undefined, bytesAfterFractional];
|
return [undefined, bytesAfterFractional];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
r: {
|
||||||
|
toBuffer: (color) => {
|
||||||
|
if (color === undefined || color === null) {
|
||||||
|
throw new TypeError('osc type r called with undefined or null value');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof color === 'object' && 'r' in color && 'g' in color && 'b' in color && 'a' in color) {
|
||||||
|
const view = new DataView(new ArrayBuffer(4));
|
||||||
|
|
||||||
|
view.setUint8(0, color.r);
|
||||||
|
view.setUint8(1, color.g);
|
||||||
|
view.setUint8(2, color.b);
|
||||||
|
view.setUint8(3, color.a);
|
||||||
|
|
||||||
|
return new Uint8Array(view.buffer);
|
||||||
|
}
|
||||||
|
throw new TypeError('osc type r called with non OSCColor object');
|
||||||
|
},
|
||||||
|
fromBuffer: (buffer) => {
|
||||||
|
if (buffer.length < 4) {
|
||||||
|
throw new Error('osc color must be at least 4 bytes');
|
||||||
|
}
|
||||||
|
|
||||||
|
const red = buffer[0];
|
||||||
|
const green = buffer[1];
|
||||||
|
const blue = buffer[2];
|
||||||
|
const alpha = buffer[3];
|
||||||
|
|
||||||
|
if (red !== undefined && green !== undefined && blue !== undefined && alpha !== undefined) {
|
||||||
|
if (
|
||||||
|
typeof red === 'number' &&
|
||||||
|
typeof green === 'number' &&
|
||||||
|
typeof blue === 'number' &&
|
||||||
|
typeof alpha === 'number'
|
||||||
|
) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
r: red,
|
||||||
|
g: green,
|
||||||
|
b: blue,
|
||||||
|
a: alpha,
|
||||||
|
},
|
||||||
|
buffer.subarray(4),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error('problem converting osc ');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
N: {
|
||||||
|
toBuffer: () => {
|
||||||
|
return new Uint8Array(0);
|
||||||
|
},
|
||||||
|
fromBuffer: (buffer) => {
|
||||||
|
return [null, buffer];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
I: {
|
||||||
|
toBuffer: () => {
|
||||||
|
return new Uint8Array();
|
||||||
|
},
|
||||||
|
fromBuffer: (buffer) => {
|
||||||
|
return [Number.MAX_SAFE_INTEGER, buffer];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
h: {
|
||||||
|
toBuffer: (number) => {
|
||||||
|
const view = new DataView(new ArrayBuffer(8));
|
||||||
|
|
||||||
|
if (typeof number === 'number') {
|
||||||
|
view.setBigInt64(0, BigInt(number));
|
||||||
|
} else if (typeof number === 'bigint') {
|
||||||
|
view.setBigInt64(0, number);
|
||||||
|
} else {
|
||||||
|
throw new TypeError('osc type h toBuffer called with non number or bigint value');
|
||||||
|
}
|
||||||
|
return new Uint8Array(view.buffer);
|
||||||
|
},
|
||||||
|
fromBuffer: (buffer) => {
|
||||||
|
if (buffer.length < 8) {
|
||||||
|
throw new Error('osc int64 must be at least 8 bytes');
|
||||||
|
}
|
||||||
|
|
||||||
|
const view = new DataView(new ArrayBuffer(8));
|
||||||
|
buffer.subarray(0, 8).forEach((byte, index) => {
|
||||||
|
view.setUint8(index, byte);
|
||||||
|
});
|
||||||
|
|
||||||
|
return [view.getBigInt64(0), buffer.subarray(8)];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
d: {
|
||||||
|
toBuffer: (number) => {
|
||||||
|
if (typeof number === 'number') {
|
||||||
|
const view = new DataView(new ArrayBuffer(8));
|
||||||
|
view.setFloat64(0, number);
|
||||||
|
return new Uint8Array(view.buffer);
|
||||||
|
}
|
||||||
|
throw new TypeError('osc type d toBuffer called with non number value');
|
||||||
|
},
|
||||||
|
fromBuffer: (buffer) => {
|
||||||
|
if (buffer.length < 8) {
|
||||||
|
throw new Error('not enough bytes to read a osc float');
|
||||||
|
}
|
||||||
|
const view = new DataView(new ArrayBuffer(8));
|
||||||
|
|
||||||
|
buffer.subarray(0, 8).forEach((byte, index) => {
|
||||||
|
view.setUint8(index, byte);
|
||||||
|
});
|
||||||
|
|
||||||
|
const value = view.getFloat64(0);
|
||||||
|
return [value, buffer.subarray(8)];
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,13 +20,79 @@ const tests = [
|
|||||||
contents: [{ address: '/oscillator/4/frequency', args: [{ type: 'f', value: 440 }] }],
|
contents: [{ address: '/oscillator/4/frequency', args: [{ type: 'f', value: 440 }] }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'resolume bundle example',
|
||||||
|
bytes: new Uint8Array([
|
||||||
|
0x23, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
0x28, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72,
|
||||||
|
0x73, 0x2f, 0x31, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x2c, 0x66, 0x00, 0x00, 0x3d,
|
||||||
|
0x6d, 0x9c, 0x9c, 0x00, 0x00, 0x00, 0x2c, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||||
|
0x2f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x70, 0x6f, 0x73, 0x69,
|
||||||
|
0x74, 0x69, 0x6f, 0x6e, 0x00, 0x2c, 0x66, 0x00, 0x00, 0x3d, 0x6d, 0x9c, 0x9c, 0x00, 0x00, 0x00, 0x3c, 0x2f, 0x63,
|
||||||
|
0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x2f, 0x31,
|
||||||
|
0x2f, 0x63, 0x6c, 0x69, 0x70, 0x73, 0x2f, 0x34, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f,
|
||||||
|
0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x66, 0x00, 0x00, 0x3d, 0x6d, 0x9c,
|
||||||
|
0x9c, 0x00, 0x00, 0x00, 0x38, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73,
|
||||||
|
0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x63, 0x6c, 0x69, 0x70, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f,
|
||||||
|
0x72, 0x74, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x66, 0x00, 0x00,
|
||||||
|
0x3d, 0x6d, 0x9c, 0x9c, 0x00, 0x00, 0x00, 0x28, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
|
||||||
|
0x6e, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x2f, 0x31, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||||
|
0x00, 0x00, 0x2c, 0x66, 0x00, 0x00, 0x3d, 0x6d, 0x9c, 0x9c, 0x00, 0x00, 0x00, 0x2c, 0x2f, 0x63, 0x6f, 0x6d, 0x70,
|
||||||
|
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x6c, 0x61, 0x79,
|
||||||
|
0x65, 0x72, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x2c, 0x66, 0x00, 0x00, 0x3d, 0x6d, 0x9c,
|
||||||
|
0x9c, 0x00, 0x00, 0x00, 0x3c, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6c,
|
||||||
|
0x61, 0x79, 0x65, 0x72, 0x73, 0x2f, 0x31, 0x2f, 0x63, 0x6c, 0x69, 0x70, 0x73, 0x2f, 0x34, 0x2f, 0x74, 0x72, 0x61,
|
||||||
|
0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x2c, 0x66, 0x00, 0x00, 0x3d, 0x6d, 0x9c, 0x9c, 0x00, 0x00, 0x00, 0x38, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73,
|
||||||
|
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x63, 0x6c, 0x69, 0x70, 0x2f,
|
||||||
|
0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x2c, 0x66, 0x00, 0x00, 0x3d, 0x6d, 0x9c, 0x9c,
|
||||||
|
]),
|
||||||
|
expected: {
|
||||||
|
timeTag: [0, 1],
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
address: '/composition/layers/1/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/selectedlayer/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/layers/1/clips/4/transport/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/selectedclip/transport/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/layers/1/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/selectedlayer/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/layers/1/clips/4/transport/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
address: '/composition/selectedclip/transport/position',
|
||||||
|
args: [{ type: 'f', value: 0.05801068246364593505859375 }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('OSC Bundle Decoding', () => {
|
describe('OSC Bundle Decoding', () => {
|
||||||
tests.forEach((bundleTest) => {
|
tests.forEach((bundleTest) => {
|
||||||
it(bundleTest.description, () => {
|
it(bundleTest.description, () => {
|
||||||
const [encoded, remainingBytes] = osc.bundleFromBuffer(bundleTest.bytes);
|
const [encoded, remainingBytes] = osc.bundleFromBuffer(bundleTest.bytes);
|
||||||
equal(remainingBytes.length, 0)
|
equal(remainingBytes.length, 0);
|
||||||
deepEqual(encoded, bundleTest.expected);
|
deepEqual(encoded, bundleTest.expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,40 @@ const tests = [
|
|||||||
bytes: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 70, 0, 0]),
|
bytes: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 70, 0, 0]),
|
||||||
expected: { address: '/hello', args: [{ type: 'F', value: false }] },
|
expected: { address: '/hello', args: [{ type: 'F', value: false }] },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address color arg',
|
||||||
|
bytes: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 114, 0, 0, 20, 21, 22, 10]),
|
||||||
|
expected: { address: '/hello', args: [{ type: 'r', value: { r: 20, g: 21, b: 22, a: 10 } }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address nil arg',
|
||||||
|
bytes: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 78, 0, 0]),
|
||||||
|
expected: { address: '/hello', args: [{ type: 'N', value: null }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address Inifinitum arg',
|
||||||
|
bytes: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 73, 0, 0]),
|
||||||
|
expected: { address: '/hello', args: [{ type: 'I', value: Number.MAX_SAFE_INTEGER }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address int64 arg',
|
||||||
|
bytes: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 104, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255]),
|
||||||
|
expected: { address: '/hello', args: [{ type: 'h', value: 281474976710655n }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address float64 arg',
|
||||||
|
bytes: new Uint8Array([
|
||||||
|
47, 104, 101, 108, 108, 111, 0, 0, 44, 100, 0, 0, 0x40, 0x29, 0x87, 0xec, 0x82, 0x74, 0xb9, 0xe6,
|
||||||
|
]),
|
||||||
|
expected: { address: '/hello', args: [{ type: 'd', value: 12.7654763 }] },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address array arg',
|
||||||
|
bytes: new Uint8Array([
|
||||||
|
47, 104, 101, 108, 108, 111, 0, 0, 44, 91, 100, 105, 93, 0, 0, 0, 0x40, 0x29, 0x87, 0xec, 0x82, 0x74, 0xb9, 0xe6, 0, 0, 3, 232
|
||||||
|
]),
|
||||||
|
expected: { address: '/hello', args: [[{ type: 'd', value: 12.7654763 }, { type: 'i', value: 1000}]] },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: 'osc 1.0 spec example 1',
|
description: 'osc 1.0 spec example 1',
|
||||||
bytes: new Uint8Array([
|
bytes: new Uint8Array([
|
||||||
@@ -70,7 +104,7 @@ describe('OSC Message Decoding', () => {
|
|||||||
tests.forEach((messageTest) => {
|
tests.forEach((messageTest) => {
|
||||||
it(messageTest.description, () => {
|
it(messageTest.description, () => {
|
||||||
const [decoded, remainingBytes] = osc.messageFromBuffer(messageTest.bytes);
|
const [decoded, remainingBytes] = osc.messageFromBuffer(messageTest.bytes);
|
||||||
equal(remainingBytes.length, 0)
|
equal(remainingBytes.length, 0);
|
||||||
deepEqual(decoded, messageTest.expected);
|
deepEqual(decoded, messageTest.expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,35 @@ const tests = [
|
|||||||
message: { address: '/hello', args: [{ type: 'F', value: false }] },
|
message: { address: '/hello', args: [{ type: 'F', value: false }] },
|
||||||
expected: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 70, 0, 0]),
|
expected: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 70, 0, 0]),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address color arg',
|
||||||
|
message: { address: '/hello', args: [{ type: 'r', value: { r: 20, g: 21, b: 22, a: 10 } }] },
|
||||||
|
expected: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 114, 0, 0, 20, 21, 22, 10]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address nil arg',
|
||||||
|
message: { address: '/hello', args: [{ type: 'N', value: null }] },
|
||||||
|
expected: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 78, 0, 0]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address int64 arg',
|
||||||
|
message: { address: '/hello', args: [{ type: 'h', value: 281474976710655n }] },
|
||||||
|
expected: new Uint8Array([47, 104, 101, 108, 108, 111, 0, 0, 44, 104, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address float64 arg',
|
||||||
|
message: { address: '/hello', args: [{ type: 'd', value: 12.7654763 }] },
|
||||||
|
expected: new Uint8Array([
|
||||||
|
47, 104, 101, 108, 108, 111, 0, 0, 44, 100, 0, 0, 0x40, 0x29, 0x87, 0xec, 0x82, 0x74, 0xb9, 0xe6,
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'simple address array arg',
|
||||||
|
message: { address: '/hello', args: [[{ type: 'd', value: 12.7654763 }, { type: 'i', value: 1000}]] },
|
||||||
|
expected: new Uint8Array([
|
||||||
|
47, 104, 101, 108, 108, 111, 0, 0, 44, 91, 100, 105, 93, 0, 0, 0, 0x40, 0x29, 0x87, 0xec, 0x82, 0x74, 0xb9, 0xe6, 0, 0, 3, 232
|
||||||
|
]),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: 'osc 1.0 spec example 1',
|
description: 'osc 1.0 spec example 1',
|
||||||
message: { address: '/oscillator/4/frequency', args: [{ type: 'f', value: 440 }] },
|
message: { address: '/oscillator/4/frequency', args: [{ type: 'f', value: 440 }] },
|
||||||
|
|||||||
Reference in New Issue
Block a user