nodeskini 1.0.0

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.
Files changed (215) hide show
  1. package/README.md +31 -0
  2. package/client/archive/bundle.js +11528 -0
  3. package/client/archive/golem.html +60 -0
  4. package/client/archive/golemClient.js +595 -0
  5. package/client/archive/golembundle.js +11634 -0
  6. package/client/archive/sequencer.html +43 -0
  7. package/client/archive/sequenceurClient.js +815 -0
  8. package/client/archive/stylegolem.css +158 -0
  9. package/client/archive/stylesequenceur.css +204 -0
  10. package/client/clientListe/Sortable-master/.circleci/config.yml +33 -0
  11. package/client/clientListe/Sortable-master/.editorconfig +15 -0
  12. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/bug-report.md +73 -0
  13. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/custom-template.md +48 -0
  14. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/feature-request.md +41 -0
  15. package/client/clientListe/Sortable-master/.jshintrc +25 -0
  16. package/client/clientListe/Sortable-master/.testcaferc.json +7 -0
  17. package/client/clientListe/Sortable-master/CONTRIBUTING.md +26 -0
  18. package/client/clientListe/Sortable-master/LICENSE +21 -0
  19. package/client/clientListe/Sortable-master/README.md +813 -0
  20. package/client/clientListe/Sortable-master/Sortable.js +3709 -0
  21. package/client/clientListe/Sortable-master/Sortable.min.js +2 -0
  22. package/client/clientListe/Sortable-master/Sortable.min.old.js +2 -0
  23. package/client/clientListe/Sortable-master/Sortable.min.old.old.js +2 -0
  24. package/client/clientListe/Sortable-master/babel.config.js +27 -0
  25. package/client/clientListe/Sortable-master/bower.json +30 -0
  26. package/client/clientListe/Sortable-master/entry/entry-complete.js +8 -0
  27. package/client/clientListe/Sortable-master/entry/entry-core.js +19 -0
  28. package/client/clientListe/Sortable-master/entry/entry-defaults.js +19 -0
  29. package/client/clientListe/Sortable-master/index.html +460 -0
  30. package/client/clientListe/Sortable-master/modular/sortable.complete.esm.js +3701 -0
  31. package/client/clientListe/Sortable-master/modular/sortable.core.esm.js +3698 -0
  32. package/client/clientListe/Sortable-master/modular/sortable.esm.js +3699 -0
  33. package/client/clientListe/Sortable-master/package-lock.json +5704 -0
  34. package/client/clientListe/Sortable-master/package.json +56 -0
  35. package/client/clientListe/Sortable-master/plugins/AutoScroll/AutoScroll.js +270 -0
  36. package/client/clientListe/Sortable-master/plugins/AutoScroll/README.md +80 -0
  37. package/client/clientListe/Sortable-master/plugins/AutoScroll/index.js +1 -0
  38. package/client/clientListe/Sortable-master/plugins/MultiDrag/MultiDrag.js +617 -0
  39. package/client/clientListe/Sortable-master/plugins/MultiDrag/README.md +96 -0
  40. package/client/clientListe/Sortable-master/plugins/MultiDrag/index.js +1 -0
  41. package/client/clientListe/Sortable-master/plugins/OnSpill/OnSpill.js +79 -0
  42. package/client/clientListe/Sortable-master/plugins/OnSpill/README.md +60 -0
  43. package/client/clientListe/Sortable-master/plugins/OnSpill/index.js +1 -0
  44. package/client/clientListe/Sortable-master/plugins/README.md +178 -0
  45. package/client/clientListe/Sortable-master/plugins/Swap/README.md +55 -0
  46. package/client/clientListe/Sortable-master/plugins/Swap/Swap.js +90 -0
  47. package/client/clientListe/Sortable-master/plugins/Swap/index.js +1 -0
  48. package/client/clientListe/Sortable-master/scripts/banner.js +8 -0
  49. package/client/clientListe/Sortable-master/scripts/build.js +17 -0
  50. package/client/clientListe/Sortable-master/scripts/esm-build.js +28 -0
  51. package/client/clientListe/Sortable-master/scripts/minify.js +11 -0
  52. package/client/clientListe/Sortable-master/scripts/test-compat.js +30 -0
  53. package/client/clientListe/Sortable-master/scripts/test.js +21 -0
  54. package/client/clientListe/Sortable-master/scripts/umd-build.js +15 -0
  55. package/client/clientListe/Sortable-master/src/Animation.js +175 -0
  56. package/client/clientListe/Sortable-master/src/BrowserInfo.js +12 -0
  57. package/client/clientListe/Sortable-master/src/EventDispatcher.js +57 -0
  58. package/client/clientListe/Sortable-master/src/PluginManager.js +87 -0
  59. package/client/clientListe/Sortable-master/src/Sortable.js +1971 -0
  60. package/client/clientListe/Sortable-master/src/utils.js +556 -0
  61. package/client/clientListe/Sortable-master/st/app.js +224 -0
  62. package/client/clientListe/Sortable-master/st/iframe/frame.html +32 -0
  63. package/client/clientListe/Sortable-master/st/iframe/index.html +49 -0
  64. package/client/clientListe/Sortable-master/st/logo.png +0 -0
  65. package/client/clientListe/Sortable-master/st/og-image.png +0 -0
  66. package/client/clientListe/Sortable-master/st/prettify/prettify.css +1 -0
  67. package/client/clientListe/Sortable-master/st/prettify/prettify.js +46 -0
  68. package/client/clientListe/Sortable-master/st/prettify/run_prettify.js +64 -0
  69. package/client/clientListe/Sortable-master/st/saucelabs.svg +1 -0
  70. package/client/clientListe/Sortable-master/st/theme.css +254 -0
  71. package/client/clientListe/Sortable-master/tests/Sortable.compat.test.js +39 -0
  72. package/client/clientListe/Sortable-master/tests/Sortable.test.js +386 -0
  73. package/client/clientListe/Sortable-master/tests/dual-list.html +34 -0
  74. package/client/clientListe/Sortable-master/tests/empty-list.html +30 -0
  75. package/client/clientListe/Sortable-master/tests/filter.html +27 -0
  76. package/client/clientListe/Sortable-master/tests/handles.html +27 -0
  77. package/client/clientListe/Sortable-master/tests/nested.html +67 -0
  78. package/client/clientListe/Sortable-master/tests/single-list.html +25 -0
  79. package/client/clientListe/Sortable-master/tests/style.css +18 -0
  80. package/client/clientListe/clientListe.html +148 -0
  81. package/client/clientListe/clientListe.js +1508 -0
  82. package/client/clientListe/clientListebundle.js +13164 -0
  83. package/client/clientListe/images/poubelle.png +0 -0
  84. package/client/clientListe/images/start.png +0 -0
  85. package/client/clientListe/images/stop.png +0 -0
  86. package/client/clientListe/images/submit.png +0 -0
  87. package/client/clientListe/sortable-theme-bootstrap.css +90 -0
  88. package/client/configurateur/configReact.js +273 -0
  89. package/client/configurateur/configReactbundle.js +295 -0
  90. package/client/configurateur/configurateur.css +95 -0
  91. package/client/configurateur/configurateur.html +48 -0
  92. package/client/configurateur/lib/jexcel.css +755 -0
  93. package/client/configurateur/lib/jexcel.js +14970 -0
  94. package/client/configurateur/lib/jsuites.css +2801 -0
  95. package/client/configurateur/lib/jsuites.js +11822 -0
  96. package/client/configurateur/lib/react-dom.production.min.js +239 -0
  97. package/client/configurateur/lib/react.production.min.js +32 -0
  98. package/client/configurateur/src/configReact.js +247 -0
  99. package/client/controleur/clientcontroleur.js +536 -0
  100. package/client/controleur/clientcontroleur.test.js +282 -0
  101. package/client/controleur/controleur.html +51 -0
  102. package/client/controleur/controleurbundle.js +565 -0
  103. package/client/controleur/stylecontroleur.css +236 -0
  104. package/client/controleurHH/controleurHH.html +71 -0
  105. package/client/controleurHH/controleurHH.js +252 -0
  106. package/client/controleurHH/styles/index.css +320 -0
  107. package/client/controleurHH/styles/material.css +11552 -0
  108. package/client/parametrage/paramReact.js +473 -0
  109. package/client/parametrage/paramReactbundle.js +500 -0
  110. package/client/parametrage/parametrage.css +111 -0
  111. package/client/parametrage/parametrage.html +163 -0
  112. package/client/parametrage/src/paramReact.js +459 -0
  113. package/client/score/hash.js +83 -0
  114. package/client/score/p5.min.js +3 -0
  115. package/client/score/parto1.js +1171 -0
  116. package/client/score/parto1bundle.js +1181 -0
  117. package/client/score/processing.min.js +431 -0
  118. package/client/score/score.html +15 -0
  119. package/client/score/score.js +34 -0
  120. package/client/simulateurListe/simulateurFork.js +750 -0
  121. package/client/simulateurListe/simulateurFork.mjs +681 -0
  122. package/client/simulateurListe/simulateurForkSansReorg.js +569 -0
  123. package/client/simulateurListe/simulateurListe.js +628 -0
  124. package/myReact/archive/Nodeemitvaluedlocal1.hh.js +52 -0
  125. package/myReact/archive/abort-parNode.js +79 -0
  126. package/myReact/archive/abroNode.js +169 -0
  127. package/myReact/archive/abroNode2.js +80 -0
  128. package/myReact/archive/atom.compile.hh.js +51 -0
  129. package/myReact/archive/await-countNode.js +67 -0
  130. package/myReact/archive/await-nowvalNode.js +44 -0
  131. package/myReact/archive/callHH.js +96 -0
  132. package/myReact/archive/emit-if2.hh.compiled.js +113 -0
  133. package/myReact/archive/every1Node.js +35 -0
  134. package/myReact/archive/if-runNode.js +74 -0
  135. package/myReact/archive/if1Node.js +43 -0
  136. package/myReact/archive/makeawait.js +0 -0
  137. package/myReact/archive/myReact.old.js +684 -0
  138. package/myReact/archive/orchestration.js +281 -0
  139. package/myReact/archive/orchestration1.js +132 -0
  140. package/myReact/archive/orchestration1.xml +465 -0
  141. package/myReact/archive/orchestration2.js +161 -0
  142. package/myReact/archive/orchestrationHH.mano.js +280 -0
  143. package/myReact/archive/orchestrationHHTest.js +428 -0
  144. package/myReact/archive/orchestrationHHTest.xml +234 -0
  145. package/myReact/archive/orchestrationHHTestRun.js +104 -0
  146. package/myReact/archive/orchestrationHHTestRun.xml +34 -0
  147. package/myReact/archive/orchestrationTest0.js +178 -0
  148. package/myReact/archive/orchestrationTest1.js +181 -0
  149. package/myReact/archive/orchestrationTest2.js +281 -0
  150. package/myReact/archive/run3pointsNode.js +59 -0
  151. package/myReact/archive/runNode.js +123 -0
  152. package/myReact/archive/runNode2.js +91 -0
  153. package/myReact/archive/testAwait1.js +141 -0
  154. package/myReact/archive/testAwait1.xml +86 -0
  155. package/myReact/archive/testEvery1.js +122 -0
  156. package/myReact/archive/testEvery1.xml +79 -0
  157. package/myReact/archive/testHH1.js +135 -0
  158. package/myReact/archive/testHH1.xml +86 -0
  159. package/myReact/archive/testHH1revu.js +104 -0
  160. package/myReact/archive/testHH2.js +122 -0
  161. package/myReact/archive/testHH2.xml +79 -0
  162. package/myReact/archive/testHH3.js +130 -0
  163. package/myReact/archive/testHH3.xml +86 -0
  164. package/myReact/archive/testHHabort.js +121 -0
  165. package/myReact/archive/testHHabort.xml +83 -0
  166. package/myReact/archive/testMakeawait.js +202 -0
  167. package/myReact/archive/testRun1.js +168 -0
  168. package/myReact/archive/testRun1.xml +142 -0
  169. package/myReact/archive/titi.js +28 -0
  170. package/myReact/archive/titi.xml +110 -0
  171. package/myReact/archive/toto.js +73 -0
  172. package/myReact/archive/toto.xml +198 -0
  173. package/myReact/archive/trap-await-parallelNode.js +123 -0
  174. package/myReact/inutiles/hiver2022.xml +804 -0
  175. package/myReact/inutiles/hopeNode.xml +459 -0
  176. package/myReact/inutiles/mars2022.xml +871 -0
  177. package/myReact/inutiles/mystique1.xml +318 -0
  178. package/myReact/inutiles/mystiqueOSC.xml +277 -0
  179. package/myReact/inutiles/opus5Node.xml +1271 -0
  180. package/myReact/inutiles/opus5NodeLinux.xml +1241 -0
  181. package/myReact/inutiles/orchestrationHH.xml +541 -0
  182. package/myReact/inutiles/orchestrationHH2.xml +547 -0
  183. package/myReact/inutiles/testHH.xml +95 -0
  184. package/myReact/inutiles/trouveLaPercuTenor.xml +349 -0
  185. package/myReact/myReact.js +744 -0
  186. package/myReact/myReact.min.js +1 -0
  187. package/myReact/orchestrationHH.js +311 -0
  188. package/myReact/orchestrationHH.mjs +436 -0
  189. package/myReact/orchestrationHH.mjs.map +1 -0
  190. package/package.json +46 -0
  191. package/serveur/OSCandMidi.mjs +361 -0
  192. package/serveur/computeScore.mjs +415 -0
  193. package/serveur/controleDAW.mjs +1149 -0
  194. package/serveur/defaultSession.csv +2 -0
  195. package/serveur/defaultSkiniParametres.js +119 -0
  196. package/serveur/gameOSC.mjs +96 -0
  197. package/serveur/groupeClientsSons.mjs +1014 -0
  198. package/serveur/ipConfig.json +24 -0
  199. package/serveur/ipConfig127.json +19 -0
  200. package/serveur/ipConfig75.json +17 -0
  201. package/serveur/ipConfigBH.json +19 -0
  202. package/serveur/ipConfigLocal.json +19 -0
  203. package/serveur/midiConfig.json +26 -0
  204. package/serveur/midiConfigBH.json +26 -0
  205. package/serveur/midiConfigVoid.json +3 -0
  206. package/serveur/midimix.mjs +570 -0
  207. package/serveur/saveParam.mjs +159 -0
  208. package/serveur/skiniParametres.good.js +132 -0
  209. package/serveur/skiniParametres.js +106 -0
  210. package/serveur/utilsHHSkini.hh.js +64 -0
  211. package/serveur/utilsSkini.mjs +137 -0
  212. package/serveur/websocketServer.mjs +2052 -0
  213. package/serveur/workerInterfaceZ.mjs +327 -0
  214. package/serveur/workerSynchro.mjs +49 -0
  215. package/skini.mjs +141 -0
@@ -0,0 +1,1014 @@
1
+
2
+ /**
3
+ * @fileOverview
4
+ * <H3>Control of clients groups and sounds</H3>
5
+ * <BR>
6
+ * La matrice des possibles est un tableau à 2 dimensions qui donne pour chaque groupe de clients
7
+ * l'état des groupes de patterns, actifs ou pas.
8
+ * Chaque groupe de patterns, groupe d'éléments comporte plusieurs éléments
9
+ * conformément à ce qui est décrit dans le fichier csv de description des patterns.
10
+
11
+ * <BR> La mise à jour de la matrice des possibles est faite par l'automate hiphop, par le controleur,
12
+ * ou par les scrutateurs. Elle est la concrétisation de l'orchestration.
13
+
14
+ * <BR> Cette matrice est sollicitée en lecture par les clients quand ils emettent le message "selectAllClips" vers le serveur de webSocket.
15
+ * Le clientSelecteurSimple emet ce message à l'initialisation (quand un message de modification du contexte DAW est reçu, DAWON) et à chaque fois
16
+ * qu'il reçoit par broadcast un message 'groupeClientStatus' qui signifie une modification dans la matrice.
17
+ * C'est donc bien à chaque fois qu'une modification est signalée que le client cherche à se mettre à jour.
18
+
19
+ * <BR> Le message 'groupeClientStatus' de signalisation d'une modification de la matrice est émis par broadcast:
20
+ * <BR> - soit par le serveur de WebSocket lorsqu'il reçoit une demande de modification de la matrice des possibles de la part du controleur via les messages:
21
+ * "putInMatriceDesPossibles", "ResetMatriceDesPossibles", "setAllMatriceDesPossibles". Pour plus de détail à ce niveau, voir les commentaires dans clientcontroleur.js.
22
+ * <BR> - soit de la part du scrutateur (dans sa version active) via le message: "propositionScrutateur".
23
+ * <BR> - soit par l'automate via la fonction informSelecteurOnMenuChange() de groupeClientsSons.js. Dans l'automate c'est à la charge du compositeur
24
+ *de signaler une mise à jour de la matrice. Ceci n'est pas automatique.
25
+ * @copyright (C) 2022-2024 Bertrand Petit-Hédelin
26
+ *
27
+ * This program is free software: you can redistribute it and/or modify
28
+ * it under the terms of the GNU General Public License as published by
29
+ * the Free Software Foundation, either version 3 of the License, or
30
+ * any later version.
31
+ *
32
+ * This program is distributed in the hope that it will be useful,
33
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
34
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35
+ * GNU General Public License for more details.
36
+ *
37
+ * You should have received a copy of the GNU General Public License
38
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
39
+ * @author Bertrand Petit-Hédelin <bertrand@hedelin.fr>
40
+ * @version 1.4
41
+ */
42
+ 'use strict'
43
+ import { createRequire } from 'module';
44
+ const require = createRequire(import.meta.url);
45
+
46
+ var debug = false;
47
+ var debug1 = true;
48
+ var par;
49
+
50
+ /**
51
+ * Load the parameters and launch the start of the client group management.
52
+ * @param {object} param
53
+ */
54
+ export function setParameters(param) {
55
+ par = param;
56
+ if (debug) console.log("groupeClientsSOns.mjs: setParameters:", param);
57
+ initGroupeClientsSons();
58
+ }
59
+
60
+ import * as DAW from './controleDAW.mjs';
61
+ import * as oscMidiLocal from './OSCandMidi.mjs'; // Pour OSC vers Game
62
+ import * as fs from "fs";
63
+
64
+ export var serv;
65
+
66
+ var midimix;
67
+ var orchestration;
68
+ var groupesClient;
69
+ export var matriceDesPossibles;
70
+ var timerDivision; // Nombre de pulses par tick, doit rester undefined si pas à jour par les automates
71
+ var nbeDeGroupesSons = 0;
72
+ var nombreDePatternsPossibleEnListe = [[1, 255]]; // init pour client memorySortable
73
+
74
+ // Pour les listes de clients memorySortable connectés et les infos sur les types de
75
+ // patterns ainsi que les précédentes listes envoyées. Mis à jour dans websocketServeur.
76
+ var clientsEnCours = [];
77
+ // Devient le tableau des groupes de patterns
78
+ var groupesSon;
79
+ var groupeName = "";
80
+
81
+ // On créé ce fichier à partir du xml de Blockly
82
+ var myReactOrchestration = "../myReact/orchestrationHH.mjs";
83
+ var socketControleur;
84
+ var computeScorePolicy = 0;
85
+ var computeScoreClass = 0;
86
+
87
+ /**
88
+ * Start the client group management according to the parameter file
89
+ */
90
+ function initGroupeClientsSons() {
91
+ // Tableau des clients actifs par groupe,
92
+ // Devient un tableau de tableau. Le premier tableau a des index correspondant au groupe.
93
+ // Les tableaux en deuxième position contiennent les id des clients générés à la connexion.
94
+ if (debug1) console.log("groupeClientsSins.js: initGroupeClientsSons: par.nbeDeGroupesClients", par.nbeDeGroupesClients);
95
+ groupesClient = new Array(par.nbeDeGroupesClients);
96
+ for (var i = 0; i < groupesClient.length; i++) {
97
+ groupesClient[i] = new Array();
98
+ }
99
+ matriceDesPossibles = new Array(par.nbeDeGroupesClients);
100
+ }
101
+
102
+ /*==========================================================================
103
+
104
+ Pour les broadcasts
105
+
106
+ ============================================================================*/
107
+ /**
108
+ * Set the server socket.
109
+ * @param {socket} server
110
+ */
111
+ export function initBroadCastServer(serveur) {
112
+ if (debug) console.log("groupecliensSons: initBroadCastServer ");
113
+ serv = serveur;
114
+ }
115
+
116
+ /**
117
+ * Set midimix to allow access to Ableton Link
118
+ * from the orchestration.
119
+ * @param {object} midimix reference
120
+ */
121
+ export function setMidimix(mix) {
122
+ midimix = mix;
123
+ }
124
+
125
+ /*===========================================================================
126
+ setClientsEncours et getClientsEncours
127
+
128
+ Ce sont des fonctions qui font passerelle entre websocketServerSkini.js
129
+ et les orchestrations car il n'y a pas de lien direct de l'orchestration
130
+ vers websocketServerSkini. Il y en a dans l'autre sens via des react().
131
+
132
+ =============================================================================*/
133
+ /**
134
+ * Set the list of connected clients
135
+ * @param {array} list of clients
136
+ */
137
+ export function setClientsEncours(liste) {
138
+ clientsEnCours = liste;
139
+ }
140
+
141
+ /**
142
+ * Get the list of connected clients
143
+ * @returns {array} list of client
144
+ */
145
+ export function getClientsEncours() {
146
+ if (debug) console.log("groupecliensSons: getClientsEncours:", clientsEnCours);
147
+ return clientsEnCours;
148
+ }
149
+
150
+ /*===========================================================================
151
+ getWinnerPseudo, getWinnerScore, getTotalGameScore, rankWinners, getGroupScore
152
+
153
+ Le calcul du ranking des scores se fait ici car ils sont activés par l'orchestration
154
+ mais le calcul des scores se fait dans compScore.js qui est activé à partir
155
+ de webSocketServeurSkini.js chaque soumission de liste de patterns.
156
+
157
+ =============================================================================*/
158
+
159
+ /**
160
+ * For a game session, get the pseudo of the winner at index position.
161
+ * @param {number} index
162
+ * @returns {string} pseudo or empty string
163
+ */
164
+ export function getWinnerPseudo(index) {
165
+
166
+ if (debug1) console.log("groupecliensSons: getWinner length:", clientsEnCours.length, index);
167
+ console.log("groupecliensSons: getWinnerPseudo : index :", index);
168
+
169
+ var winners = rankWinners(clientsEnCours);
170
+
171
+ if (winners === -1 || index >= winners.length) {
172
+ return '';
173
+ }
174
+ return winners[index].pseudo;
175
+ }
176
+
177
+ /**
178
+ * For a game session, get the score of the winner at index position.
179
+ * @param {number} index
180
+ * @returns {number} score
181
+ */
182
+ export function getWinnerScore(index) {
183
+ if (debug) console.log("groupecliensSons: getWinner length:", clientsEnCours.length);
184
+ var winners = rankWinners(clientsEnCours);
185
+ if (winners === -1 || index >= winners.length) {
186
+ return 0;
187
+ }
188
+ return winners[index].score;
189
+ }
190
+
191
+ /**
192
+ * For a game session, get the score of game.
193
+ * @returns {number} score
194
+ */
195
+ export function getTotalGameScore() {
196
+ if (debug) console.log("groupecliensSons: getTotalGameScore :", clientsEnCours);
197
+ var totalScore = 0;
198
+
199
+ for (var i = 0; i < clientsEnCours.length; i++) {
200
+ totalScore += clientsEnCours[i].score;
201
+ }
202
+ return totalScore;
203
+ }
204
+
205
+ /**
206
+ * For a game session, rank the winner.
207
+ * @param {array} list
208
+ * @returns {array} list in order according to the scores
209
+ */
210
+ function rankWinners(uneListe) {
211
+ if (debug) console.log("groupecliensSons: rankWinners:", uneListe);
212
+
213
+ if (uneListe === undefined) {
214
+ console.log("ERR : groupecliensSons: rankWinners: undefined");
215
+ return -1;
216
+ }
217
+
218
+ if (uneListe.length === 0) {
219
+ return -1;
220
+ }
221
+
222
+ var evaluation = function (a, b) {
223
+ return a.score > b.score;
224
+ }
225
+
226
+ var liste = uneListe.slice();
227
+
228
+ for (var i = 0; i < liste.length; i++) {
229
+ // le tableau est trié de 0 à i-1
230
+ // La boucle interne recherche le min
231
+ // de i+1 à la fin du tableau.
232
+ for (var j = i + 1; j < liste.length; j++) {
233
+ if (evaluation(liste[j], liste[i])) {
234
+ var temp = liste[j];
235
+ liste[j] = liste[i];
236
+ liste[i] = temp;
237
+ }
238
+ }
239
+ }
240
+ return liste;
241
+ }
242
+
243
+ /**
244
+ * Get the score of a group of winner score according to a rank.
245
+ * @param {number} rank
246
+ * @returns {array}
247
+ */
248
+ export function getGroupScore(rank) {
249
+ if (debug) console.log("groupecliensSons: getGroupScore:", clientsEnCours);
250
+ var scores = new Array();
251
+ var indexMaxDeGroupe = 0;
252
+
253
+ // On calcule l'index max pour les groupes
254
+ for (var i = 0; i < clientsEnCours.length; i++) {
255
+ if (clientsEnCours[i].groupe > indexMaxDeGroupe) {
256
+ indexMaxDeGroupe = clientsEnCours[i].groupe;
257
+ }
258
+ }
259
+
260
+ // On crée le tableau d'objet scores pour pouvoir le trier après.
261
+ for (var i = 0; i < indexMaxDeGroupe + 1; i++) {
262
+ var el = {
263
+ groupe: i,
264
+ score: 0
265
+ }
266
+ scores.push(el);
267
+ }
268
+ // On remplit scores avec les totaux de chaque groupe
269
+ // score est encore organisé avec comme index les groupes.
270
+ for (var i = 0; i < clientsEnCours.length; i++) {
271
+ if (clientsEnCours[i].groupe >= 0) { // On ne prend pas en compte les simulateurs hors audience dont le groupe est -1
272
+ scores[clientsEnCours[i].groupe].score += clientsEnCours[i].score;
273
+ }
274
+ }
275
+ // Classement des scores
276
+ var winners = rankWinners(scores);
277
+
278
+ if (debug) console.log("groupecliensSons: getGroupScore:scores", scores, "winners", winners);
279
+ return winners[rank].score;
280
+ }
281
+
282
+ /*===========================================================================
283
+ getTimerDivision, getComputeScorePolicy, getComputeScoreClass
284
+
285
+ Fonctions passerelle entre websocketServerSkini.js, controleDAW.mjs
286
+ et les orchestrations car il n'y a pas de lien direct de l'orchestration
287
+ vers websocketServerSkini. Il y en a dans l'autre sens via des react().
288
+
289
+ Les setTimerDivision, setComputeScorePolicy, setComputeScoreClass
290
+ sont faits directement depuis l'orchestration avec des addEventListeners.
291
+
292
+ =============================================================================*/
293
+ export function testGCS(text) {
294
+ console.log("testGCS+++++++++++++:", text, serv);
295
+ return serv;
296
+ }
297
+
298
+ /**
299
+ * Get the ongoing timer division
300
+ * @returns {number} timer division
301
+ */
302
+ export function getTimerDivision() {
303
+ if (debug) console.log("groupecliensSons: getTimerDivision:", timerDivision);
304
+ return timerDivision;
305
+ }
306
+
307
+ /**
308
+ * Get the ongoing score policy
309
+ * @returns {number} score policy
310
+ */
311
+ export function getComputeScorePolicy() {
312
+ return computeScorePolicy;
313
+ }
314
+
315
+ /**
316
+ * Get the ongoing score class
317
+ * @returns {number} score class
318
+ */
319
+ export function getComputeScoreClass() {
320
+ return computeScoreClass;
321
+ }
322
+
323
+ /**
324
+ * Set the score policy
325
+ * @param {number} score policy
326
+ */
327
+ export function setComputeScorePolicy(policy) {
328
+ computeScorePolicy = policy;
329
+ }
330
+
331
+ /**
332
+ * Set the score class
333
+ * @param {number} score class
334
+ */
335
+ export function setComputeScoreClass(scoreClass) {
336
+ computeScoreClass = scoreClass;
337
+ }
338
+
339
+ /**
340
+ * Set the timer division
341
+ * @param {number} timer division
342
+ */
343
+ export function setTimerDivision(timer) {
344
+ timerDivision = timer;
345
+ }
346
+
347
+ /**
348
+ * Set the controler socket
349
+ * @param {socket} controler socket
350
+ */
351
+ export function setSocketControleur(socket) {
352
+ socketControleur = socket;
353
+ }
354
+
355
+ /**
356
+ * Call the reset of the rcoehstration matrix.
357
+ */
358
+ export function resetMatrice() {
359
+ resetMatriceDesPossibles();
360
+ }
361
+
362
+ /**
363
+ * Set the length of the list of patterns for the web clients
364
+ * where a list of pattern can be selected.
365
+ * @param {array} param
366
+ */
367
+ export function setpatternListLength(param) {
368
+
369
+ function sendMessage(nbePatternsListes) {
370
+ if (debug) console.log("groupecliensSons.js: patternListLength:", nbePatternsListes);
371
+ serv.broadcast(JSON.stringify({
372
+ type: 'nombreDePatternsPossible',
373
+ value: nbePatternsListes
374
+ }));
375
+ }
376
+
377
+ // Mise à jour du suivi des longueurs de listes
378
+ for (let i = 0; i < nombreDePatternsPossibleEnListe.length; i++) {
379
+ if (nombreDePatternsPossibleEnListe[i][1] === param[1]) {
380
+ nombreDePatternsPossibleEnListe[i][0] = param[0];
381
+ sendMessage(nombreDePatternsPossibleEnListe);
382
+ return;
383
+ }
384
+ }
385
+ nombreDePatternsPossibleEnListe.push([param[0], param[1]]);
386
+ sendMessage(nombreDePatternsPossibleEnListe);
387
+ }
388
+
389
+ /*********************************************************
390
+
391
+ Gestion des logs de l'automate
392
+
393
+ **********************************************************/
394
+
395
+ function logInfoAutomate(message) {
396
+ message.date = getDateTime();
397
+ fs.appendFile('skinilog.json', JSON.stringify(message) + "\n", "UTF-8", function (err) {
398
+ if (err) {
399
+ console.error(err);
400
+ throw err;
401
+ }
402
+ });
403
+ }
404
+
405
+ function getDateTime() {
406
+ var date = new Date();
407
+ var hour = date.getHours();
408
+ hour = (hour < 10 ? "0" : "") + hour;
409
+ var min = date.getMinutes();
410
+ min = (min < 10 ? "0" : "") + min;
411
+ var sec = date.getSeconds();
412
+ sec = (sec < 10 ? "0" : "") + sec;
413
+ var year = date.getFullYear();
414
+ var month = date.getMonth() + 1;
415
+ month = (month < 10 ? "0" : "") + month;
416
+ var day = date.getDate();
417
+ day = (day < 10 ? "0" : "") + day;
418
+ return day + ":" + month + ":" + year + ":" + hour + ":" + min + ":" + sec;
419
+ }
420
+
421
+ /******************
422
+
423
+ Gestion des info vers les clients
424
+
425
+ ******************/
426
+ /**
427
+ * Clean the list of the pattern choson of web client
428
+ * using lists.
429
+ * @param {number} groupe
430
+ */
431
+ export function cleanChoiceList(groupe) {
432
+ var message = {
433
+ type: 'cleanClientChoiceList',
434
+ group: groupe
435
+ };
436
+ serv.broadcast(JSON.stringify(message));
437
+ }
438
+
439
+ /**
440
+ * To display a message on the score client
441
+ * @param {string} text
442
+ */
443
+ export function alertInfoScoreON(texte) {
444
+ var message = {
445
+ type: 'alertInfoScoreON',
446
+ text: texte
447
+ };
448
+ serv.broadcast(JSON.stringify(message));
449
+ }
450
+
451
+ /**
452
+ * To clean the message on the score client.
453
+ */
454
+ export function alertInfoScoreOFF() {
455
+ var message = {
456
+ type: 'alertInfoScoreOFF',
457
+ };
458
+ serv.broadcast(JSON.stringify(message));
459
+ }
460
+
461
+ // Cette fonction est dupliquée avec Blockly, on perd le serveur avec
462
+ // les rechargements des orchestrations.
463
+ /**
464
+ * To inform the web client when something changes in the
465
+ * orchestration
466
+ * @param {number} group number
467
+ * @param {string} group name
468
+ * @param {number} status
469
+ */
470
+ export function informSelecteurOnMenuChange(groupe, sons, status) {
471
+ if (sons == undefined) {
472
+ groupeName = "";
473
+ } else {
474
+ groupeName = sons;
475
+ }
476
+ var message = {
477
+ type: 'groupeClientStatus',
478
+ groupeClient: groupe,
479
+ groupeName: groupeName,
480
+ status: status
481
+ };
482
+ // Informe les selecteurs et simulateurs
483
+ if (debug) console.log("groupecliensSons:informSelecteurOnMenuChange:", groupe, sons, status);
484
+
485
+ if (serv !== undefined) {
486
+ serv.broadcast(JSON.stringify(message));
487
+ } else {
488
+ console.log("ERR: groupecliensSons: informSelecteurOnMenuChange: serv undefined");
489
+ }
490
+ }
491
+
492
+ /**
493
+ * To display the tick on the controler client.
494
+ * @param {number} tick
495
+ */
496
+ export function setTickOnControler(tick) {
497
+ var message = {
498
+ type: "setTickAutomate",
499
+ tick: tick
500
+ }
501
+ //console.log("groupecliensSons:socketControleur automate:", socketControleur);
502
+ if (socketControleur !== undefined) {
503
+ if (socketControleur.readyState == 1) {
504
+ socketControleur.send(JSON.stringify(message));
505
+ } else {
506
+ if (debug) console.log("ERR: groupecliensSons: informControleur: socketControleur not ready;", socketControleur.readyState);
507
+ }
508
+ }
509
+ }
510
+
511
+ /**
512
+ * To get the length of the list on the web client using lists of patterns
513
+ * (memorySortable)
514
+ * @returns {number} list length
515
+ */
516
+ export function getNombreDePatternsPossibleEnListe() {
517
+ if (debug) console.log("groupecliensSons: getNombreDePatternsPossibleEnListe:", nombreDePatternsPossibleEnListe);
518
+ return nombreDePatternsPossibleEnListe;
519
+ }
520
+
521
+ /******************
522
+
523
+ Gestion des Groupes de clients
524
+
525
+ *******************/
526
+ // for (var i = 0; i < groupesClient.length; i++) {
527
+ // groupesClient[i] = new Array();
528
+ // }
529
+
530
+ /**
531
+ * Add an id to a group of client.
532
+ * @param {number} id
533
+ * @param {array} group
534
+ */
535
+ export function putIdInGroupClient(id, groupe) {
536
+ if (debug) console.log("groupecliensSons:", id, groupe);
537
+
538
+ if (groupesClient[groupe] !== undefined) {
539
+ groupesClient[groupe].push(id);
540
+ } else {
541
+ console.log("ERR: groupecliensSons: putIdInGroupClient :", id, groupe);
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Remove an id to a group of client.
547
+ * @param {number} id
548
+ */
549
+ export function removeIdInGroupClient(id) {
550
+ var position;
551
+
552
+ for (var i = 0; i < groupesClient.length; i++) {
553
+ for (var j = 0; j < groupesClient[i].length; j++) {
554
+ if (groupesClient[i][j] == id) {
555
+ position = groupesClient[i].splice(j, 1);
556
+ return position; // Pour contrôle
557
+ }
558
+ }
559
+ }
560
+ }
561
+
562
+ /**
563
+ * Get a group of client according to an id
564
+ * @param {number} id
565
+ * @returns {array} group of client
566
+ */
567
+ export function getGroupClient(id) {
568
+ for (var i = 0; i < groupesClient.length; i++) {
569
+ for (var j = 0; j < groupesClient[i].length; j++) {
570
+ if (groupesClient[i][j] == id) {
571
+ return i;
572
+ }
573
+ }
574
+ }
575
+ }
576
+
577
+ /**
578
+ * Get a group according to an id.
579
+ * @param {id} group id
580
+ * @returns {array} the group
581
+ */
582
+ export function getIdsClient(groupe) {
583
+ return groupesClient[groupe];
584
+ }
585
+
586
+ /**
587
+ *
588
+ * @returns Get all the client groups.
589
+ */
590
+ export function getGroupesClient() {
591
+ return groupesClient;
592
+ }
593
+
594
+ /**
595
+ * Get the length of all the client groups
596
+ * @returns {array} lengths
597
+ */
598
+ export function getGroupesClientLength() {
599
+ // It happends when calling this function before loading a piece
600
+ if (par === undefined) return 0;
601
+
602
+ var longueurs = new Array(par.nbeDeGroupesClients);
603
+ for (var i = 0; i < groupesClient.length; i++) {
604
+ longueurs[i] = groupesClient[i].length;
605
+ }
606
+ return longueurs;
607
+ }
608
+
609
+ /************************************
610
+
611
+ Groupes de sons (patterns)
612
+
613
+ ************************************/
614
+ /**
615
+ * Get the list of patterns
616
+ * @returns {array} ongoing group of patterns
617
+ */
618
+ export function getOnGoingGroupeSons() {
619
+ return groupesSon;
620
+ }
621
+
622
+ /**
623
+ * Get the name of the group used for the signal in the orchestration
624
+ * according to group number assign to a pattern.
625
+ * @param {number} group number in a pattern description
626
+ * @returns {string|number} group name or -1
627
+ */
628
+ export function getSignalFromGroup(groupe) {
629
+ if (debug) console.log("groupecliensSons.js : getSignalFromGroup : ", groupe);
630
+
631
+ var ongoingGroupe = getOnGoingGroupeSons();
632
+ if (debug) console.log("groupecliensSons.js : ongoingGroupe : ", ongoingGroupe);
633
+
634
+ for (var i = 0; i < ongoingGroupe.length; i++) {
635
+ if (ongoingGroupe[i][1] == groupe) {
636
+ return ongoingGroupe[i][0];
637
+ }
638
+ }
639
+ if (debug) console.log("ERR: groupecliensSons : getSignalFromGroup : groupe inconnu :", groupe);
640
+ return -1;
641
+ }
642
+
643
+ /**
644
+ * Set the number of pattern groups.
645
+ * @param {number} number of pattern groups
646
+ */
647
+ export function setNbeDeGroupesSons(groupesSons) {
648
+ // Nbe de groupe de son est donné par controleDAW sur la base de ce qui est décrit dans les fichiers csv
649
+ // il s'agit donc de la valeur max dans des groupes qui vont de 0 à X. Il y a donc X + 1 groupe de sons.
650
+ nbeDeGroupesSons = groupesSons + 1;
651
+ }
652
+
653
+ /**
654
+ * Get the pattern group number from a signal
655
+ * @param {string} signal
656
+ * @returns {number} group number
657
+ */
658
+ function getGroupeSons(signal) {
659
+ var signalLocal = signal.slice(0, -3); // Pour enlever OUT
660
+
661
+ if (debug) console.log("groupeClientSons.mjs: getGroupeSons: signal:", signal, "signalLocal:", signalLocal, "nbeDeGroupesSons:", nbeDeGroupesSons);
662
+
663
+ for (let i = 0; i < nbeDeGroupesSons; i++) {
664
+ if (groupesSon[i][0] === undefined) {
665
+ console.log("ERR: getGroupeSons: groupesSon[", i, "i][0]: undefined, table groupesSon pas encore à jour");
666
+ return -1;
667
+ }
668
+ if (groupesSon[i][0] === signalLocal) {
669
+ return groupesSon[i][1];
670
+ }
671
+ }
672
+ console.log("ERR: groupeClientSons.mjs: getGroupeSons: signal inconnu", signalLocal);
673
+ return -1;
674
+ }
675
+
676
+ /*function getGroupeSons(signal) {
677
+
678
+ var signalLocal = signal.slice(0, -3); // Pour enlever OUT
679
+
680
+ if (debug1) console.log("groupeClientSons.mjs: getGroupeSons: signal:", signal, "signalLocal:", signalLocal, "groupesDesSons.length:", par.groupesDesSons.length);
681
+
682
+ for (var i = 0; i < par.groupesDesSons.length ; i++) {
683
+ if ( par.groupesDesSons[i][0] === undefined) {
684
+ console.log("ERR: getGroupeSons: groupesSon[", i ,"i][0]: undefined, table groupesSon pas encore à jour");
685
+ return -1;
686
+ }
687
+ if ( par.groupesDesSons[i][0] === signalLocal) {
688
+ return par.groupesDesSons[i][1];
689
+ }
690
+ }
691
+ console.log("ERR: groupeClientSons.mjs: getGroupeSons: signal inconnu", signalLocal);
692
+ return -1;
693
+ }*/
694
+
695
+ /**
696
+ * Get the name of a group from its index.
697
+ * @param {number} index
698
+ * @returns {string|number} name or -1
699
+ */
700
+ export function getNameGroupeSons(index) {
701
+ for (var i = 0; i < groupesSon.length; i++) {
702
+ if (groupesSon[i][1] == index) { // Attention pas de === ici, il y a changementde type
703
+ return groupesSon[i][0];
704
+ }
705
+ }
706
+ if (groupesSon[index] === undefined) {
707
+ console.log("ERR: groupeClientSons.mjs: getNameGroupeSons: index inconnu", index, groupesSon);
708
+ return -1;
709
+ }
710
+ }
711
+
712
+ /**
713
+ * Set the group of pattern as described in the configuration file
714
+ * of the piece.
715
+ * @param {number} Flag of the orchestration loaded
716
+ * @returns {number} 0 is OK -1 otherwise
717
+ */
718
+ export function setGroupesSon(DAWState) {
719
+ if (DAWState == 0) {
720
+ if (debug) console.log("groupeClientsSons: setGroupesSon:DAWStatus:", DAWState);
721
+ return -1;
722
+ }
723
+
724
+ groupesSon = par.groupesDesSons;
725
+ if (groupesSon == undefined) {
726
+ console.log("ERR: groupeClientSons.mjs: setGroupesSon: groupesSon:undefined:DAWStatus:", DAWState);
727
+ return -1;
728
+ }
729
+
730
+ if (groupesSon.length == 0) {
731
+ console.log("WARNING: groupeClientSons.mjs: setGroupesSon: groupesSon vide");
732
+ return -1;
733
+ }
734
+
735
+ var msg = {
736
+ type: "setPatternGroups",
737
+ text: groupesSon
738
+ }
739
+ serv.broadcast(JSON.stringify(msg));
740
+
741
+ if (debug) console.log("groupeClientsSons: setGroupesSon:groupesSon ", groupesSon, "DAWStatus:", DAWState);
742
+ return 0;
743
+ }
744
+
745
+ /*************************
746
+
747
+ Matrice des possibles, pour le contrôle
748
+ des liens entre groupes de clients et groupes de sons (patterns)
749
+
750
+ **************************/
751
+ /**
752
+ * Create the matrix giving the status of the orchestration.
753
+ */
754
+ export function createMatriceDesPossibles() {
755
+ for (var i = 0; i < matriceDesPossibles.length; i++) {
756
+ if (nbeDeGroupesSons > 0) { // Protection
757
+ matriceDesPossibles[i] = new Array(nbeDeGroupesSons);
758
+ } else {
759
+ matriceDesPossibles[i] = [];
760
+ }
761
+ }
762
+ // Info pour les scrutateurs
763
+ serv.broadcast(JSON.stringify({ type: "createMatriceDesPossibles",
764
+ matrice: matriceDesPossibles }));
765
+ }
766
+
767
+ /**
768
+ * Change the status of a group of pattern for a group of web client
769
+ * @param {number} groupeClient
770
+ * @param {number} groupeDeSons
771
+ * @param {number} status
772
+ * @returns {number} 0 is OK, -1 is a problem
773
+ */
774
+ export function setInMatriceDesPossibles(groupeClient, groupeDeSons, status) {
775
+ if (debug) console.log("groupeClientSons.mjs: setInMatriceDesPossibles ", groupeClient, groupeDeSons, status);
776
+ if (debug) console.log("groupeClientSons.mjs: setInMatriceDesPossibles:", matriceDesPossibles);
777
+
778
+ if (groupeClient === 255) { // On traite tous les groupes
779
+ for (var i = 0; i < par.nbeDeGroupesClients; i++) {
780
+ matriceDesPossibles[i][groupeDeSons] = status;
781
+ }
782
+ return 0;
783
+ }
784
+ if (groupeClient >= par.nbeDeGroupesClients) {
785
+ console.log("ERR: groupeClientSons.mjs:setInMatriceDesPossibles:groupeClient size exceeded:", groupeClient);
786
+ return -1;
787
+ }
788
+ matriceDesPossibles[groupeClient][groupeDeSons] = status;
789
+
790
+ var message = [groupeClient, groupeDeSons, status];
791
+ var msg = {
792
+ type: "setInMatriceDesPossibles",
793
+ value: message
794
+ }
795
+ serv.broadcast(JSON.stringify(msg));
796
+ return 0;
797
+ }
798
+
799
+ /**
800
+ * Get the status of group of pattern for a group of client.
801
+ * @param {number} groupeClient
802
+ * @param {number} groupeSon
803
+ * @returns {number}
804
+ */
805
+ export function getStatusInMatriceDesPossibles(groupeClient, groupeSon) {
806
+ if (matriceDesPossibles[groupeClient][groupeSon] != undefined) {
807
+ return matriceDesPossibles[groupeClient][groupeSon];
808
+ }
809
+ }
810
+
811
+ /**
812
+ * Broadcast the matrix.
813
+ */
814
+ export function setMatriceDesPossibles() {
815
+ for (var i = 0; i < matriceDesPossibles.length; i++) {
816
+ for (var j = 0; j < matriceDesPossibles[i].length; j++) {
817
+ matriceDesPossibles[i][j] = true;
818
+ }
819
+ }
820
+ // Info pour les scrutateurs
821
+ var msg = {
822
+ type: "setMatriceDesPossibles",
823
+ message: "Set"
824
+ }
825
+ serv.broadcast(JSON.stringify(msg));
826
+ if (debug) console.log("groupeClientSons:setMatriceDesPossibles:", matriceDesPossibles);
827
+ }
828
+
829
+ /**
830
+ * Clean the matrix.
831
+ */
832
+ export function resetMatriceDesPossibles() {
833
+ for (var i = 0; i < matriceDesPossibles.length; i++) {
834
+ for (var j = 0; j < matriceDesPossibles[i].length; j++) {
835
+ matriceDesPossibles[i][j] = false;
836
+ }
837
+ }
838
+ if (debug) console.log("groupeClientSons:resetMatriceDesPossibles:", matriceDesPossibles);
839
+ // Info pour les scrutateurs
840
+ var msg = {
841
+ type: "resetMatriceDesPossibles",
842
+ message: "Reset"
843
+ }
844
+ serv.broadcast(JSON.stringify(msg));
845
+ }
846
+
847
+ /**
848
+ * Display the matrix on the console.
849
+ */
850
+ export function displayMatriceDesPossibles() {
851
+ console.log("groupecliensSons: displayMatriceDesPossibles : DEBUT ---------------------------");
852
+ console.log(matriceDesPossibles);
853
+ console.log("groupecliensSons: displayMatriceDesPossibles : FIN ---------------------------");
854
+ }
855
+
856
+ /*************************************************************
857
+
858
+ AUTOMATE DE GESTION DE LA MATRICE DES POSSIBLES
859
+
860
+ **************************************************************/
861
+ /**
862
+ * To get the HH machine. But should be useless.
863
+ * @returns {object} the HipHop.js machine
864
+ */
865
+ var machine;
866
+ export function getMachine() {
867
+ return machine;
868
+ }
869
+
870
+ /**
871
+ * Create and compile the hipHop.js orchestration from the blocky generated code
872
+ * or HH file
873
+ */
874
+ var tempIndex = 0;
875
+
876
+ export async function makeOneAutomatePossibleMachine() {
877
+ if (debug) console.log("groupeClientsSons.js: makeOneAutomatePossibleMachine", par.groupesDesSons);
878
+
879
+ try {
880
+ const orchestration = await import(myReactOrchestration + '?foo=bar' + tempIndex);
881
+ tempIndex++;
882
+
883
+ orchestration.setServ(serv, DAW, this, oscMidiLocal, midimix);
884
+
885
+ machine = orchestration.setSignals(par);
886
+ makeSignalsListeners(machine);
887
+
888
+ if (debug) console.log("------------- groupecliensSons: makeOneAutomatePossibleMachine:machine: ", machine);
889
+
890
+ return machine;
891
+
892
+ } catch (err) {
893
+ console.log("ERR: groupeClientsSons: makeOneAutomatePossibleMachine:", err.toString());
894
+ throw err; // Propage l'erreur pour que compileHH() la capture
895
+ }
896
+ }
897
+
898
+ let messageLog = {
899
+ date: "",
900
+ source: "groupeClientSons.mjs",
901
+ type: "log"
902
+ }
903
+
904
+ /**
905
+ * Create the listeners for the HipHop.js orchestration
906
+ * @param {object} HipHop.js machine
907
+ */
908
+ function makeSignalsListeners(machine) {
909
+ // Création des listeners des signaux
910
+ for (var i = 0; i < par.groupesDesSons.length; i++) {
911
+
912
+ if (par.groupesDesSons[i][0] !== "") {
913
+ var signal = par.groupesDesSons[i][0] + "OUT";
914
+
915
+ if (debug) console.log("Addeventlisterner:signal:", signal);
916
+
917
+ machine.addEventListener(signal, function (evt) {
918
+ // Rappel: setInMatriceDesPossibles(groupeClient, groupeSon, status)
919
+ if (debug) console.log("groupeClientSons: listerner:signal:", evt.signame, evt);
920
+
921
+ var groupeSonLocal = getGroupeSons(evt?.signame || evt.signame);
922
+ if (groupeSonLocal == -1) {
923
+ console.log("ERR: groupeClientsSons.js:Addeventlisterner: signal inconnu:", evt.signame);
924
+ return;
925
+ }
926
+ if (debug) console.log("groupeClientSons.mjs:Addeventlisterner: groupeSons:", groupeSonLocal,
927
+ "signame:", evt.signame,
928
+ "groupeClientsNo:", evt.nowval[1],
929
+ "statut:", evt.nowval[0],
930
+ "nowval:", evt.nowval);
931
+
932
+ if (setInMatriceDesPossibles(evt.nowval[1], groupeSonLocal, evt.nowval[0]) === -1) {
933
+ return;
934
+ }
935
+
936
+ // INFORMATION VERS CLIENT CONTROLEUR POUR AFFICHAGE (son, groupe, status)
937
+ var message = {
938
+ type: "setInMatrix",
939
+ son: groupeSonLocal,
940
+ groupe: evt.nowval[1],
941
+ status: evt.nowval[0]
942
+ }
943
+ //console.log("groupecliensSons:socketControleur automate:", socketControleur);
944
+ if (socketControleur !== undefined) {
945
+ if (socketControleur.readyState == 1) {
946
+ socketControleur.send(JSON.stringify(message));
947
+ } else {
948
+ if (debug) console.log("WARN: groupecliensSons:socketControleur: status:", socketControleur.readyState);
949
+ }
950
+ }
951
+ // Info pour les scrutateurs et score [groupeClient, groupeDeSons, status];
952
+ var messageScrut = [evt.nowval[1], groupeSonLocal, evt.nowval[0]];
953
+ var msg = {
954
+ type: "setInMatriceDesPossibles",
955
+ value: messageScrut
956
+ }
957
+ serv.broadcast(JSON.stringify(msg));
958
+ messageLog.type = "signal";
959
+ messageLog.value = evt.type;
960
+ logInfoAutomate(messageLog);
961
+ });
962
+ }
963
+ }
964
+
965
+ // Listener des signaux pour les commandes OSC direct
966
+ // Inutile si les message OSC sont envoyés sans passer par des signaux, ce qui est plus simple.
967
+ /* if(par.gameOSCOut !== undefined){
968
+ for (var i=0; i < par.gameOSCOut.length; i++) {
969
+ var signal = par.gameOSCOut[i];
970
+ if(debug1) console.log("Signal OSC ajouté:", signal);
971
+ machine.addEventListener( signal , function(evt) {
972
+ if(debug1) console.log("groupeClientsSons:Emission d'une commande OSC depuis orchestration:", evt.signame);
973
+ oscMidiLocal.sendOSCGame(evt.signame, evt.nowval);
974
+ });
975
+ }
976
+ }*/
977
+ }
978
+
979
+ function makeListener(machine) {
980
+
981
+ /*
982
+ // Listener des signaux pour les jeux avec commandes OSC
983
+ if(par.gameOSCOut !== undefined){
984
+ for (var i=0; i < par.gameOSCOut.length; i++) {
985
+ var signal = par.gameOSCOut[i];
986
+ if(debug) console.log("Signal OSC ajouté:", signal);
987
+ machine.addEventListener( signal , function(evt) {
988
+ if(debug) console.log("groupeClientsSons:Emission d'une commande OSC depuis orchestration:", evt.signame);
989
+ oscMidiLocal.sendOSCGame(evt.signame, evt.nowval);
990
+ });
991
+ }
992
+ }
993
+
994
+ machine.addEventListener( "patternListLength" , function(evt) {
995
+
996
+ function sendMessage(nbePatternsListes){
997
+ if(debug) console.log("groupecliensSons.js: patternListLength:", nbePatternsListes);
998
+ hop.broadcast('nombreDePatternsPossible', nbePatternsListes);
999
+ }
1000
+
1001
+ // Mise à jour du suivi des longueurs de listes
1002
+ for (var i=0; i < nombreDePatternsPossibleEnListe.length; i++){
1003
+ if( nombreDePatternsPossibleEnListe[i][1] === evt.nowval[1]){
1004
+ nombreDePatternsPossibleEnListe[i][0] = evt.nowval[0];
1005
+ sendMessage(nombreDePatternsPossibleEnListe);
1006
+ return;
1007
+ }
1008
+ }
1009
+ nombreDePatternsPossibleEnListe.push([evt.nowval[0], evt.nowval[1]]);
1010
+ sendMessage(nombreDePatternsPossibleEnListe);
1011
+ });
1012
+
1013
+ */
1014
+ }