@ircam/comote-helpers 0.3.3 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +5 -0
- package/.github/workflows/main.yml +3 -3
- package/.history/.gitignore_20250415160643 +6 -0
- package/.history/.gitignore_20250415160723 +6 -0
- package/.history/examples/simple-webview/package-lock_20250415130242.json +5109 -0
- package/.history/examples/simple-webview/package-lock_20250416103557.json +5109 -0
- package/.history/examples/simple-webview/package_20250415130704.json +26 -0
- package/.history/examples/simple-webview/package_20250415184837.json +26 -0
- package/.history/examples/simple-webview/package_20250415190300.json +23 -0
- package/.history/examples/simple-webview/src/server_20250415105733.js +20 -0
- package/.history/examples/simple-webview/src/server_20250415184604.js +20 -0
- package/.history/examples/soundworks/package_20250415132431.json +35 -0
- package/.history/examples/soundworks/package_20250416105956.json +35 -0
- package/.history/max/CoMote/examples/simple-webview/package_20250415184836.json +26 -0
- package/.history/max/CoMote/examples/simple-webview/package_20250415185949.json +23 -0
- package/.history/max/CoMote/examples/simple-webview/package_20250415185950.json +23 -0
- package/.history/max/CoMote/package-info_20241018173608.json +41 -0
- package/.history/max/CoMote/package-info_20250416105743.json +27 -0
- package/.history/max/CoMote/package-info_20250416105826.json +27 -0
- package/.history/max/CoMote/source/comote-connect/package_20250415132759.json +19 -0
- package/.history/max/CoMote/source/comote-connect/package_20250416110158.json +19 -0
- package/.history/max/CoMote/source/comote-connect/server_20250414175059.js +193 -0
- package/.history/max/CoMote/source/comote-connect/server_20250415180549.js +193 -0
- package/.history/package_20250415143437.json +26 -0
- package/.history/package_20250416105907.json +26 -0
- package/LICENSE +2 -2
- package/examples/simple-webview/README.md +10 -0
- package/examples/simple-webview/build/comote-simple-webview-server.js +44 -0
- package/examples/simple-webview/package-lock.json +5109 -0
- package/examples/simple-webview/package.json +23 -0
- package/examples/simple-webview/public/favicon.ico +0 -0
- package/examples/simple-webview/public/index.html +13 -0
- package/examples/simple-webview/public/index.mjs +3623 -0
- package/examples/simple-webview/public/styles.css +99 -0
- package/examples/simple-webview/src/client.js +35 -0
- package/examples/simple-webview/src/server.js +20 -0
- package/examples/soundworks/.build/clients/components/sw-audit.js +64 -0
- package/examples/soundworks/.build/clients/components/sw-audit.js.map +1 -0
- package/examples/soundworks/.build/clients/components/sw-credits.js +73 -0
- package/examples/soundworks/.build/clients/components/sw-credits.js.map +1 -0
- package/examples/soundworks/.build/clients/player/.editorbackup/PlayerExperience.js~ +131 -0
- package/examples/soundworks/.build/clients/player/index.js +116 -0
- package/examples/soundworks/.build/clients/player/index.js.map +1 -0
- package/examples/soundworks/.build/clients/styles/app.scss +79 -0
- package/examples/soundworks/.build/clients/styles/normalize.scss +359 -0
- package/examples/soundworks/.build/clients/webview/index.js +72 -0
- package/examples/soundworks/.build/clients/webview/index.js.map +1 -0
- package/examples/soundworks/.build/public/css/app.css +76 -0
- package/examples/soundworks/.build/public/css/app.css.map +1 -0
- package/examples/soundworks/.build/public/css/normalize.css +321 -0
- package/examples/soundworks/.build/public/css/normalize.css.map +1 -0
- package/examples/soundworks/.build/public/player.js +98098 -0
- package/examples/soundworks/.build/public/player.js.map +1 -0
- package/examples/soundworks/.build/public/webview.js +50725 -0
- package/examples/soundworks/.build/public/webview.js.map +1 -0
- package/examples/soundworks/.build/server/index.js +57 -0
- package/examples/soundworks/.build/server/index.js.map +1 -0
- package/examples/soundworks/.build/server/schemas/.gitkeep +1 -0
- package/examples/soundworks/.build/server/schemas/global.js +19 -0
- package/examples/soundworks/.build/server/schemas/global.js.map +1 -0
- package/examples/soundworks/.build/server/tmpl/default.tmpl +27 -0
- package/examples/soundworks/.build/utils/catch-unhandled-errors.js +9 -0
- package/examples/soundworks/.build/utils/catch-unhandled-errors.js.map +1 -0
- package/examples/soundworks/.editorconfig +12 -0
- package/examples/soundworks/.eslintrc +3 -0
- package/examples/soundworks/.soundworks +7 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/CHANGELOG.md +76 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/LICENSE.md +19 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/README.md +259 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-ce.js +63 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-ce.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_dom.js +62 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_dom.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_js.js +95 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-pf_js.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js +374 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce.js +240 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd-ce.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd.js +196 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/bundles/webcomponents-sd.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/custom-elements-es5-adapter.js +15 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/package.json +51 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/custom-elements-es5-adapter-index.js +16 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-bundle-index.js +55 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-ce-index.js +17 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-pf_dom-index.js +19 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-pf_js-index.js +13 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-index.js +19 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-pf-index.js +25 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/entrypoints/webcomponents-sd-index.js +18 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/flag-parser.js +69 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/baseuri.js +28 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/after.js +47 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/before.js +40 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/index.js +14 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/remove.js +37 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/child-node/replace-with.js +42 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/custom-event.js +79 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/es6-misc.js +38 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/event-listener-options.js +122 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/get-attribute-names.js +27 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/matches.js +21 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/append.js +31 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/index.js +13 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/prepend.js +42 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/parent-node/replace-children.js +45 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/promise.js +50 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/svg-element-class-list.js +28 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/symbol.js +64 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/platform/toggle-attribute.js +39 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/src/unresolved.js +32 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-bundle.d.ts +175 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-bundle.js +384 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-bundle.js.map +1 -0
- package/examples/soundworks/.vendors/public/webcomponentsjs/webcomponents-loader.js +238 -0
- package/examples/soundworks/LICENSE +28 -0
- package/examples/soundworks/README.md +26 -0
- package/examples/soundworks/config/application.yaml +8 -0
- package/examples/soundworks/config/env-default.yaml +12 -0
- package/examples/soundworks/package.json +35 -0
- package/examples/soundworks/public/favicon.ico +0 -0
- package/examples/soundworks/public/images/loader.gif +0 -0
- package/examples/soundworks/src/clients/components/sw-audit.js +78 -0
- package/examples/soundworks/src/clients/components/sw-credits.js +80 -0
- package/examples/soundworks/src/clients/player/.editorbackup/PlayerExperience.js~ +131 -0
- package/examples/soundworks/src/clients/player/index.js +118 -0
- package/examples/soundworks/src/clients/styles/app.scss +79 -0
- package/examples/soundworks/src/clients/styles/normalize.scss +359 -0
- package/examples/soundworks/src/clients/webview/index.js +78 -0
- package/examples/soundworks/src/server/index.js +62 -0
- package/examples/soundworks/src/server/schemas/.gitkeep +1 -0
- package/examples/soundworks/src/server/schemas/global.js +18 -0
- package/examples/soundworks/src/server/tmpl/default.tmpl +27 -0
- package/examples/soundworks/src/utils/catch-unhandled-errors.js +9 -0
- package/index.html +51 -0
- package/max/CoMote/docs/sw.shared-state.maxref.xml +95 -0
- package/max/CoMote/examples/simple-webview/README.md +10 -0
- package/max/CoMote/examples/simple-webview/build/comote-simple-webview-server.js +44 -0
- package/max/CoMote/examples/simple-webview/comote-simple-webview-server.maxpat +186 -0
- package/max/CoMote/examples/simple-webview/package-lock.json +5109 -0
- package/max/CoMote/examples/simple-webview/package.json +23 -0
- package/max/CoMote/examples/simple-webview/public/favicon.ico +0 -0
- package/max/CoMote/examples/simple-webview/public/index.html +13 -0
- package/max/CoMote/examples/simple-webview/public/index.mjs +3623 -0
- package/max/CoMote/examples/simple-webview/public/styles.css +99 -0
- package/max/CoMote/examples/simple-webview/src/client.js +35 -0
- package/max/CoMote/examples/simple-webview/src/server.js +20 -0
- package/max/CoMote/examples/soundworks/.editorconfig +12 -0
- package/max/CoMote/examples/soundworks/.eslintrc +3 -0
- package/max/CoMote/examples/soundworks/.soundworks +7 -0
- package/max/CoMote/examples/soundworks/LICENSE +28 -0
- package/max/CoMote/examples/soundworks/README.md +26 -0
- package/max/CoMote/examples/soundworks/config/application.yaml +8 -0
- package/max/CoMote/examples/soundworks/config/env-default.yaml +12 -0
- package/max/CoMote/examples/soundworks/package.json +35 -0
- package/max/CoMote/examples/soundworks/public/favicon.ico +0 -0
- package/max/CoMote/examples/soundworks/public/images/loader.gif +0 -0
- package/max/CoMote/examples/soundworks/src/clients/components/sw-audit.js +78 -0
- package/max/CoMote/examples/soundworks/src/clients/components/sw-credits.js +80 -0
- package/max/CoMote/examples/soundworks/src/clients/player/.editorbackup/PlayerExperience.js~ +131 -0
- package/max/CoMote/examples/soundworks/src/clients/player/index.js +118 -0
- package/max/CoMote/examples/soundworks/src/clients/styles/app.scss +79 -0
- package/max/CoMote/examples/soundworks/src/clients/styles/normalize.scss +359 -0
- package/max/CoMote/examples/soundworks/src/clients/webview/index.js +78 -0
- package/max/CoMote/examples/soundworks/src/server/index.js +62 -0
- package/max/CoMote/examples/soundworks/src/server/schemas/.gitkeep +1 -0
- package/max/CoMote/examples/soundworks/src/server/schemas/global.js +18 -0
- package/max/CoMote/examples/soundworks/src/server/tmpl/default.tmpl +27 -0
- package/max/CoMote/examples/soundworks/src/utils/catch-unhandled-errors.js +9 -0
- package/max/CoMote/extras/CoMote.maxpat +1994 -0
- package/max/CoMote/help/comote_osc_receive.maxhelp +946 -0
- package/max/CoMote/icon.png +0 -0
- package/max/CoMote/init/objectmappings.txt +2 -0
- package/max/CoMote/media/comote-screenshot.png +0 -0
- package/max/CoMote/package-info.json +27 -0
- package/max/CoMote/patchers/comote-connect/comote-connect-public/comote-connect-client.mjs +2821 -0
- package/max/CoMote/patchers/comote-connect/comote-connect-public/favicon.ico +0 -0
- package/max/CoMote/patchers/comote-connect/comote-connect-public/index.html +22 -0
- package/max/CoMote/patchers/comote-connect/comote-connect-server.js +24775 -0
- package/max/CoMote/patchers/comote-connect/comote-connect.maxpat +1048 -0
- package/max/CoMote/patchers/comote-connect/package.json +4 -0
- package/max/CoMote/patchers/comote_format_from_comote_v2.maxpat +613 -0
- package/max/CoMote/patchers/comote_format_from_v3.maxpat +443 -0
- package/max/CoMote/patchers/comote_format_gyro_v2_to_v3.maxpat +240 -0
- package/max/CoMote/patchers/comote_format_gyro_v3_to_v2.maxpat +240 -0
- package/max/CoMote/patchers/comote_format_heading_v2_to_v3.maxpat +171 -0
- package/max/CoMote/patchers/comote_osc_receive.maxpat +440 -0
- package/max/CoMote/patchers/comote_osc_to_list.maxpat +161 -0
- package/max/CoMote/readme.md +22 -0
- package/max/CoMote/source/comote-connect/client.js +104 -0
- package/max/CoMote/source/comote-connect/package-lock.json +591 -0
- package/max/CoMote/source/comote-connect/package.json +19 -0
- package/max/CoMote/source/comote-connect/server.js +193 -0
- package/max-update.bash +44 -0
- package/package.json +10 -29
- package/src/.editorbackup/network-infos.js~ +60 -0
- package/src/.editorbackup/wifi-infos.js~ +33 -0
- package/{network-infos.js → src/network-infos.js} +25 -16
- package/{qrcode.js → src/qrcode.js} +32 -30
- package/{server.js → src/server.js} +60 -47
- package/{wifi-infos.js → src/wifi-infos.js} +8 -12
- package/README.md +0 -160
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _nodeOsc = require("node-osc");
|
|
10
|
-
var _cloneDeep = _interopRequireDefault(require("clone-deep"));
|
|
11
|
-
var _assignDeep = _interopRequireDefault(require("assign-deep"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import { WebSocketServer } from 'ws';
|
|
2
|
+
import isValidUTF8 from 'utf-8-validate';
|
|
3
|
+
import { Server as OscServer } from 'node-osc';
|
|
4
|
+
import cloneDeep from 'clone-deep';
|
|
5
|
+
import assignDeep from 'assign-deep';
|
|
6
|
+
|
|
7
|
+
console.log(WebSocket);
|
|
8
|
+
|
|
13
9
|
/**
|
|
14
10
|
* @typedef {Object} CoMoteConfig
|
|
15
|
-
* @property {String} id - id of the client
|
|
16
|
-
* @property {Number} interval - period in ms of the sensors for the client
|
|
11
|
+
* @property {String} id - id of the client CoMote
|
|
12
|
+
* @property {Number} interval - period in ms of the sensors for the client CoMote
|
|
17
13
|
* @property {CoMoteTarget} osc - OSC configuration
|
|
18
14
|
* @property {CoMoteTarget} ws - WebSocket configuration
|
|
19
15
|
*/
|
|
@@ -22,9 +18,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
22
18
|
* @typedef {Object} CoMoteTarget
|
|
23
19
|
* @property {String} hostname - hostname or ip of the WebSocket or OSC server
|
|
24
20
|
* @property {Number} port - listening port of the of the WebSocket or OSC server
|
|
25
|
-
* @property {Boolean} autostart - enable streaming on
|
|
21
|
+
* @property {Boolean} autostart - enable streaming on CoMote application
|
|
26
22
|
*/
|
|
27
23
|
|
|
24
|
+
|
|
28
25
|
/**
|
|
29
26
|
* Launch WebSocket and/or OSC server according to given `CoMoteConfig` object
|
|
30
27
|
*
|
|
@@ -32,57 +29,60 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
32
29
|
* @param {Object} options - options
|
|
33
30
|
* @param {Object} [options.verbose=false] - logs debug informations
|
|
34
31
|
*/
|
|
35
|
-
class Server {
|
|
32
|
+
export class Server {
|
|
36
33
|
constructor(config, options) {
|
|
37
34
|
/**
|
|
38
35
|
* Configuration of the CoMote server
|
|
39
36
|
*/
|
|
40
|
-
this.config = (
|
|
37
|
+
this.config = cloneDeep(assignDeep({
|
|
41
38
|
id: null,
|
|
42
39
|
interval: null,
|
|
43
40
|
osc: null,
|
|
44
41
|
ws: null,
|
|
45
|
-
verbose: false
|
|
42
|
+
verbose: false,
|
|
46
43
|
}, config));
|
|
44
|
+
|
|
47
45
|
this._verbose = !!options.verbose;
|
|
46
|
+
|
|
48
47
|
if (this._verbose) {
|
|
49
|
-
console.log('+
|
|
48
|
+
console.log('+ CoMote config:');
|
|
50
49
|
console.log(this.config, '\n');
|
|
51
50
|
}
|
|
51
|
+
|
|
52
52
|
this._websocketServer = null;
|
|
53
53
|
this._oscServer = null;
|
|
54
|
+
|
|
54
55
|
this._wsListeners = new Set();
|
|
55
56
|
this._oscListeners = new Set();
|
|
56
57
|
}
|
|
58
|
+
|
|
57
59
|
async start() {
|
|
58
60
|
let wsPromise = true;
|
|
59
61
|
let oscPromise = true;
|
|
62
|
+
|
|
60
63
|
if (this.config.ws !== null) {
|
|
61
|
-
const {
|
|
62
|
-
|
|
63
|
-
port
|
|
64
|
-
} = this.config.ws;
|
|
64
|
+
const { hostname, port } = this.config.ws;
|
|
65
|
+
|
|
65
66
|
if (!Number.isInteger(port)) {
|
|
66
67
|
throw new Error(`Invalid port "${port}" for WebSocket server`);
|
|
67
68
|
}
|
|
69
|
+
|
|
68
70
|
if (this._verbose) {
|
|
69
|
-
console.log(`>
|
|
71
|
+
console.log(`> CoMote: Launching WebSocket server on port: ${port}`);
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
const sockets = new Map();
|
|
73
|
+
|
|
74
|
+
this._websocketServer = new WebSocketServer({ port });
|
|
75
75
|
this._websocketServer.on('connection', (socket, request) => {
|
|
76
76
|
// const ip = request.socket.remoteAddress;
|
|
77
77
|
socket.on('message', (data, isBinary) => {
|
|
78
78
|
if (isBinary) {
|
|
79
79
|
// @todo
|
|
80
80
|
} else {
|
|
81
|
-
if ((
|
|
82
|
-
// do we really need this check?
|
|
81
|
+
if (isValidUTF8(data)) { // do we really need this check?
|
|
83
82
|
data = JSON.parse(data);
|
|
83
|
+
|
|
84
84
|
if (this._verbose) {
|
|
85
|
-
console.log(`>
|
|
85
|
+
console.log(`> CoMote: new WebSocket message`, data);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// console.log(data);
|
|
@@ -95,28 +95,30 @@ class Server {
|
|
|
95
95
|
// When a socket closes, or disconnects, remove it from the array.
|
|
96
96
|
socket.on('close', (code, data) => {
|
|
97
97
|
if (this._verbose) {
|
|
98
|
-
console.log('>
|
|
98
|
+
console.log('> CoMote: closed socket connection');
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
|
+
|
|
102
103
|
wsPromise = new Promise((resolve, reject) => {
|
|
103
104
|
this._websocketServer.on('listening', () => {
|
|
104
105
|
if (this._verbose) {
|
|
105
|
-
console.log(`>
|
|
106
|
+
console.log(`> CoMote: WebSocket server listening`);
|
|
106
107
|
}
|
|
108
|
+
|
|
107
109
|
resolve();
|
|
108
110
|
});
|
|
111
|
+
|
|
109
112
|
this._websocketServer.on('error', err => {
|
|
110
|
-
console.log(`>
|
|
113
|
+
console.log(`> CoMote: WebSocket server error`, err);
|
|
111
114
|
reject(err);
|
|
112
115
|
});
|
|
113
116
|
});
|
|
114
117
|
}
|
|
118
|
+
|
|
115
119
|
if (this.config.osc !== null) {
|
|
116
|
-
const {
|
|
117
|
-
|
|
118
|
-
port
|
|
119
|
-
} = this.config.osc;
|
|
120
|
+
const { hostname, port } = this.config.osc;
|
|
121
|
+
|
|
120
122
|
if (!Number.isInteger(port)) {
|
|
121
123
|
throw new Error(`Invalid port "${port}" for OSC server`);
|
|
122
124
|
}
|
|
@@ -125,46 +127,57 @@ class Server {
|
|
|
125
127
|
if (!hostname) {
|
|
126
128
|
hostname = '0.0.0.0';
|
|
127
129
|
}
|
|
130
|
+
|
|
128
131
|
if (this._verbose) {
|
|
129
|
-
console.log(`>
|
|
132
|
+
console.log(`> CoMote: Launching OSC server udp://${hostname}:${port}`);
|
|
130
133
|
}
|
|
134
|
+
|
|
131
135
|
oscPromise = new Promise((resolve, reject) => {
|
|
132
|
-
this._oscServer = new
|
|
136
|
+
this._oscServer = new OscServer(this.config.osc.port, hostname, err => {
|
|
133
137
|
if (err) {
|
|
134
|
-
console.log(`>
|
|
138
|
+
console.log(`> CoMote: OSC server error`, err);
|
|
135
139
|
reject();
|
|
136
140
|
return;
|
|
137
141
|
}
|
|
142
|
+
|
|
138
143
|
if (this._verbose) {
|
|
139
|
-
console.log(`>
|
|
144
|
+
console.log(`> CoMote: OSC server listening`);
|
|
140
145
|
}
|
|
146
|
+
|
|
141
147
|
resolve();
|
|
142
148
|
});
|
|
149
|
+
|
|
143
150
|
this._oscServer.on('message', data => {
|
|
144
151
|
let address = data.shift();
|
|
152
|
+
|
|
145
153
|
if (this._verbose) {
|
|
146
|
-
console.log(`>
|
|
154
|
+
console.log(`> CoMote: new OSC message "${address}":`, data);
|
|
147
155
|
}
|
|
156
|
+
|
|
148
157
|
this._oscListeners.forEach(callback => callback(address, data));
|
|
149
158
|
});
|
|
150
159
|
});
|
|
151
160
|
}
|
|
161
|
+
|
|
152
162
|
return Promise.all([wsPromise, oscPromise]);
|
|
153
163
|
}
|
|
164
|
+
|
|
154
165
|
async stop() {
|
|
155
166
|
if (this._websocketServer) {
|
|
156
167
|
this._websocketServer.close();
|
|
157
168
|
}
|
|
169
|
+
|
|
158
170
|
if (this._oscServer) {
|
|
159
171
|
this._oscServer.close();
|
|
160
172
|
}
|
|
161
173
|
}
|
|
162
174
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Add a listener for incomming WebSocket message
|
|
177
|
+
*/
|
|
166
178
|
addWsListener(callback) {
|
|
167
179
|
this._wsListeners.add(callback);
|
|
180
|
+
|
|
168
181
|
return () => this._wsListeners.delete(callback);
|
|
169
182
|
}
|
|
170
183
|
|
|
@@ -180,6 +193,7 @@ class Server {
|
|
|
180
193
|
*/
|
|
181
194
|
addOscListener(callback) {
|
|
182
195
|
this._oscListeners.add(callback);
|
|
196
|
+
|
|
183
197
|
return () => this._oscListeners.delete(callback);
|
|
184
198
|
}
|
|
185
199
|
|
|
@@ -190,4 +204,3 @@ class Server {
|
|
|
190
204
|
this._oscListeners.delete(callback);
|
|
191
205
|
}
|
|
192
206
|
}
|
|
193
|
-
exports.Server = Server;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import si from 'systeminformation';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getWifiInfos = getWifiInfos;
|
|
7
|
-
var _systeminformation = _interopRequireDefault(require("systeminformation"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
3
|
/**
|
|
10
4
|
* @typedef {Object} WifiInfos
|
|
11
5
|
* @property {number} ssid - SSID of the WiFi connection
|
|
@@ -19,19 +13,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
13
|
* @async
|
|
20
14
|
* @return {WiFiInfos|null}
|
|
21
15
|
*/
|
|
22
|
-
async function getWifiInfos() {
|
|
16
|
+
export async function getWifiInfos() {
|
|
23
17
|
// find first wifi connection
|
|
24
|
-
const wifiConnections = await
|
|
18
|
+
const wifiConnections = await si.wifiConnections();
|
|
25
19
|
const conn = wifiConnections[0];
|
|
20
|
+
|
|
26
21
|
if (!conn) {
|
|
27
22
|
return null;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
// find related interface
|
|
31
|
-
const interfaces = await
|
|
26
|
+
const interfaces = await si.networkInterfaces();
|
|
32
27
|
const int = interfaces.find(int => int.iface === conn.iface);
|
|
28
|
+
|
|
33
29
|
return {
|
|
34
30
|
ssid: conn.ssid,
|
|
35
|
-
ip: int.ip4
|
|
31
|
+
ip: int.ip4,
|
|
36
32
|
};
|
|
37
|
-
}
|
|
33
|
+
}
|
package/README.md
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# `CoMo.te helpers`
|
|
2
|
-
|
|
3
|
-
> Javascript and Max/MSP utilities to create applications compatible with iPhone
|
|
4
|
-
> and Android `CoMo.te` application, cf. [https://ismm-apps.ircam.fr/comote](https://ismm-apps.ircam.fr/comote).
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
The CoMo.te application (iOS and Android) allows for streaming motion data (accelerometer, gyroscope) from the smartphone to desktop applications using either the OSC or Websockets protocols. The network's setup is facilitated by the use of a QR code generated by the targeted remote application receiving the motion sensor data.
|
|
8
|
-
|
|
9
|
-
CoMo.te is especially designed for the CoMo applications family that enables real-time interaction between gestures/movements and sounds. Nevertheless, the CoMo.te application can be used with any software that makes use of the OSC protocol.
|
|
10
|
-
|
|
11
|
-
Among the CoMo applications that make use of CoMo.te are CoMo-Vox to learn and train conducting gestures, and CoMo-Elements to interact collectively thought body movements with recorded sounds.
|
|
12
|
-
|
|
13
|
-
CoMo.te and the CoMo applications are software designed and developed by IRCAM in the Sound-Music-Movement-Interaction team (UMR STMS).
|
|
14
|
-
|
|
15
|
-
This repository provides utilities to help to generate the QRCode in the target application both for Max/MSP and Node.js.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Table of Contents
|
|
20
|
-
|
|
21
|
-
<!-- toc -->
|
|
22
|
-
|
|
23
|
-
- [Max/MSP](#maxmsp)
|
|
24
|
-
- [JS](#js)
|
|
25
|
-
* [Node.js](#nodejs)
|
|
26
|
-
* [API](#api)
|
|
27
|
-
- [License](#license)
|
|
28
|
-
|
|
29
|
-
<!-- tocstop -->
|
|
30
|
-
|
|
31
|
-
## Max/MSP
|
|
32
|
-
|
|
33
|
-
Download the Max abstraction (i.e. CoMo.te.zip) from the lastest release in the releases page: https://github.com/ircam-ismm/comote-helpers/releases
|
|
34
|
-
Unzip the package and copy the resulting directory in `~/Documents/Max 8/Packages`
|
|
35
|
-
|
|
36
|
-
For now, the package only provide abstraction `[comote.connect]` that allows you to generate a QRCode that can be
|
|
37
|
-
flashed within the CoMo.te application to configure the OSC stream.
|
|
38
|
-
|
|
39
|
-
You can find more informations in the Helper patch: `~/Document/Max 8/Packages/CoMo.te/extras/CoMo.te.maxpat`
|
|
40
|
-
|
|
41
|
-
This version requires Max 7.1 or higher.
|
|
42
|
-
|
|
43
|
-
## JS
|
|
44
|
-
|
|
45
|
-
### Node.js
|
|
46
|
-
|
|
47
|
-
```sh
|
|
48
|
-
npm install --save @ircam/comote-helpers
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### API
|
|
52
|
-
|
|
53
|
-
<!-- api -->
|
|
54
|
-
|
|
55
|
-
#### Classes
|
|
56
|
-
|
|
57
|
-
<dl>
|
|
58
|
-
<dt><a href="#Server">Server</a></dt>
|
|
59
|
-
<dd><p>Launch WebSocket and/or OSC server according to given <code>CoMoteConfig</code> object</p>
|
|
60
|
-
</dd>
|
|
61
|
-
</dl>
|
|
62
|
-
|
|
63
|
-
#### Functions
|
|
64
|
-
|
|
65
|
-
<dl>
|
|
66
|
-
<dt><a href="#rawLink">rawLink()</a></dt>
|
|
67
|
-
<dd><p>Return the link to be encoded in the QRCode accroding to given <code>CoMoteConfig</code></p>
|
|
68
|
-
</dd>
|
|
69
|
-
<dt><a href="#terminal">terminal(config)</a></dt>
|
|
70
|
-
<dd><p>Create a qrcode to be logged in terminal according to given `CoMoteConfig``</p>
|
|
71
|
-
</dd>
|
|
72
|
-
<dt><a href="#dataURL">dataURL(config)</a></dt>
|
|
73
|
-
<dd><p>Create a qrcode to be used as in Image source according to given `CoMoteConfig``</p>
|
|
74
|
-
</dd>
|
|
75
|
-
</dl>
|
|
76
|
-
|
|
77
|
-
#### Typedefs
|
|
78
|
-
|
|
79
|
-
<dl>
|
|
80
|
-
<dt><a href="#CoMoteConfig">CoMoteConfig</a> : <code>Object</code></dt>
|
|
81
|
-
<dd></dd>
|
|
82
|
-
<dt><a href="#CoMoteTarget">CoMoteTarget</a> : <code>Object</code></dt>
|
|
83
|
-
<dd></dd>
|
|
84
|
-
</dl>
|
|
85
|
-
|
|
86
|
-
<a name="rawLink"></a>
|
|
87
|
-
|
|
88
|
-
#### rawLink()
|
|
89
|
-
Return the link to be encoded in the QRCode accroding to given `CoMoteConfig`
|
|
90
|
-
|
|
91
|
-
**Kind**: global function
|
|
92
|
-
<a name="terminal"></a>
|
|
93
|
-
|
|
94
|
-
#### terminal(config)
|
|
95
|
-
Create a qrcode to be logged in terminal according to given `CoMoteConfig``
|
|
96
|
-
|
|
97
|
-
**Kind**: global function
|
|
98
|
-
|
|
99
|
-
| Param | Type |
|
|
100
|
-
| --- | --- |
|
|
101
|
-
| config | [<code>CoMoteConfig</code>](#CoMoteConfig) |
|
|
102
|
-
|
|
103
|
-
**Example**
|
|
104
|
-
```js
|
|
105
|
-
console(await CoMoteQRCode.terminal(config));
|
|
106
|
-
```
|
|
107
|
-
<a name="dataURL"></a>
|
|
108
|
-
|
|
109
|
-
#### dataURL(config)
|
|
110
|
-
Create a qrcode to be used as in Image source according to given `CoMoteConfig``
|
|
111
|
-
|
|
112
|
-
**Kind**: global function
|
|
113
|
-
|
|
114
|
-
| Param | Type |
|
|
115
|
-
| --- | --- |
|
|
116
|
-
| config | [<code>CoMoteConfig</code>](#CoMoteConfig) |
|
|
117
|
-
|
|
118
|
-
**Example**
|
|
119
|
-
```js
|
|
120
|
-
const qrCode = await CoMoteQRCode.dataURL(config));
|
|
121
|
-
|
|
122
|
-
<img src="${qrCode}" />
|
|
123
|
-
```
|
|
124
|
-
<a name="CoMoteConfig"></a>
|
|
125
|
-
|
|
126
|
-
#### CoMoteConfig : <code>Object</code>
|
|
127
|
-
**Kind**: global typedef
|
|
128
|
-
**Properties**
|
|
129
|
-
|
|
130
|
-
| Name | Type | Description |
|
|
131
|
-
| --- | --- | --- |
|
|
132
|
-
| id | <code>String</code> | id of the client CoMo.te |
|
|
133
|
-
| interval | <code>Number</code> | period in ms of the sensors for the client CoMo.te |
|
|
134
|
-
| osc | [<code>CoMoteTarget</code>](#CoMoteTarget) | OSC configuration |
|
|
135
|
-
| ws | [<code>CoMoteTarget</code>](#CoMoteTarget) | WebSocket configuration |
|
|
136
|
-
|
|
137
|
-
<a name="CoMoteTarget"></a>
|
|
138
|
-
|
|
139
|
-
#### CoMoteTarget : <code>Object</code>
|
|
140
|
-
**Kind**: global typedef
|
|
141
|
-
**Properties**
|
|
142
|
-
|
|
143
|
-
| Name | Type | Description |
|
|
144
|
-
| --- | --- | --- |
|
|
145
|
-
| hostname | <code>String</code> | hostname or ip of the WebSocket or OSC server |
|
|
146
|
-
| port | <code>Number</code> | listening port of the of the WebSocket or OSC server |
|
|
147
|
-
| autostart | <code>Boolean</code> | enable streaming on CoMo.te application |
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<!-- apistop -->
|
|
151
|
-
|
|
152
|
-
## Credits
|
|
153
|
-
|
|
154
|
-
CoMo.te is developed by Ircam and the Music and Sound Science and Technology Joint Research Unit (STMS), supported by Ircam, CNRS, the French Ministry of Culture and Sorbonne University.
|
|
155
|
-
|
|
156
|
-
Produced with the support of the French Ministry of Education, Youth and Sports (Edu-up system), the National Research Agency (ELEMENT project), and in partnership with Radio France.
|
|
157
|
-
|
|
158
|
-
## License
|
|
159
|
-
|
|
160
|
-
BSD-3-Clause
|