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,1171 @@
1
+ /**
2
+ * @fileOverview Display the score of the Skini piece
3
+ *
4
+ * browserify parto1.js -o parto1bundle.js
5
+ *
6
+ * @author Bertrand Petit-Hédelin <bertrand@hedelin.fr>
7
+ * @version 1.0
8
+ * @copyright (C) 2022 Bertrand Petit-Hédelin
9
+ *
10
+ * This program is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ */
23
+ "use strict"
24
+
25
+ var ipConfig = require('../../serveur/ipConfig');
26
+
27
+ var debug = false;
28
+ var debug1 = true;
29
+ var demandeDeSons = "";
30
+ var par;
31
+ var ws;
32
+ var msg;
33
+ var index = Math.floor((Math.random() * 1000000) + 1 ); // Pour identifier le client;
34
+
35
+ //var abletonON;
36
+ var refProcessing;
37
+ var noScore = false;
38
+ var displayNonActiveGroups = true;
39
+
40
+ // Pour un affichage dynamique des scènes graphique.
41
+ // Si dans le fichier de description aucune scène n'est donnée
42
+ // les éléments créés seront dans une scène 0.
43
+ var ongoingGraphicScene = [0];
44
+ var alertInfoMessage;
45
+
46
+ // Couleurs inactives en RGB
47
+ const Rinactive = 10;
48
+ const Ginactive = 10;
49
+ const Binactive = 10;
50
+
51
+ const courbure = 40;
52
+ // Paramètres graphiques
53
+ // Taille du canvas
54
+ var screenX = 1600;
55
+ var screenY = 1200;
56
+
57
+ var increaseTank = 13;
58
+
59
+ var patternGroups; // Groupes des patterns reçu du serveur
60
+
61
+ // On conçoit la partition dans un carré Xbase, Ybase
62
+ // Bases de calcul des largeur et hauteur, li'dée et de permettre un modification de la taille de
63
+ // l'écran sans toucher à la description de la partition.
64
+ // height * screenY / Ybase, width * screenX / Xbase
65
+ var Xbase = 1000;
66
+ var Ybase = 1000;
67
+
68
+ var textSize = 20 * screenY / Ybase;
69
+
70
+ /*
71
+ On utilise logosParameters pour décrire la partition.
72
+ Pour éviter des manipulations sur les accès dans le tableau groupeDesSons,
73
+ j'utilise le fait que les groupes se succèdent pour les indexer..
74
+ Du coup le champ 1 qui donne un numéro de groupe est inutile.
75
+ Par prudence je le laisse ne sachant plus trop comment il est utilisé ailleurs.
76
+ */
77
+
78
+ // La version processing.min.js ne sais pas gérer les couleur en hexa.
79
+ function hex_to_RGB(hex) {
80
+ var m = hex.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
81
+ return [ parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16)];
82
+ }
83
+
84
+ /********************
85
+ Graphical Objects
86
+ *********************/
87
+ class Rectangle {
88
+ constructor(x,y, width, height, color, text, processing){
89
+ if (debug) console.log("constructor rectangle:", x,y, width, height, color, text);
90
+ this.x = x * screenX / Xbase;
91
+ this.y = y * screenY / Ybase;
92
+ this.height = height * screenY / Ybase;
93
+ this.width = width * screenX / Xbase;
94
+ this.colorRect = color.slice();
95
+ this.text = text;
96
+ this.message1 = "";
97
+ this.message2 = "";
98
+ this.processing = processing;
99
+ this.countSounds = "";
100
+ if (debug) console.log("Rectangle : constructor: setColor:", color, this.colorRect);
101
+ }
102
+
103
+ setSize(width, height){
104
+ this.height = height * screenY / Ybase;
105
+ this.width = width * screenX / Xbase;
106
+ }
107
+
108
+ setColor(couleur){
109
+ this.colorRect = couleur.slice(); // Pour recopier et pas assigner
110
+ if (debug) console.log("Rectangle: setColor:", couleur, this.colorRect);
111
+ }
112
+
113
+ setCoundSounds(counter){
114
+ this.countSounds = counter;
115
+ }
116
+
117
+ setMessage(message1, message2){
118
+ this.message1 = message1;
119
+ this.message2 = message2;
120
+ }
121
+
122
+ display() {
123
+ // Façon peu économique de définir les tailles des chaines de caractère pour dimensioner le rectangle
124
+ this.processing.textSize(this.height*1.5/3);
125
+ this.processing.text(this.message1.slice(0,10), this.x + 5, this.y + (this.height * 1.5/3), this.processing.textWidth(this.message1.slice(0,10)));
126
+ var localWidth1 = this.processing.textWidth(this.message1.slice(0,17));
127
+
128
+ this.processing.textSize(this.height*1/3);
129
+ this.processing.text(this.message2.slice(0,17), this.x + 5, this.y + (this.height) -5, this.processing.textWidth(this.message2.slice(0,17)));
130
+ var localWidth2 = this.processing.textWidth(this.message2.slice(0,17));
131
+
132
+ this.width = Math.max(this.width, localWidth1 + 10, localWidth2 + 10);
133
+ this.processing.fill(this.colorRect[0], this.colorRect[1], this.colorRect[2]);
134
+ this.processing.rect(this.x, this.y, this.width, this.height,this.radius);
135
+
136
+ // Affichage des textes
137
+ this.processing.fill(0); // En noir
138
+ this.processing.textSize(textSize);
139
+ this.processing.text(this.text, this.x, this.y -3 ); //, this.width, this.height);
140
+
141
+ this.processing.fill(255); // En blanc
142
+ this.processing.textSize(this.height*1.5/3);
143
+ this.processing.text(this.message1.slice(0,10), this.x + 5, this.y + (this.height * 1.5/3), this.processing.textWidth(this.message1.slice(0,10)));
144
+ this.processing.textSize(this.height*1/3);
145
+ this.processing.text(this.message2.slice(0,17), this.x + 5, this.y + (this.height) -5, this.processing.textWidth(this.message2.slice(0,17)));
146
+ //this.processing.text(this.message2.slice(0,20), this.x + 5, this.y + (this.height * 4/5));
147
+ //this.processing.text(this.countSounds, this.x + this.width/2 - 50, this.y + (this.height*3/4));
148
+ }
149
+ }
150
+
151
+ // Assignation d'une proprité à une classe
152
+ Rectangle.prototype.radius = 10;
153
+
154
+ class Ellipse {
155
+ constructor(x,y, width, height, color, text, processing){
156
+ if (debug) console.log("constructor ellipse:", x,y, width, height, color, text);
157
+ this.x = x * screenX / Xbase;
158
+ this.y = y * screenY / Ybase;
159
+ this.height = height * screenY/Ybase;
160
+ this.width = width * screenX/Xbase;
161
+ this.colorEllipse = color.slice();
162
+ this.text = text;
163
+ this.message1 = "";
164
+ this.message2 = "";
165
+ this.processing = processing;
166
+ }
167
+
168
+ setSize(width, height){
169
+ this.height = height * screenY/Ybase;
170
+ this.width = width * screenX/Xbase;
171
+ }
172
+
173
+ setColor(color){
174
+ this.colorEllipse = color.slice();
175
+ if (debug) console.log("Rectangle: setColor:", color, this.colorEllipse);
176
+ }
177
+
178
+ setMessage(message1, message2){
179
+ this.message1 = message1;
180
+ this.message2 = message2;
181
+ }
182
+
183
+ display() {
184
+ this.processing.fill(this.colorEllipse[0], this.colorEllipse[1], this.colorEllipse[2]);
185
+ // L'ellipse est centrée de façon à être dans un rectangle.
186
+ // L'idée est de garder le même modèle de coordonnée pour Rectangle et Ellipse.
187
+ this.processing.ellipse(this.x+this.width/2 , this.y+this.height/2, this.width, this.height);
188
+ this.processing.fill(0);
189
+
190
+ this.processing.textSize(textSize);
191
+ this.processing.text(this.text, this.x, this.y); //, this.width, this.height);
192
+
193
+ this.processing.fill(255); // En blanc
194
+ this.processing.textSize(this.height*1.5/3);
195
+ this.processing.text(this.message1.slice(0,10), this.x + 5, this.y + (this.height * 1.5/3), this.processing.textWidth(this.message1.slice(0,10)));
196
+ this.processing.textSize(this.height*1/3);
197
+ this.processing.text(this.message2.slice(0,18), this.x + 5, this.y + (this.height) -5, this.processing.textWidth(this.message2.slice(0,18)));
198
+ }
199
+ }
200
+
201
+ /*************************
202
+ Orchestral Objects
203
+
204
+ *************************/
205
+
206
+ class Tank extends Rectangle {
207
+ constructor(indexTank, tankNumber, x, y, color, text, previous, graphicScene, processing){
208
+ var width = 0;
209
+ var height = 0;
210
+
211
+ // Pour initialiser le rectangle
212
+ super(x, y, width, height, [Rinactive,Ginactive,Binactive],text, processing); // Attention: "super" à placer avant les références à this
213
+ this.indexTank = indexTank;
214
+
215
+ this.width = 0;
216
+ this.height = 0;
217
+ this.colorTank = color.slice();
218
+ this.tankNumber = tankNumber;
219
+ this.signalCount = 1; // au départ
220
+ this.signalCountMax = 1;
221
+ this.graphicScene = graphicScene;
222
+ this.processing = processing;
223
+ this.active = false;
224
+ this.couleurInactiveTank = [Rinactive,Ginactive,Binactive];
225
+ this.previousGroups = previous;
226
+ this.name = text;
227
+ }
228
+
229
+ decrement() {
230
+ this.signalCount--;
231
+ if (this.signalCount < 0) this.signalCount = 0; // Protection
232
+ if (debug1) console.log("decrement Group:", this.signalCount, ":", this.width, this.height);
233
+ if (this.signalCount === 0 ) {
234
+ this.active = false;
235
+ }
236
+ this.width = this.signalCount * increaseTank;
237
+ this.height = this.signalCount * increaseTank;
238
+ super.setSize(this.width, this.height);
239
+ if (this.active){
240
+ /* Il faut faire autre chose que changer la couleur
241
+ this.colorTank[0] = Math.floor(Math.random() * 255);
242
+ this.colorTank[1] = Math.floor(Math.random() * 255);
243
+ this.colorTank[2] = Math.floor(Math.random() * 255);
244
+ */
245
+ super.setColor(this.colorTank);
246
+ }else{
247
+ super.setColor([Rinactive,Ginactive,Binactive]);
248
+ }
249
+ return this.signalCount;
250
+ }
251
+
252
+ isTank(){
253
+ return true;
254
+ }
255
+
256
+ getX(){
257
+ return this.x;
258
+ }
259
+
260
+ getY(){
261
+ return this.y;
262
+ }
263
+
264
+ getWidth(){
265
+ return this.width;
266
+ }
267
+
268
+ getHeight(){
269
+ return this.height;
270
+ }
271
+
272
+ getPrevious() {
273
+ return this.previousGroups;
274
+ }
275
+
276
+ getName(){
277
+ return this.name;
278
+ }
279
+
280
+ getTankNumber(){
281
+ return this.tankNumber;
282
+ }
283
+
284
+ getIndex(){
285
+ return this.indexTank;
286
+ }
287
+
288
+ getGraphicScene(){
289
+ return this.graphicScene;
290
+ }
291
+
292
+ activate() {
293
+ super.setColor(this.colorTank);
294
+ this.active = true;
295
+ }
296
+
297
+ reactivate() {
298
+ super.setColor(this.colorTank);
299
+ this.active = true;
300
+ this.signalCount = this.signalCountMax;
301
+ }
302
+
303
+ deactivate() {
304
+ this.active = false;
305
+ super.setColor([Rinactive,Ginactive,Binactive]);
306
+ }
307
+
308
+ isActive(){
309
+ return this.active;
310
+ }
311
+
312
+ incrementSignalCount(sizeIncrease){
313
+ this.signalCount++;
314
+ this.signalCountMax = this.signalCount;
315
+ this.width = this.signalCount * sizeIncrease;
316
+ this.height = this.signalCount * sizeIncrease;
317
+ super.setSize(this.width, this.height);
318
+ if (debug) console.log("Increment tank:", this.signalCount);
319
+ return this.signalCount;
320
+ }
321
+
322
+ display(){
323
+ // Assignation d'une proprité à une classe
324
+ Rectangle.prototype.radius = 0;
325
+ this.processing.strokeWeight(3);
326
+ super.display();
327
+ }
328
+ // Appelable dans la classe, mais pas par une instance
329
+ // fonction générique (local) à une classe et pas accessible en dehors.
330
+ /* static distance(a, b) {
331
+ const dx = a.x - b.x;
332
+ const dy = a.y - b.y;
333
+ return Math.hypot(dx, dy);
334
+ }*/
335
+ }
336
+
337
+ class Group extends Rectangle {
338
+ constructor(indexGroup, signalCount, x, y, couleur, text, previous, graphicScene, processing){
339
+ var width = signalCount * 6;
340
+ var height = signalCount * 4;
341
+
342
+ // Pour initialiser le rectangle
343
+ super(x, y, width, height, [Rinactive,Ginactive,Binactive], text, processing); // Attention: "super" à placer avant les références à this
344
+ this.indexGroup = indexGroup;
345
+ this.signalCount = signalCount;
346
+ this.width = width * screenX/Xbase;
347
+ this.height = height * screenY/Ybase;
348
+ this.colorGroup = couleur;
349
+ this.graphicScene = graphicScene;
350
+ this.processing = processing;
351
+ this.active = false;
352
+ this.couleurInactiveGroup = [Rinactive,Ginactive,Binactive];
353
+ this.name = text;
354
+ // colorInactive; attention au passage des objets (objet, arrays, ) par lien (ou référence)
355
+ // Si on met couleurInactive dans le "='', on lie couleurInactiveGroup à l'objet couleurInactive
356
+ // du coup quand on appelle desactivate() on passe un lien vers le tableau couleurInactive dans le parent rectangle
357
+ // avec l'instruction super.setColor(this.couleurInactiveGroup); .
358
+ // Le this.colorRect de rectangle est alors en fait le tableau couleurInactive.
359
+ // Toute modification sur this.colorRect va en fait modifier couleurInactive.
360
+ // Pour casser ce lien il faut réassigner couleurInactiveGroup (assignement vs mutate)
361
+ this.previousGroups = previous;
362
+ this.counterOfSounds = 0;
363
+ }
364
+
365
+ increment() {
366
+ this.signalCount++;
367
+ if (debug) console.log("increment Group:", this.signalCount);
368
+
369
+ this.counterOfSounds++;
370
+ super.setCoundSounds(this.counterOfSounds);
371
+ /* Faire autre chose !!
372
+ this.colorRect[0] = Math.floor(Math.random() * 127 + 100);
373
+ this.colorRect[1] = Math.floor(Math.random() * 127 + 100);
374
+ this.colorRect[2] = Math.floor(Math.random() * 127 + 100);
375
+ */
376
+ return this.signalCount;
377
+ }
378
+
379
+ setMessage(message1, message2){
380
+ super.setMessage(message1, message2);
381
+ }
382
+
383
+ isTank(){
384
+ return false;
385
+ }
386
+
387
+ getX(){
388
+ return this.x;
389
+ }
390
+
391
+ getY(){
392
+ return this.y;
393
+ }
394
+
395
+ getWidth(){
396
+ return this.width;
397
+ }
398
+
399
+ getHeight(){
400
+ return this.height;
401
+ }
402
+
403
+ getPrevious() {
404
+ return this.previousGroups;
405
+ }
406
+
407
+ getName(){
408
+ return this.name;
409
+ }
410
+
411
+ getIndex() {
412
+ return this.indexGroup;
413
+ }
414
+
415
+ activate() {
416
+ super.setColor(this.colorGroup);
417
+ if (debug) console.log("class group: activate: ", this.name, this.colorGroup );
418
+ this.active = true;
419
+ }
420
+
421
+ deactivate() {
422
+ if (debug) console.log("deactivate rectangle:", this.name);
423
+ super.setColor([Rinactive,Ginactive,Binactive]);
424
+ this.counterOfSounds = 0;
425
+ this.active = false;
426
+ }
427
+
428
+ isActive(){
429
+ return this.active;
430
+ }
431
+
432
+ getGraphicScene(){
433
+ return this.graphicScene;
434
+ }
435
+
436
+ display(){
437
+ // Assignation d'une proprité à une classe
438
+ Rectangle.prototype.radius = 20;
439
+ super.display();
440
+ }
441
+ }
442
+
443
+ /********************************************************
444
+ Affichage des FIFOs
445
+
446
+ *********************************************************/
447
+ class infoAudience {
448
+ constructor(processing) {
449
+ this.processing = processing;
450
+ this.text = 'Texte au départ -------------------------------------------------------------';
451
+ this.x = 10;
452
+ this.y = 850;
453
+ this.height = 100 * screenY / Ybase;
454
+ this.width = 1000 * screenX / Xbase;
455
+ this.displaySpeed = 5;
456
+ this.displayCounter = 0;
457
+ this.textToDisplay = '';
458
+ this.scrollChar = 0;
459
+ this.scrollCounter = 0;
460
+ this.frameSpeed = 0;
461
+ this.frameCounter = 0;
462
+ }
463
+
464
+ setText(text){
465
+ this.text = this.text + " | " + text;
466
+ }
467
+
468
+ // Scrolling pas résolu, en cours.
469
+ display(){
470
+ this.displaySpeed = 500 / (this.text.length + 1);
471
+ this.displayCounter++;
472
+ this.frameCounter++;
473
+
474
+ if (this.displayCounter > this.displaySpeed) {
475
+ this.text = this.text.slice(1, 2000);
476
+ this.scrollChar = this.processing.textWidth(this.text.slice(0,1));
477
+ this.displayCounter = 0;
478
+ // Calcul de la vitesse en nombre de frame entre deux affichages
479
+ // de la chaine de caractère décalée d'un caractère.
480
+ this.frameSpeed = this.frameCounter;
481
+ this.frameCounter = 0;
482
+ // Re-calcul du décalage à faire en nombre de frame.
483
+ this.scrollChar = this.frameSpeed / this.scrollChar;
484
+ if (debug) console.log("displayInfoAudience:", this.frameSpeed, this.scrollChar, this.displaySpeed );
485
+ }
486
+ this.processing.fill(255);
487
+ this.processing.rect(this.x, this.y, this.width, this.height);
488
+ this.processing.fill(0);
489
+ this.processing.textSize(50);
490
+ this.textToDisplay = this.text.slice(0, 80);
491
+
492
+ if ( this.scrollCounter <= 0 ){
493
+ this.scrollCounter = this.scrollChar; // this.displaySpeed ;
494
+ this.processing.text(this.textToDisplay, this.x + 10 - this.scrollCounter, this.y + (this.height*3/4));
495
+ }
496
+ this.scrollCounter --;
497
+ }
498
+ }
499
+
500
+ class infoQueues {
501
+ constructor(processing) {
502
+ this.processing = processing;
503
+ this.xStart = 10;
504
+ this.yStart = 710 * screenY / Ybase;
505
+ this.height = ((1000 * screenY / Ybase) - this.yStart) * screenY / Ybase;
506
+ this.width = 1000 * screenX / Xbase;
507
+ this.cellWidth = 300 * screenX / Xbase ;
508
+ this.cellHeight = 30 * screenY / Ybase;
509
+ this.textToDisplay = '';
510
+ }
511
+
512
+ display(){
513
+ var texte1EnPixel = 0;
514
+ var texte2EnPixel = 0;
515
+ var largeurTexte = 0;
516
+ var legende = "En file d'attente";
517
+ var couleur = hex_to_RGB('#83614C');
518
+
519
+ // Rectangle d'encadrement
520
+ //this.processing.fill(0);
521
+ this.processing.fill(couleur[0], couleur[1], couleur[2]);
522
+
523
+ this.processing.rect(0, this.yStart, this.width, this.height);
524
+
525
+ this.processing.fill(255);
526
+ this.processing.fill(255);
527
+ // Titre du rectangle
528
+ this.processing.textSize(30);
529
+ this.processing.text(legende, this.width - (this.processing.textWidth(legende) + 3), this.yStart +30);
530
+
531
+ if(queuesMessages !== undefined){
532
+ for (var i = 0; i < queuesMessages.length ; i++ ) { // chaque Instrument
533
+ texte1EnPixel = 0;
534
+ texte2EnPixel = 0;
535
+ largeurTexte = 0;
536
+ if(queuesMessages[i][2] !== undefined){
537
+ for (var j=0; j < queuesMessages[i][2].length; j++){ // chaque Array des pseudos et noms
538
+ // Concaténation pseudo et nom
539
+ this.texte1ToDisplay = ' ' + queuesMessages[i][2][j][1];
540
+ this.texte2ToDisplay = ' (' + queuesMessages[i][2][j][0]+ ')';
541
+
542
+ this.processing.textSize(20);
543
+ texte1EnPixel = this.processing.textWidth(this.texte1ToDisplay);
544
+ //this.processing.text(this.textToDisplay, (this.width - this.cellWidth - j * this.cellWidth), (this.yStart + queuesMessages[i][0] * this.cellHeight));
545
+ this.processing.text(this.texte1ToDisplay, (largeurTexte), (this.yStart + queuesMessages[i][0] * this.cellHeight));
546
+ largeurTexte += texte1EnPixel;
547
+
548
+ this.processing.textSize(15);
549
+ texte2EnPixel = this.processing.textWidth(this.texte2ToDisplay) + 10;
550
+ this.processing.text(this.texte2ToDisplay, (largeurTexte), (this.yStart + queuesMessages[i][0] * this.cellHeight));
551
+ largeurTexte += texte2EnPixel;
552
+
553
+ //this.processing.text(this.textToDisplay, (this.width - texteEnPixel - largeurTexte), (this.yStart + queuesMessages[i][0] * this.cellHeight));
554
+
555
+ this.processing.line(0, this.yStart + queuesMessages[i][0] * this.cellHeight + 10, this.width, this.yStart + queuesMessages[i][0] * this.cellHeight + 10);
556
+ }
557
+ }
558
+ }
559
+ }
560
+ }
561
+ }
562
+
563
+
564
+ /*********************************************************
565
+ Affichage Alert et info
566
+ **********************************************************/
567
+ class alertInfo {
568
+ constructor(processing, text) {
569
+ this.processing = processing;
570
+ this.xStart = 100;
571
+ this.yStart = 250;
572
+ this.height = 250 * screenY / Ybase;
573
+ this.width = 250 * screenX / Xbase;
574
+ this.textToDisplay = text;
575
+ }
576
+
577
+ setText(text){
578
+ this.textToDisplay = text;
579
+ }
580
+
581
+ display(){
582
+ this.processing.textSize(90);
583
+ var texteEnPixel = this.processing.textWidth(this.textToDisplay) + 10;
584
+ // Rectangle d'encadrement
585
+ this.processing.fill(0);
586
+ this.processing.rect(this.xStart, this.yStart, texteEnPixel, this.height);
587
+ // Texte
588
+ this.processing.fill(255);
589
+ //this.processing.textAlign(CENTER, CENTER);
590
+ this.processing.text(this.textToDisplay, this.xStart + 5, this.yStart + this.height/2 );
591
+ //this.processing.textAlign(RIGHT, BOTTOM);
592
+ }
593
+ }
594
+
595
+ /*********************************************************
596
+ Gestion des scènes graphiques
597
+
598
+ **********************************************************/
599
+
600
+ function isInOngoingGraphicScene(scene){
601
+ for (var i=0; i < ongoingGraphicScene.length; i++){
602
+ if ( ongoingGraphicScene[i] === scene) return true;
603
+ }
604
+ return false;
605
+ }
606
+
607
+ function addSceneScore(scene){
608
+ // Déjà là
609
+ for (var i=0; i < ongoingGraphicScene.length; i++){
610
+ if ( ongoingGraphicScene[i] === scene){
611
+ return true;
612
+ }
613
+ }
614
+ // Un espace libre ?
615
+ for (var i=0; i < ongoingGraphicScene.length; i++){
616
+ if ( ongoingGraphicScene[i] === -1) {
617
+ ongoingGraphicScene[i] = scene;
618
+ return true;
619
+ }
620
+ }
621
+ ongoingGraphicScene.push(scene);
622
+ return true;
623
+ }
624
+
625
+ function removeSceneScore(scene){
626
+ if( ongoingGraphicScene[ongoingGraphicScene.length - 1] === scene){
627
+ ongoingGraphicScene.pop();
628
+ return true;
629
+ }else{
630
+ for (var i=0; i < ongoingGraphicScene.length; i++){
631
+ if ( ongoingGraphicScene[i] === scene){
632
+ ongoingGraphicScene[i] = -1;
633
+ return true;
634
+ }
635
+ }
636
+ }
637
+ }
638
+
639
+ /**************************
640
+ Processing sketch
641
+ ***************************/
642
+ var groups;
643
+ var tanks;
644
+ var displayAudience;
645
+ var displayQueues;
646
+ var queuesMessages = [];
647
+
648
+ // Simple way to attach js code to the canvas is by using a function
649
+ function sketchProc(processing) {
650
+ var xPrev;
651
+ var widthPrev;
652
+ var yPrev;
653
+ var heightPrev;
654
+ var xStart;
655
+ var yStart;
656
+ var xEnd;
657
+ var yEnd;
658
+ var prevTankNumber = -1;
659
+
660
+ refProcessing = processing; // Pour appeler setup depuis le listener
661
+
662
+ function createTank(index, indexGroup){
663
+ var scene = 0;
664
+
665
+ if (patternGroups[index][8] !== undefined ){
666
+ scene = patternGroups[index][8];
667
+ }
668
+ if (debug1) console.log("createTank:", patternGroups[index][0]);
669
+ groups[indexGroup] = new Tank(
670
+ patternGroups[index][1], // index du tank
671
+ patternGroups[index][5], // numéro du tank
672
+ patternGroups[index][3], // x
673
+ patternGroups[index][4], // y
674
+ hex_to_RGB(patternGroups[index][6]), // color
675
+ patternGroups[index][0], // name
676
+ patternGroups[index][7], // Antécédents
677
+ scene, // Scène graphique
678
+ processing);
679
+ }
680
+
681
+ processing.setup = function() {
682
+ // Création et remplissage du tableau des "groups" et des "tanks"
683
+ groups = new Array(patternGroups.length);
684
+
685
+ var groupsCounter = 0; // index dans l'array groups des objets graphiques
686
+ var sceneGroupe = 0;
687
+
688
+ for (var i=0; i < patternGroups.length; i++) {
689
+ if (patternGroups[i][2] == undefined) {
690
+ alert("ERR: No score defined, choose a score in the controler.");
691
+ noScore = true;
692
+ return;
693
+ }else{
694
+ noScore = false;
695
+ if (patternGroups[i][2] == "group") {
696
+ if (debug) console.log("This one is group", patternGroups[i], groupsCounter);
697
+ if (patternGroups[i][8] !== undefined ){
698
+ sceneGroupe = patternGroups[i][8];
699
+ }else{
700
+ sceneGroupe = 0;
701
+ }
702
+
703
+ groups[groupsCounter] = new Group(
704
+ patternGroups[i][1], // index du groupe
705
+ patternGroups[i][5], // nbe d'éléments
706
+ patternGroups[i][3], // x
707
+ patternGroups[i][4], // y
708
+ hex_to_RGB(patternGroups[i][6]), //color
709
+ patternGroups[i][0], //name
710
+ patternGroups[i][7], // Antécédents
711
+ sceneGroupe, // Scène graphique
712
+ processing);
713
+ groupsCounter++;
714
+ }else if(patternGroups[i][2] == "tank"){
715
+ if (debug) console.log("This one is the tank:", patternGroups[i][0]);
716
+ if ( i > 0){
717
+ // C'est ici que l'on gére les tanks de façon séquentielle
718
+ // On regarde si le prédécesseur est dans le même tank.
719
+ // Cela pose une contrainte sur le fichier de configuration graphique.
720
+ // Il faut que des groupes dans un même tank se suivent.
721
+ if (groups[groupsCounter-1].isTank()){
722
+ if (debug) console.log("Previous is the tank:", groups[groupsCounter-1].getName());
723
+ if(groups[groupsCounter-1].getTankNumber() == patternGroups[i][5]) {
724
+ if (debug) console.log("We are in the same tank number:", groups[groupsCounter-1].getTankNumber() );
725
+ groups[groupsCounter-1].incrementSignalCount(increaseTank);
726
+
727
+ }else{
728
+ if (debug) console.log("We are not in the same tank:", groups[groupsCounter-1].getTankNumber());
729
+ // !! i dans createTank ??
730
+ createTank(i, groupsCounter);
731
+ groupsCounter++;
732
+ }
733
+ }else{
734
+ if (debug) console.log("Previous is not a tank, create the tank");
735
+ createTank(i, groupsCounter);
736
+ groupsCounter++;
737
+ }
738
+ }else{
739
+ if (debug) console.log("we are the first of tanks and groups ")
740
+ createTank(i, groupsCounter);
741
+ groupsCounter++;
742
+ }
743
+ }else{
744
+ // Ni group, ni tank, donc on n'affichera pas dans score
745
+ if (debug) console.log("Not a group or a tank ");
746
+ }
747
+ }
748
+ }
749
+ if(debug) console.log("setup: Groups:", groups);
750
+ processing.size(screenX,screenY);
751
+ processing.stroke(126);
752
+ processing.strokeWeight(3);
753
+
754
+ displayAudience = new infoAudience(processing);
755
+ displayQueues = new infoQueues(processing);
756
+ }
757
+
758
+ // Façon d'utiliser la souris
759
+ /*processing.mouseMoved = function () {
760
+ console.log("mouse moved:", processing.mouseX, processing.mouseY);
761
+ processing.ellipse(processing.mouseX, processing.mouseY, 50,50);
762
+ if(processing.mouseIsPressed) {
763
+ console.log("mouse pressed:", processing.mouseX, processing.mouseY);
764
+ processing.ellipse(processing.mouseX, processing.mouseY, 100,100);
765
+ }
766
+ }
767
+ */
768
+ processing.draw = function() {
769
+ // erase background
770
+ processing.background(224);
771
+ if (noScore) return;
772
+
773
+ //displayAudience.display();
774
+ displayQueues.display();
775
+
776
+ // Display groups et tanks
777
+ for (var i=0; i < groups.length; i++) {
778
+ // Quand il ya des tanks, le nombre de groupes sera < au tableau patternGroups
779
+ if (groups[i] == undefined) {
780
+ break;
781
+ }
782
+ if (groups[i].isActive() || displayNonActiveGroups){ // On n'affiche que les groupes actifs
783
+ // On épaissit les bords en fonction du nombre d'activation
784
+ if (!groups[i].isTank()) processing.strokeWeight(groups[i].counterOfSounds);
785
+ if( isInOngoingGraphicScene(groups[i].getGraphicScene())){
786
+ groups[i].display();
787
+ }
788
+ processing.strokeWeight(3);
789
+ }
790
+
791
+ // Affichage des liens
792
+ // Repérage des antécédents (prev)
793
+ var IndexPrev = groups[i].getPrevious();
794
+ if (IndexPrev.length > 1 ){
795
+ for (var j=0; j < IndexPrev.length; j++ ) {
796
+ // On ne relie que des groupes actifs
797
+ if(groups[ IndexPrev[j] ].isActive() && groups[i].isActive() || displayNonActiveGroups){
798
+
799
+ // On ne relie que si la scène graphique est != 0
800
+ if(isInOngoingGraphicScene(groups[ IndexPrev[j] ].getGraphicScene()) &&
801
+ isInOngoingGraphicScene(groups[i].getGraphicScene())) {
802
+ // coordonnées en (xPrev + widthPrev, Yprev + heightPrev/2)
803
+ xPrev = groups[ IndexPrev[j] ].getX();
804
+ widthPrev = groups[ IndexPrev[j] ].getWidth();
805
+ xStart = xPrev + widthPrev;
806
+ yPrev = groups[ IndexPrev[j] ].getY();
807
+ heightPrev = groups[ IndexPrev[j] ].getHeight();
808
+ yStart = yPrev + heightPrev/2;
809
+
810
+ xEnd = groups[i].getX();
811
+ yEnd = groups[i].getY() + groups[i].getHeight()/2;
812
+ processing.noFill();
813
+ // Triangle en fin de courbe
814
+ processing.triangle( xEnd-10, yEnd-5, xEnd-10, yEnd+5, xEnd, yEnd);
815
+ xEnd -= 10;
816
+ processing.bezier(xStart,yStart, xStart+courbure, yStart, xEnd-courbure,yEnd, xEnd,yEnd);
817
+ }
818
+ }
819
+ }
820
+ }
821
+ }
822
+ // Message qui prend le dessus sur le score
823
+ if (alertInfoMessage !== undefined){
824
+ alertInfoMessage.display();
825
+ }
826
+ }
827
+ }
828
+
829
+ /****************************
830
+ Main
831
+ ****************************/
832
+ var canvas;
833
+ // Il faut initialiser le canvas une seule fois
834
+ // donc la première fois que l'on charge un fichier de config.
835
+ function start() {
836
+ if(canvas === undefined){
837
+ canvas = document.getElementById("canvas1");
838
+ // attaching the sketchProc function to the canvas
839
+ var p = new Processing(canvas, sketchProc);
840
+ }
841
+ }
842
+ window.start = start;
843
+
844
+ /*********************************************************************************
845
+ Communication listeners
846
+
847
+ **********************************************************************************/
848
+
849
+ // Fonctions uniquement utilisées par les listeners *************************************
850
+
851
+ function isTank(nomDeGroupe){
852
+ var isTank = false;
853
+ for(var i=0; i < patternGroups.length; i++){
854
+ if( patternGroups[i][0] == nomDeGroupe) {
855
+ if ( patternGroups[i][2] == "tank"){
856
+ isTank = true ;
857
+ }
858
+ break;
859
+ }
860
+ }
861
+ if (debug) console.log("isTank ?:", isTank);
862
+ return isTank;
863
+ }
864
+
865
+ function isTankFromNumOfGroup(numOfGroup){
866
+ var isTank = false;
867
+ if( patternGroups === undefined) return false;
868
+ for(var i=0; i < patternGroups.length; i++){
869
+ if( patternGroups[i][1] == numOfGroup) {
870
+ if ( patternGroups[i][2] == "tank"){
871
+ isTank = true ;
872
+ }
873
+ break;
874
+ }
875
+ }
876
+ return isTank;
877
+ }
878
+
879
+ function getGroupNumber(nomDeGroupe){
880
+ var groupeDeSons;
881
+ if (debug) console.log("Groupe pour groupname:", nomDeGroupe);
882
+ for(var i=0; i < groups.length; i++){
883
+ if(groups[i].getName() == nomDeGroupe) {
884
+ groupeDeSons = i ;
885
+ break;
886
+ }
887
+ }
888
+ return groupeDeSons;
889
+ }
890
+
891
+ function getNumberInGroupsFromNumberInConf(numOfGroup){
892
+ var groupeDeSons;
893
+ if (debug) console.log("getNumberInGroupsFromNumberInConf:", numOfGroup, groups);
894
+ if( groups === undefined) return -1;
895
+ for(var i=0; i < groups.length; i++){
896
+ if (debug) console.log("getNumberInGroupsFromNumberInConf:groups[i]:", groups[i] );
897
+ if(groups[i].getIndex() == numOfGroup) {
898
+ groupeDeSons = i ;
899
+ break;
900
+ }
901
+ }
902
+ return groupeDeSons;
903
+ }
904
+
905
+ function getTankNumberFromGroupName(nomDeGroupe) {
906
+ if (debug) console.log("getTankNumberFromGroupName: Tank number pour groupname:", nomDeGroupe, patternGroups );
907
+ var tankNumber;
908
+ if( patternGroups === undefined) return -1;
909
+ for(var i=0; i < patternGroups.length; i++){
910
+ if( patternGroups[i][0] == nomDeGroupe) {
911
+ tankNumber = patternGroups[i][5];
912
+ break;
913
+ }
914
+ }
915
+ return tankNumber;
916
+ }
917
+
918
+ function getTankNumberFromNumberInConf(numInConf) {
919
+ var tankNumber;
920
+ for(var i=0; i < patternGroups.length; i++){
921
+ if( patternGroups[i][1] == numInConf) {
922
+ tankNumber = patternGroups[i][5];
923
+ if (debug) console.log("getTankNumberFromNumberInConf:", patternGroups[i], tankNumber );
924
+ break;
925
+ }
926
+ }
927
+ return tankNumber;
928
+ }
929
+
930
+ function getGroupOfSoundsFromTankNumber(tankNumber){
931
+ var groupeDeSons = -1;
932
+ if(groups === undefined) return -1;
933
+ for(var i=0; i < groups.length; i++){
934
+ if (groups[i].isTank() ){
935
+ if(groups[i].getTankNumber() == tankNumber) {
936
+ if (debug) console.log("getGroupOfSoundsFromTankNumber:", groupeDeSons, tankNumber );
937
+ groupeDeSons = i ;
938
+ break;
939
+ }
940
+ }
941
+ }
942
+ return groupeDeSons;
943
+ }
944
+
945
+ function getPatternGroups(){
946
+ var msg = {
947
+ type:"getPatternGroups",
948
+ id: index
949
+ }
950
+ ws.send(JSON.stringify(msg));
951
+ }
952
+ window.getPatternGroups = getPatternGroups;
953
+
954
+ /* Les listeners *****************************************************************************/
955
+
956
+ //************ WEBSOCKET HOP et listener BROADCAST ******************************
957
+ function initWSSocket(host) {
958
+ ws = new WebSocket("ws://" + host + ":" + ipConfig.websocketServeurPort); // NODE JS
959
+
960
+ if (debug1) console.log("score.js ws://" + host + ":" + ipConfig.websocketServeurPort );
961
+ ws.onopen = function( event ) {
962
+ var msg = {
963
+ type:"startSpectateur",
964
+ text: "score",
965
+ id: index
966
+ }
967
+ console.log("ID sent to server:", msg.id);
968
+ ws.send(JSON.stringify(msg));
969
+
970
+ var msg = {
971
+ type:"getPatternGroups",
972
+ id: index
973
+ }
974
+ ws.send(JSON.stringify(msg));
975
+ };
976
+
977
+ //Traitement de la Réception sur le client
978
+ ws.onmessage = function( event ) {
979
+ //console.log( "Client: received [%s]", event.data );
980
+
981
+ var msgRecu = JSON.parse(event.data);
982
+ if(debug) console.log("message reçu: ", msgRecu.type);
983
+
984
+ switch(msgRecu.type) {
985
+
986
+ case 'addSceneScore':
987
+ if (debug1) console.log("Reçu addScenceScore:", msgRecu.value );
988
+ addSceneScore(msgRecu.value);
989
+ break;
990
+
991
+ // Pour activer un affichage d'info
992
+ case 'alertInfoScoreON':
993
+ if (refProcessing !== undefined){
994
+ alertInfoMessage = new alertInfo(refProcessing, msgRecu.value);
995
+ }
996
+ break;
997
+
998
+ // Pour désactiver un affichage d'info
999
+ case 'alertInfoScoreOFF':
1000
+ alertInfoMessage = undefined;
1001
+ break;
1002
+
1003
+ case 'etatDeLaFileAttente':
1004
+ queuesMessages = [];
1005
+ for (var i = 0; i < msgRecu.value.length ; i++ ) {
1006
+ queuesMessages[i] = msgRecu.value[i];
1007
+ // voir displayQueue de controleDAW pour la structure de queueMessages
1008
+ // [i, filesDattente[i].length, contenuDeLaFile]
1009
+ if(debug) console.log("etatDeLaFileAttente:", i, "--", queuesMessages[i]);
1010
+ }
1011
+ break;
1012
+
1013
+ // Action sur sur les sons qui sont joués
1014
+ case 'infoPlayDAW':
1015
+ var groupeDeSons;
1016
+ if (debug) console.log("Reçu Texte Broadcast infoPlayDAW: msgRecu.value:", msgRecu.value[5], msgRecu.value[7]);
1017
+
1018
+ displayAudience.setText(msgRecu.value[5] + " - " + msgRecu.value[7]);
1019
+ // Event.value = bus, channel, note, velocity, wsid, pseudo, dureeClip, nom, signal
1020
+ // Celle-là elle ne s'invente pas, récupération du nom du groupe dans le signal
1021
+ var groupName = Object.keys(msgRecu.value[8])[0].slice(0, -2);
1022
+ if (debug) console.log("Reçu Texte Broadcast infoPlayDAW: groupName:", groupName);
1023
+
1024
+ var tankNumber;
1025
+
1026
+ if ( patternGroups !== undefined) {
1027
+ if (!isTank(groupName)) {
1028
+ // S'il s'agit d'un "group" recherche du groupe de son pour le signal donné
1029
+ // dans le tableau des groups et tanks consécutifs
1030
+ var groupNumber = getGroupNumber(groupName);
1031
+ if(debug) console.log("infoPlayDAW:groupNumber", groupNumber);
1032
+ if(groupNumber === undefined){
1033
+ if(debug) console.log("infoPlayDAW:groupNumber: undefined");
1034
+ break;
1035
+ }
1036
+
1037
+ var groupRunning = groups[groupNumber];
1038
+
1039
+ if (groupRunning.isActive()){
1040
+ groupRunning.setMessage(msgRecu.value[5], msgRecu.value[7]);
1041
+ groupRunning.increment();
1042
+ }
1043
+ } else {
1044
+ // S'il s'agit d'un "tank"
1045
+ if (debug) console.log("Reçu Texte Broadcast infoPlayDAW: groupName", groupName );
1046
+ var tankNumber = getTankNumberFromGroupName(groupName);
1047
+ if(tankNumber === -1){
1048
+ if(debug) console.log("infoPlayDAW: getTankNumberFromGroupName retourne ERR: ", groupName);
1049
+ break;
1050
+ }
1051
+ var desSons = getGroupOfSoundsFromTankNumber(tankNumber);
1052
+ if(desSons === -1){
1053
+ if(debug) console.log("infoPlayDAW: getGroupOfSoundsFromTankNumber retourne ERR");
1054
+ break;
1055
+ }
1056
+
1057
+ if (desSons < 0 ) console.log("ERR: addEventListener: infoPlayAbleton: getGroupOfSoundsFromTankNumber ");
1058
+ groups[desSons].setMessage(msgRecu.value[5], msgRecu.value[7]);
1059
+ groups[desSons].decrement();
1060
+ }
1061
+ }
1062
+ break;
1063
+
1064
+ // Pour désactiver un réservoir quand il est aborté dans la pièce.
1065
+ case 'killTank':
1066
+ var tankNumber = getTankNumberFromGroupName( msgRecu.value );
1067
+ if(tankNumber === -1){
1068
+ if(debug) console.log("killTank: getTankNumberFromGroupName retourne ERR");
1069
+ break;
1070
+ }
1071
+ var desSons = getGroupOfSoundsFromTankNumber(tankNumber);
1072
+ if(desSons === -1){
1073
+ if(debug) console.log("killTank: getGroupOfSoundsFromTankNumber retourne ERR");
1074
+ break;
1075
+ }
1076
+ if (debug) console.log("KILL TANK:", msgRecu.value, tankNumber, desSons );
1077
+ groups[desSons].deactivate();
1078
+ break;
1079
+
1080
+ // Remise à l'état d'origine des éléments
1081
+ case 'refreshSceneScore':
1082
+ if (debug1) console.log("Reçu refreshSceneScore:", msgRecu.value );
1083
+ if ( refProcessing !== undefined && patternGroups !== undefined ){
1084
+ refProcessing.setup();
1085
+ }
1086
+ break;
1087
+
1088
+ // Enlève une scène graphique
1089
+ case 'removeSceneScore':
1090
+ if (debug1) console.log("Reçu removeSceneScore:", msgRecu.value );
1091
+ removeSceneScore(msgRecu.value);
1092
+ break;
1093
+
1094
+ /* Info sur changement de la matrice des possibles */
1095
+ /* Ici on sait seulement si un groupe est activé ou désactivé.
1096
+ Il n'y a pas de notion de réservoir dans le protocole.
1097
+ Un réservoir est un ensemble de groupes ayant chacun un seul son.
1098
+ Il n'y a donc pas de notion d'activation ou désactivation de réservoir.
1099
+
1100
+ Dans le cas d'un réservoir ce listener donne une information que
1101
+ l'on a déjà reçue dans infoPlayAbleton car pour un réservoir un son joué implique
1102
+ une modification de la matrice des possibles.
1103
+ */
1104
+ case 'setInMatriceDesPossibles':
1105
+ var groupsNumber;
1106
+ if (debug1) console.log("Reçu setInMatriceDesPossibles:", msgRecu.value );
1107
+ // [0] = groupe de clients, [1] = index du groupe de son dans le tableau du fichier de conf, [2] = true ot false
1108
+ if ( isTankFromNumOfGroup(msgRecu.value[1])){
1109
+ var tankNumber = getTankNumberFromNumberInConf(msgRecu.value[1]);
1110
+ groupsNumber = getGroupOfSoundsFromTankNumber(tankNumber);
1111
+ if (groupsNumber < 0 ) console.log("ERR: addEventListener: setInMatriceDesPossibles: getGroupOfSoundsFromTankNumber ");
1112
+ }else{
1113
+ groupsNumber = getNumberInGroupsFromNumberInConf(msgRecu.value[1]);
1114
+ if(groupsNumber === -1) break;
1115
+ }
1116
+
1117
+ if (msgRecu.value[2]) { // On or Off
1118
+ groups[groupsNumber].activate();
1119
+ }else{
1120
+ if( groups[groupsNumber] !== undefined){
1121
+ if (!groups[groupsNumber].isTank()){
1122
+ groups[groupsNumber].deactivate();
1123
+ }
1124
+ }
1125
+ }
1126
+ break;
1127
+
1128
+ // Réception des groupes de patterns
1129
+ case 'setPatternGroups':
1130
+ if(debug) console.log("setPatternGroups: ", msgRecu.value);
1131
+ if ( msgRecu.value !== undefined ) {
1132
+ patternGroups = msgRecu.value ;
1133
+ noScore = false;
1134
+ start();
1135
+ if (refProcessing !== undefined){
1136
+ refProcessing.setup();
1137
+ }
1138
+ }
1139
+ break;
1140
+
1141
+ case 'startTank':
1142
+ var tankNumber = getTankNumberFromGroupName( msgRecu.value );
1143
+
1144
+ if(tankNumber === -1){
1145
+ if(debug1) console.log("startTank: getTankNumberFromGroupName retourne ERR: ", msgRecu.value, ": tankNumber :", tankNumber);
1146
+ break;
1147
+ }
1148
+ var desSons = getGroupOfSoundsFromTankNumber(tankNumber);
1149
+ if(desSons === -1){
1150
+ if(debug) console.log("startTank: getGroupOfSoundsFromTankNumber retourne ERR");
1151
+ break;
1152
+ }
1153
+ if (debug) console.log("START TANK:", msgRecu.value, tankNumber, desSons );
1154
+ groups[desSons].reactivate();
1155
+ break;
1156
+
1157
+ default: if (debug) console.log("Le Client reçoit un message inconnu", msgRecu );
1158
+ }
1159
+ };
1160
+
1161
+ ws.onerror = function (event) {
1162
+ if (debug) console.log( "clientcontroleur.js : received error on WS", ws.socket, " ", event );
1163
+ }
1164
+
1165
+ // Mécanisme de reconnexion automatique si le serveur est tombé.
1166
+ // Le service Ping permet de vérifier le présence du serveur
1167
+ ws.onclose = function( event ) {
1168
+ if (debug1) console.log( "clientcontroleur.js : ON CLOSE");
1169
+ }
1170
+ }
1171
+ window.initWSSocket = initWSSocket;