@ircam/comote-helpers 0.3.1 → 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/src/network-infos.js +67 -0
- package/{qrcode.js → src/qrcode.js} +26 -40
- package/{server.js → src/server.js} +45 -69
- package/src/wifi-infos.js +33 -0
- package/README.md +0 -160
- package/wifi-infos.js +0 -41
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
|
|
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';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Server = void 0;
|
|
7
|
-
|
|
8
|
-
var _ws = _interopRequireDefault(require("ws"));
|
|
9
|
-
|
|
10
|
-
var _utf8Validate = _interopRequireDefault(require("utf-8-validate"));
|
|
11
|
-
|
|
12
|
-
var _nodeOsc = require("node-osc");
|
|
13
|
-
|
|
14
|
-
var _cloneDeep = _interopRequireDefault(require("clone-deep"));
|
|
15
|
-
|
|
16
|
-
var _assignDeep = _interopRequireDefault(require("assign-deep"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
console.log(WebSocket);
|
|
19
8
|
|
|
20
9
|
/**
|
|
21
10
|
* @typedef {Object} CoMoteConfig
|
|
22
|
-
* @property {String} id - id of the client
|
|
23
|
-
* @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
|
|
24
13
|
* @property {CoMoteTarget} osc - OSC configuration
|
|
25
14
|
* @property {CoMoteTarget} ws - WebSocket configuration
|
|
26
15
|
*/
|
|
@@ -29,9 +18,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
29
18
|
* @typedef {Object} CoMoteTarget
|
|
30
19
|
* @property {String} hostname - hostname or ip of the WebSocket or OSC server
|
|
31
20
|
* @property {Number} port - listening port of the of the WebSocket or OSC server
|
|
32
|
-
* @property {Boolean} autostart - enable streaming on
|
|
21
|
+
* @property {Boolean} autostart - enable streaming on CoMote application
|
|
33
22
|
*/
|
|
34
23
|
|
|
24
|
+
|
|
35
25
|
/**
|
|
36
26
|
* Launch WebSocket and/or OSC server according to given `CoMoteConfig` object
|
|
37
27
|
*
|
|
@@ -39,27 +29,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
39
29
|
* @param {Object} options - options
|
|
40
30
|
* @param {Object} [options.verbose=false] - logs debug informations
|
|
41
31
|
*/
|
|
42
|
-
class Server {
|
|
32
|
+
export class Server {
|
|
43
33
|
constructor(config, options) {
|
|
44
34
|
/**
|
|
45
35
|
* Configuration of the CoMote server
|
|
46
36
|
*/
|
|
47
|
-
this.config = (
|
|
37
|
+
this.config = cloneDeep(assignDeep({
|
|
48
38
|
id: null,
|
|
49
39
|
interval: null,
|
|
50
40
|
osc: null,
|
|
51
41
|
ws: null,
|
|
52
|
-
verbose: false
|
|
42
|
+
verbose: false,
|
|
53
43
|
}, config));
|
|
44
|
+
|
|
54
45
|
this._verbose = !!options.verbose;
|
|
55
46
|
|
|
56
47
|
if (this._verbose) {
|
|
57
|
-
console.log('+
|
|
48
|
+
console.log('+ CoMote config:');
|
|
58
49
|
console.log(this.config, '\n');
|
|
59
50
|
}
|
|
60
51
|
|
|
61
52
|
this._websocketServer = null;
|
|
62
53
|
this._oscServer = null;
|
|
54
|
+
|
|
63
55
|
this._wsListeners = new Set();
|
|
64
56
|
this._oscListeners = new Set();
|
|
65
57
|
}
|
|
@@ -69,47 +61,41 @@ class Server {
|
|
|
69
61
|
let oscPromise = true;
|
|
70
62
|
|
|
71
63
|
if (this.config.ws !== null) {
|
|
72
|
-
const {
|
|
73
|
-
hostname,
|
|
74
|
-
port
|
|
75
|
-
} = this.config.ws;
|
|
64
|
+
const { hostname, port } = this.config.ws;
|
|
76
65
|
|
|
77
66
|
if (!Number.isInteger(port)) {
|
|
78
67
|
throw new Error(`Invalid port "${port}" for WebSocket server`);
|
|
79
68
|
}
|
|
80
69
|
|
|
81
70
|
if (this._verbose) {
|
|
82
|
-
console.log(`>
|
|
71
|
+
console.log(`> CoMote: Launching WebSocket server on port: ${port}`);
|
|
83
72
|
}
|
|
84
73
|
|
|
85
|
-
this._websocketServer = new
|
|
86
|
-
port
|
|
87
|
-
});
|
|
88
|
-
const sockets = new Map();
|
|
89
|
-
|
|
74
|
+
this._websocketServer = new WebSocketServer({ port });
|
|
90
75
|
this._websocketServer.on('connection', (socket, request) => {
|
|
91
76
|
// const ip = request.socket.remoteAddress;
|
|
92
77
|
socket.on('message', (data, isBinary) => {
|
|
93
|
-
if (isBinary) {
|
|
78
|
+
if (isBinary) {
|
|
79
|
+
// @todo
|
|
94
80
|
} else {
|
|
95
|
-
if ((
|
|
96
|
-
// do we really need this check?
|
|
81
|
+
if (isValidUTF8(data)) { // do we really need this check?
|
|
97
82
|
data = JSON.parse(data);
|
|
98
83
|
|
|
99
84
|
if (this._verbose) {
|
|
100
|
-
console.log(`>
|
|
101
|
-
}
|
|
102
|
-
// console.log(this._wsListeners.size);
|
|
103
|
-
|
|
85
|
+
console.log(`> CoMote: new WebSocket message`, data);
|
|
86
|
+
}
|
|
104
87
|
|
|
88
|
+
// console.log(data);
|
|
89
|
+
// console.log(this._wsListeners.size);
|
|
105
90
|
this._wsListeners.forEach(listener => listener(data));
|
|
106
91
|
}
|
|
107
92
|
}
|
|
108
|
-
});
|
|
93
|
+
});
|
|
109
94
|
|
|
95
|
+
// When a socket closes, or disconnects, remove it from the array.
|
|
110
96
|
socket.on('close', (code, data) => {
|
|
111
97
|
if (this._verbose) {
|
|
112
|
-
console.log('>
|
|
98
|
+
console.log('> CoMote: closed socket connection');
|
|
113
99
|
}
|
|
114
100
|
});
|
|
115
101
|
});
|
|
@@ -117,48 +103,45 @@ class Server {
|
|
|
117
103
|
wsPromise = new Promise((resolve, reject) => {
|
|
118
104
|
this._websocketServer.on('listening', () => {
|
|
119
105
|
if (this._verbose) {
|
|
120
|
-
console.log(`>
|
|
106
|
+
console.log(`> CoMote: WebSocket server listening`);
|
|
121
107
|
}
|
|
122
108
|
|
|
123
109
|
resolve();
|
|
124
110
|
});
|
|
125
111
|
|
|
126
112
|
this._websocketServer.on('error', err => {
|
|
127
|
-
console.log(`>
|
|
113
|
+
console.log(`> CoMote: WebSocket server error`, err);
|
|
128
114
|
reject(err);
|
|
129
115
|
});
|
|
130
116
|
});
|
|
131
117
|
}
|
|
132
118
|
|
|
133
119
|
if (this.config.osc !== null) {
|
|
134
|
-
const {
|
|
135
|
-
hostname,
|
|
136
|
-
port
|
|
137
|
-
} = this.config.osc;
|
|
120
|
+
const { hostname, port } = this.config.osc;
|
|
138
121
|
|
|
139
122
|
if (!Number.isInteger(port)) {
|
|
140
123
|
throw new Error(`Invalid port "${port}" for OSC server`);
|
|
141
|
-
}
|
|
142
|
-
|
|
124
|
+
}
|
|
143
125
|
|
|
126
|
+
// fallback to broadcast
|
|
144
127
|
if (!hostname) {
|
|
145
128
|
hostname = '0.0.0.0';
|
|
146
129
|
}
|
|
147
130
|
|
|
148
131
|
if (this._verbose) {
|
|
149
|
-
console.log(`>
|
|
132
|
+
console.log(`> CoMote: Launching OSC server udp://${hostname}:${port}`);
|
|
150
133
|
}
|
|
151
134
|
|
|
152
135
|
oscPromise = new Promise((resolve, reject) => {
|
|
153
|
-
this._oscServer = new
|
|
136
|
+
this._oscServer = new OscServer(this.config.osc.port, hostname, err => {
|
|
154
137
|
if (err) {
|
|
155
|
-
console.log(`>
|
|
138
|
+
console.log(`> CoMote: OSC server error`, err);
|
|
156
139
|
reject();
|
|
157
140
|
return;
|
|
158
141
|
}
|
|
159
142
|
|
|
160
143
|
if (this._verbose) {
|
|
161
|
-
console.log(`>
|
|
144
|
+
console.log(`> CoMote: OSC server listening`);
|
|
162
145
|
}
|
|
163
146
|
|
|
164
147
|
resolve();
|
|
@@ -168,7 +151,7 @@ class Server {
|
|
|
168
151
|
let address = data.shift();
|
|
169
152
|
|
|
170
153
|
if (this._verbose) {
|
|
171
|
-
console.log(`>
|
|
154
|
+
console.log(`> CoMote: new OSC message "${address}":`, data);
|
|
172
155
|
}
|
|
173
156
|
|
|
174
157
|
this._oscListeners.forEach(callback => callback(address, data));
|
|
@@ -188,43 +171,36 @@ class Server {
|
|
|
188
171
|
this._oscServer.close();
|
|
189
172
|
}
|
|
190
173
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Add a listener for incomming WebSocket message
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Add a listener for incomming WebSocket message
|
|
177
|
+
*/
|
|
196
178
|
addWsListener(callback) {
|
|
197
179
|
this._wsListeners.add(callback);
|
|
198
180
|
|
|
199
181
|
return () => this._wsListeners.delete(callback);
|
|
200
182
|
}
|
|
183
|
+
|
|
201
184
|
/**
|
|
202
185
|
* Remove WebSocket listener
|
|
203
186
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
187
|
removeWsListener(callback) {
|
|
207
188
|
this._wsListeners.delete(callback);
|
|
208
189
|
}
|
|
190
|
+
|
|
209
191
|
/**
|
|
210
192
|
* Add a listener for incomming OSC message
|
|
211
193
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
194
|
addOscListener(callback) {
|
|
215
195
|
this._oscListeners.add(callback);
|
|
216
196
|
|
|
217
197
|
return () => this._oscListeners.delete(callback);
|
|
218
198
|
}
|
|
199
|
+
|
|
219
200
|
/**
|
|
220
201
|
* Remove OSC listener
|
|
221
202
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
203
|
removeOscListener(callback) {
|
|
225
204
|
this._oscListeners.delete(callback);
|
|
226
205
|
}
|
|
227
|
-
|
|
228
206
|
}
|
|
229
|
-
|
|
230
|
-
exports.Server = Server;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import si from 'systeminformation';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} WifiInfos
|
|
5
|
+
* @property {number} ssid - SSID of the WiFi connection
|
|
6
|
+
* @property {number} ip - Related IP (IPV4)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve the SSID and related IP of the first WiFi connection found, return
|
|
11
|
+
* `null` if no WiFi connection found.
|
|
12
|
+
*
|
|
13
|
+
* @async
|
|
14
|
+
* @return {WiFiInfos|null}
|
|
15
|
+
*/
|
|
16
|
+
export async function getWifiInfos() {
|
|
17
|
+
// find first wifi connection
|
|
18
|
+
const wifiConnections = await si.wifiConnections();
|
|
19
|
+
const conn = wifiConnections[0];
|
|
20
|
+
|
|
21
|
+
if (!conn) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// find related interface
|
|
26
|
+
const interfaces = await si.networkInterfaces();
|
|
27
|
+
const int = interfaces.find(int => int.iface === conn.iface);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
ssid: conn.ssid,
|
|
31
|
+
ip: int.ip4,
|
|
32
|
+
};
|
|
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
|
package/wifi-infos.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getWifiInfos = getWifiInfos;
|
|
7
|
-
|
|
8
|
-
var _systeminformation = _interopRequireDefault(require("systeminformation"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {Object} WifiInfos
|
|
14
|
-
* @property {number} ssid - SSID of the WiFi connection
|
|
15
|
-
* @property {number} ip - Related IP (IPV4)
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve the SSID and related IP of the first WiFi connection found, return
|
|
20
|
-
* `null` if no WiFi connection found.
|
|
21
|
-
*
|
|
22
|
-
* @async
|
|
23
|
-
* @return {WiFiInfos|null}
|
|
24
|
-
*/
|
|
25
|
-
async function getWifiInfos() {
|
|
26
|
-
// find first wifi connection
|
|
27
|
-
const wifiConnections = await _systeminformation.default.wifiConnections();
|
|
28
|
-
const conn = wifiConnections[0];
|
|
29
|
-
|
|
30
|
-
if (!conn) {
|
|
31
|
-
return null;
|
|
32
|
-
} // find related interface
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const interfaces = await _systeminformation.default.networkInterfaces();
|
|
36
|
-
const int = interfaces.find(int => int.iface === conn.iface);
|
|
37
|
-
return {
|
|
38
|
-
ssid: conn.ssid,
|
|
39
|
-
ip: int.ip4
|
|
40
|
-
};
|
|
41
|
-
}
|