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.
- package/README.md +31 -0
- package/client/archive/bundle.js +11528 -0
- package/client/archive/golem.html +60 -0
- package/client/archive/golemClient.js +595 -0
- package/client/archive/golembundle.js +11634 -0
- package/client/archive/sequencer.html +43 -0
- package/client/archive/sequenceurClient.js +815 -0
- package/client/archive/stylegolem.css +158 -0
- package/client/archive/stylesequenceur.css +204 -0
- package/client/clientListe/Sortable-master/.circleci/config.yml +33 -0
- package/client/clientListe/Sortable-master/.editorconfig +15 -0
- package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/bug-report.md +73 -0
- package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/custom-template.md +48 -0
- package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/feature-request.md +41 -0
- package/client/clientListe/Sortable-master/.jshintrc +25 -0
- package/client/clientListe/Sortable-master/.testcaferc.json +7 -0
- package/client/clientListe/Sortable-master/CONTRIBUTING.md +26 -0
- package/client/clientListe/Sortable-master/LICENSE +21 -0
- package/client/clientListe/Sortable-master/README.md +813 -0
- package/client/clientListe/Sortable-master/Sortable.js +3709 -0
- package/client/clientListe/Sortable-master/Sortable.min.js +2 -0
- package/client/clientListe/Sortable-master/Sortable.min.old.js +2 -0
- package/client/clientListe/Sortable-master/Sortable.min.old.old.js +2 -0
- package/client/clientListe/Sortable-master/babel.config.js +27 -0
- package/client/clientListe/Sortable-master/bower.json +30 -0
- package/client/clientListe/Sortable-master/entry/entry-complete.js +8 -0
- package/client/clientListe/Sortable-master/entry/entry-core.js +19 -0
- package/client/clientListe/Sortable-master/entry/entry-defaults.js +19 -0
- package/client/clientListe/Sortable-master/index.html +460 -0
- package/client/clientListe/Sortable-master/modular/sortable.complete.esm.js +3701 -0
- package/client/clientListe/Sortable-master/modular/sortable.core.esm.js +3698 -0
- package/client/clientListe/Sortable-master/modular/sortable.esm.js +3699 -0
- package/client/clientListe/Sortable-master/package-lock.json +5704 -0
- package/client/clientListe/Sortable-master/package.json +56 -0
- package/client/clientListe/Sortable-master/plugins/AutoScroll/AutoScroll.js +270 -0
- package/client/clientListe/Sortable-master/plugins/AutoScroll/README.md +80 -0
- package/client/clientListe/Sortable-master/plugins/AutoScroll/index.js +1 -0
- package/client/clientListe/Sortable-master/plugins/MultiDrag/MultiDrag.js +617 -0
- package/client/clientListe/Sortable-master/plugins/MultiDrag/README.md +96 -0
- package/client/clientListe/Sortable-master/plugins/MultiDrag/index.js +1 -0
- package/client/clientListe/Sortable-master/plugins/OnSpill/OnSpill.js +79 -0
- package/client/clientListe/Sortable-master/plugins/OnSpill/README.md +60 -0
- package/client/clientListe/Sortable-master/plugins/OnSpill/index.js +1 -0
- package/client/clientListe/Sortable-master/plugins/README.md +178 -0
- package/client/clientListe/Sortable-master/plugins/Swap/README.md +55 -0
- package/client/clientListe/Sortable-master/plugins/Swap/Swap.js +90 -0
- package/client/clientListe/Sortable-master/plugins/Swap/index.js +1 -0
- package/client/clientListe/Sortable-master/scripts/banner.js +8 -0
- package/client/clientListe/Sortable-master/scripts/build.js +17 -0
- package/client/clientListe/Sortable-master/scripts/esm-build.js +28 -0
- package/client/clientListe/Sortable-master/scripts/minify.js +11 -0
- package/client/clientListe/Sortable-master/scripts/test-compat.js +30 -0
- package/client/clientListe/Sortable-master/scripts/test.js +21 -0
- package/client/clientListe/Sortable-master/scripts/umd-build.js +15 -0
- package/client/clientListe/Sortable-master/src/Animation.js +175 -0
- package/client/clientListe/Sortable-master/src/BrowserInfo.js +12 -0
- package/client/clientListe/Sortable-master/src/EventDispatcher.js +57 -0
- package/client/clientListe/Sortable-master/src/PluginManager.js +87 -0
- package/client/clientListe/Sortable-master/src/Sortable.js +1971 -0
- package/client/clientListe/Sortable-master/src/utils.js +556 -0
- package/client/clientListe/Sortable-master/st/app.js +224 -0
- package/client/clientListe/Sortable-master/st/iframe/frame.html +32 -0
- package/client/clientListe/Sortable-master/st/iframe/index.html +49 -0
- package/client/clientListe/Sortable-master/st/logo.png +0 -0
- package/client/clientListe/Sortable-master/st/og-image.png +0 -0
- package/client/clientListe/Sortable-master/st/prettify/prettify.css +1 -0
- package/client/clientListe/Sortable-master/st/prettify/prettify.js +46 -0
- package/client/clientListe/Sortable-master/st/prettify/run_prettify.js +64 -0
- package/client/clientListe/Sortable-master/st/saucelabs.svg +1 -0
- package/client/clientListe/Sortable-master/st/theme.css +254 -0
- package/client/clientListe/Sortable-master/tests/Sortable.compat.test.js +39 -0
- package/client/clientListe/Sortable-master/tests/Sortable.test.js +386 -0
- package/client/clientListe/Sortable-master/tests/dual-list.html +34 -0
- package/client/clientListe/Sortable-master/tests/empty-list.html +30 -0
- package/client/clientListe/Sortable-master/tests/filter.html +27 -0
- package/client/clientListe/Sortable-master/tests/handles.html +27 -0
- package/client/clientListe/Sortable-master/tests/nested.html +67 -0
- package/client/clientListe/Sortable-master/tests/single-list.html +25 -0
- package/client/clientListe/Sortable-master/tests/style.css +18 -0
- package/client/clientListe/clientListe.html +148 -0
- package/client/clientListe/clientListe.js +1508 -0
- package/client/clientListe/clientListebundle.js +13164 -0
- package/client/clientListe/images/poubelle.png +0 -0
- package/client/clientListe/images/start.png +0 -0
- package/client/clientListe/images/stop.png +0 -0
- package/client/clientListe/images/submit.png +0 -0
- package/client/clientListe/sortable-theme-bootstrap.css +90 -0
- package/client/configurateur/configReact.js +273 -0
- package/client/configurateur/configReactbundle.js +295 -0
- package/client/configurateur/configurateur.css +95 -0
- package/client/configurateur/configurateur.html +48 -0
- package/client/configurateur/lib/jexcel.css +755 -0
- package/client/configurateur/lib/jexcel.js +14970 -0
- package/client/configurateur/lib/jsuites.css +2801 -0
- package/client/configurateur/lib/jsuites.js +11822 -0
- package/client/configurateur/lib/react-dom.production.min.js +239 -0
- package/client/configurateur/lib/react.production.min.js +32 -0
- package/client/configurateur/src/configReact.js +247 -0
- package/client/controleur/clientcontroleur.js +536 -0
- package/client/controleur/clientcontroleur.test.js +282 -0
- package/client/controleur/controleur.html +51 -0
- package/client/controleur/controleurbundle.js +565 -0
- package/client/controleur/stylecontroleur.css +236 -0
- package/client/controleurHH/controleurHH.html +71 -0
- package/client/controleurHH/controleurHH.js +252 -0
- package/client/controleurHH/styles/index.css +320 -0
- package/client/controleurHH/styles/material.css +11552 -0
- package/client/parametrage/paramReact.js +473 -0
- package/client/parametrage/paramReactbundle.js +500 -0
- package/client/parametrage/parametrage.css +111 -0
- package/client/parametrage/parametrage.html +163 -0
- package/client/parametrage/src/paramReact.js +459 -0
- package/client/score/hash.js +83 -0
- package/client/score/p5.min.js +3 -0
- package/client/score/parto1.js +1171 -0
- package/client/score/parto1bundle.js +1181 -0
- package/client/score/processing.min.js +431 -0
- package/client/score/score.html +15 -0
- package/client/score/score.js +34 -0
- package/client/simulateurListe/simulateurFork.js +750 -0
- package/client/simulateurListe/simulateurFork.mjs +681 -0
- package/client/simulateurListe/simulateurForkSansReorg.js +569 -0
- package/client/simulateurListe/simulateurListe.js +628 -0
- package/myReact/archive/Nodeemitvaluedlocal1.hh.js +52 -0
- package/myReact/archive/abort-parNode.js +79 -0
- package/myReact/archive/abroNode.js +169 -0
- package/myReact/archive/abroNode2.js +80 -0
- package/myReact/archive/atom.compile.hh.js +51 -0
- package/myReact/archive/await-countNode.js +67 -0
- package/myReact/archive/await-nowvalNode.js +44 -0
- package/myReact/archive/callHH.js +96 -0
- package/myReact/archive/emit-if2.hh.compiled.js +113 -0
- package/myReact/archive/every1Node.js +35 -0
- package/myReact/archive/if-runNode.js +74 -0
- package/myReact/archive/if1Node.js +43 -0
- package/myReact/archive/makeawait.js +0 -0
- package/myReact/archive/myReact.old.js +684 -0
- package/myReact/archive/orchestration.js +281 -0
- package/myReact/archive/orchestration1.js +132 -0
- package/myReact/archive/orchestration1.xml +465 -0
- package/myReact/archive/orchestration2.js +161 -0
- package/myReact/archive/orchestrationHH.mano.js +280 -0
- package/myReact/archive/orchestrationHHTest.js +428 -0
- package/myReact/archive/orchestrationHHTest.xml +234 -0
- package/myReact/archive/orchestrationHHTestRun.js +104 -0
- package/myReact/archive/orchestrationHHTestRun.xml +34 -0
- package/myReact/archive/orchestrationTest0.js +178 -0
- package/myReact/archive/orchestrationTest1.js +181 -0
- package/myReact/archive/orchestrationTest2.js +281 -0
- package/myReact/archive/run3pointsNode.js +59 -0
- package/myReact/archive/runNode.js +123 -0
- package/myReact/archive/runNode2.js +91 -0
- package/myReact/archive/testAwait1.js +141 -0
- package/myReact/archive/testAwait1.xml +86 -0
- package/myReact/archive/testEvery1.js +122 -0
- package/myReact/archive/testEvery1.xml +79 -0
- package/myReact/archive/testHH1.js +135 -0
- package/myReact/archive/testHH1.xml +86 -0
- package/myReact/archive/testHH1revu.js +104 -0
- package/myReact/archive/testHH2.js +122 -0
- package/myReact/archive/testHH2.xml +79 -0
- package/myReact/archive/testHH3.js +130 -0
- package/myReact/archive/testHH3.xml +86 -0
- package/myReact/archive/testHHabort.js +121 -0
- package/myReact/archive/testHHabort.xml +83 -0
- package/myReact/archive/testMakeawait.js +202 -0
- package/myReact/archive/testRun1.js +168 -0
- package/myReact/archive/testRun1.xml +142 -0
- package/myReact/archive/titi.js +28 -0
- package/myReact/archive/titi.xml +110 -0
- package/myReact/archive/toto.js +73 -0
- package/myReact/archive/toto.xml +198 -0
- package/myReact/archive/trap-await-parallelNode.js +123 -0
- package/myReact/inutiles/hiver2022.xml +804 -0
- package/myReact/inutiles/hopeNode.xml +459 -0
- package/myReact/inutiles/mars2022.xml +871 -0
- package/myReact/inutiles/mystique1.xml +318 -0
- package/myReact/inutiles/mystiqueOSC.xml +277 -0
- package/myReact/inutiles/opus5Node.xml +1271 -0
- package/myReact/inutiles/opus5NodeLinux.xml +1241 -0
- package/myReact/inutiles/orchestrationHH.xml +541 -0
- package/myReact/inutiles/orchestrationHH2.xml +547 -0
- package/myReact/inutiles/testHH.xml +95 -0
- package/myReact/inutiles/trouveLaPercuTenor.xml +349 -0
- package/myReact/myReact.js +744 -0
- package/myReact/myReact.min.js +1 -0
- package/myReact/orchestrationHH.js +311 -0
- package/myReact/orchestrationHH.mjs +436 -0
- package/myReact/orchestrationHH.mjs.map +1 -0
- package/package.json +46 -0
- package/serveur/OSCandMidi.mjs +361 -0
- package/serveur/computeScore.mjs +415 -0
- package/serveur/controleDAW.mjs +1149 -0
- package/serveur/defaultSession.csv +2 -0
- package/serveur/defaultSkiniParametres.js +119 -0
- package/serveur/gameOSC.mjs +96 -0
- package/serveur/groupeClientsSons.mjs +1014 -0
- package/serveur/ipConfig.json +24 -0
- package/serveur/ipConfig127.json +19 -0
- package/serveur/ipConfig75.json +17 -0
- package/serveur/ipConfigBH.json +19 -0
- package/serveur/ipConfigLocal.json +19 -0
- package/serveur/midiConfig.json +26 -0
- package/serveur/midiConfigBH.json +26 -0
- package/serveur/midiConfigVoid.json +3 -0
- package/serveur/midimix.mjs +570 -0
- package/serveur/saveParam.mjs +159 -0
- package/serveur/skiniParametres.good.js +132 -0
- package/serveur/skiniParametres.js +106 -0
- package/serveur/utilsHHSkini.hh.js +64 -0
- package/serveur/utilsSkini.mjs +137 -0
- package/serveur/websocketServer.mjs +2052 -0
- package/serveur/workerInterfaceZ.mjs +327 -0
- package/serveur/workerSynchro.mjs +49 -0
- package/skini.mjs +141 -0
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileOverview
|
|
3
|
+
* <H3>CODE CLIENT DE SIMULATION D'UNE AUDIENCE
|
|
4
|
+
* UTILISANT LE CLIENT AVEC LISTE (clientListe)</H3>
|
|
5
|
+
* <BR>
|
|
6
|
+
* Les clips sont appelés de façon aléatoire selon la liste disponible.
|
|
7
|
+
* Ceci correspond à une audience qui fait n'importe quoi sur les clips
|
|
8
|
+
* disponibles.
|
|
9
|
+
* @version 1.0
|
|
10
|
+
* @author Bertrand Petit-Hédelin <bertrand@hedelin.fr>
|
|
11
|
+
* @copyright (C) 2022 Bertrand Petit-Hédelin
|
|
12
|
+
*
|
|
13
|
+
* This program is free software: you can redistribute it and/or modify
|
|
14
|
+
* it under the terms of the GNU General Public License as published by
|
|
15
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
16
|
+
* any later version.
|
|
17
|
+
*
|
|
18
|
+
* This program is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
* GNU General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU General Public License
|
|
24
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
25
|
+
*/
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
var par;
|
|
29
|
+
var ws;
|
|
30
|
+
var ipConfig = require('../../serveur/ipConfig');
|
|
31
|
+
const WebSocket = require('ws');
|
|
32
|
+
var debug = false;
|
|
33
|
+
var debug1 = true;
|
|
34
|
+
|
|
35
|
+
var tempoMax, tempoMin, limiteDureeAttente, dureeAttente = 10;
|
|
36
|
+
var derniersPatternsJoues = [];
|
|
37
|
+
var derniersInstrumentsJoue = [-1, -1, -1];
|
|
38
|
+
var nbeInstruments = 100; // Attention c'est en dur...
|
|
39
|
+
|
|
40
|
+
function setTableDerniersPatterns() {
|
|
41
|
+
var tablederniersPatterns = [];
|
|
42
|
+
var tableVide = [-1, -1, -1]; // Ce tableau définit la taille de la "mémoire" pour les non répétitions de patterns
|
|
43
|
+
|
|
44
|
+
for (var i = 0; i < nbeInstruments; i++) {
|
|
45
|
+
tablederniersPatterns.push(tableVide);
|
|
46
|
+
}
|
|
47
|
+
return tablederniersPatterns;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function initTempi() {
|
|
51
|
+
|
|
52
|
+
if (par === undefined) {
|
|
53
|
+
console.log("WARN simulator : launch the simulator after loading a piece");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log("------------------------------------------------");
|
|
58
|
+
if (par.tempoMax !== undefined) {
|
|
59
|
+
tempoMax = parseInt(par.tempoMax); // en ms
|
|
60
|
+
} else {
|
|
61
|
+
tempoMax = 500;
|
|
62
|
+
console.log("tempoMax par défaut")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (par.tempoMin !== undefined) {
|
|
66
|
+
tempoMin = parseInt(par.tempoMin); // en ms
|
|
67
|
+
} else {
|
|
68
|
+
tempoMin = 100;
|
|
69
|
+
console.log("tempoMin par défaut")
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (par.limiteDureeAttente !== undefined) {
|
|
73
|
+
limiteDureeAttente = par.limiteDureeAttente; // en ms
|
|
74
|
+
} else {
|
|
75
|
+
limiteDureeAttente = 100;
|
|
76
|
+
console.log("tempoMin par défaut")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
derniersPatternsJoues = setTableDerniersPatterns();
|
|
80
|
+
if (debug) console.log("derniersPatternsJoues: ", derniersPatternsJoues);
|
|
81
|
+
|
|
82
|
+
console.log("INFO simulateur : Paramètres tempo: Min=", tempoMin, " Max=", tempoMax, " limiteDureeAttente=", limiteDureeAttente);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (ipConfig.websocketServeurPort !== undefined) {
|
|
86
|
+
var port = ipConfig.websocketServeurPort;
|
|
87
|
+
} else {
|
|
88
|
+
var port = 8080;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (debug) console.log("----------------------------------------------\n");
|
|
92
|
+
if (debug) console.log("serveur:", ipConfig.serverIPAddress, " port:", ipConfig.websocketServeurPort);
|
|
93
|
+
|
|
94
|
+
var id = Math.floor((Math.random() * 1000000) + 1); // Pour identifier le client
|
|
95
|
+
var monGroupe = -1; // non initialisé
|
|
96
|
+
var DAWON = 0;
|
|
97
|
+
var pseudo = "sim" + id;
|
|
98
|
+
var listClips; // Devient une array avec toutes les infos sur les clips selectionnes
|
|
99
|
+
var nombreDePatternsPossible = 1; // Valeur par défaut qui peut être modifiée par l'orchestration
|
|
100
|
+
|
|
101
|
+
var numClip;
|
|
102
|
+
var msg = { // On met des valeurs pas defaut
|
|
103
|
+
type: "configuration",
|
|
104
|
+
text: "ECRAN_NOIR",
|
|
105
|
+
pseudo: "Anonyme",
|
|
106
|
+
value: 0,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var myArgs = process.argv.slice(2);
|
|
110
|
+
//console.log('myArgs: ', myArgs);
|
|
111
|
+
|
|
112
|
+
// Décodage du paramètre pour une simulation indépendante de l'audience
|
|
113
|
+
var jeSuisUneAudience = true;
|
|
114
|
+
for (var i = 0; i < myArgs.length; i++) {
|
|
115
|
+
if (myArgs[i] === "-sim") {
|
|
116
|
+
jeSuisUneAudience = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/************************ NON REPETITION DES CLIPS ********************
|
|
120
|
+
Table des commandes donnée par les listes de patterns
|
|
121
|
+
|
|
122
|
+
0= note, 1=note stop, 2=flag, 3=nom, 4=fichier son,
|
|
123
|
+
5=instrument, 6=Slot, 7=type, 8=free, 9=groupe, 10=durée
|
|
124
|
+
11= IP, 12= buffer, 13=niveau
|
|
125
|
+
|
|
126
|
+
**********************************************************************/
|
|
127
|
+
|
|
128
|
+
function isInList(element, list) {
|
|
129
|
+
for (var i = 0; i < list.length; i++) {
|
|
130
|
+
if (list[i] === element) return true;
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function sendPseudo(texte) {
|
|
136
|
+
if (debug) console.log("sendPseudo: ", texte);
|
|
137
|
+
msg.type = "clientPseudo";
|
|
138
|
+
msg.pseudo = texte;
|
|
139
|
+
ws.send(JSON.stringify(msg));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* --------------------------------------------------------------------
|
|
143
|
+
* On évite de reprendre un élément de la liste qui serait dans la mémoire.
|
|
144
|
+
* Nous avons les cas particuliers où la liste est de taille équivalente
|
|
145
|
+
* ou inferieure à la mémoire.
|
|
146
|
+
* Cette fonction retourne un élément de la liste en tenant compte de l'état de la mémoire.
|
|
147
|
+
* C'est utilisé pour les instruments et pour les patterns.
|
|
148
|
+
* --------------------------------------------------------------------*/
|
|
149
|
+
function selectRandomInList(memoire, liste) {
|
|
150
|
+
var selection;
|
|
151
|
+
var index;
|
|
152
|
+
|
|
153
|
+
if (liste === undefined) {
|
|
154
|
+
console.log("INFO: simuateurFork: selectRandomInList: liste undefined");
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (memoire === undefined) {
|
|
159
|
+
console.log("INFO: simuateurFork: selectRandomInList: memoire undefined");
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (debug) console.log("*** selectRandomInList:memoire:", memoire, "liste:", liste);
|
|
164
|
+
|
|
165
|
+
if (liste.length === 0) {
|
|
166
|
+
return undefined;
|
|
167
|
+
} else if (liste.length < 2) {
|
|
168
|
+
// Quand on a un seul élément pas la peine de se fatiguer.
|
|
169
|
+
return liste[0];
|
|
170
|
+
} else if (liste.length <= memoire.length) {
|
|
171
|
+
while (true) {
|
|
172
|
+
index = Math.floor(Math.random() * liste.length);
|
|
173
|
+
selection = liste[index];
|
|
174
|
+
if (selection === memoire[memoire.length - 1]) {
|
|
175
|
+
if (debug) console.log("reselecte A:", selection, index);
|
|
176
|
+
continue; // On refait un tour pour éviter une répétition immédiate
|
|
177
|
+
} else {
|
|
178
|
+
memoire.shift(selection); // Décale la mémoire
|
|
179
|
+
memoire.push(selection); // Mémorise le choix
|
|
180
|
+
return selection;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
while (true) {
|
|
185
|
+
index = Math.floor(Math.random() * liste.length);
|
|
186
|
+
selection = liste[index];
|
|
187
|
+
if (!isInList(selection, memoire)) { // La selection n'est pas dans la mémoire
|
|
188
|
+
memoire.shift(selection); // Décale la mémoire
|
|
189
|
+
memoire.push(selection); // Mémorise le choix
|
|
190
|
+
if (debug) console.log("reselecte fin: ", selection, index);
|
|
191
|
+
return selection;
|
|
192
|
+
} else { // La sélection est dans la mémoire
|
|
193
|
+
if (debug) console.log("reselecte B:", selection, index);
|
|
194
|
+
continue; // On refait un tour
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Retourne la note MIDI (Skini) d'un pattern choisi au hasard
|
|
201
|
+
function selectNextClip() {
|
|
202
|
+
var selectionClip;
|
|
203
|
+
var listeSelectionClip = [];
|
|
204
|
+
var listeInstruments = [];
|
|
205
|
+
var instrument;
|
|
206
|
+
|
|
207
|
+
//Mettre à jour le nombre d'instruments donnés par la liste
|
|
208
|
+
for (var i = 0; i < listClips.length; i++) {
|
|
209
|
+
if (!isInList(listClips[i][5], listeInstruments)) {
|
|
210
|
+
listeInstruments.push(listClips[i][5]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (debug) console.log("*** selectNextClip:listeInstruments:", listeInstruments);
|
|
214
|
+
|
|
215
|
+
//Choisir un instrument au hasard, et pas toujours le même
|
|
216
|
+
instrument = selectRandomInList(derniersInstrumentsJoue, listeInstruments);
|
|
217
|
+
if (debug) console.log("*** selectNextClip:instrument:", instrument);
|
|
218
|
+
if (instrument === undefined) {
|
|
219
|
+
console.log("ERR:selectNextClip:instrument undefined");
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//Choisir les commandes MIDI des patterns pour l'instrument sélectioné
|
|
224
|
+
for (var i = 0; i < listClips.length; i++) {
|
|
225
|
+
if (listClips[i][5] === instrument) {
|
|
226
|
+
listeSelectionClip.push(listClips[i][0]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (debug) console.log("*** selectNextClip:listeSelectionClip:", listeSelectionClip);
|
|
230
|
+
|
|
231
|
+
// Choisir un pattern pour l'instrument sélectionné
|
|
232
|
+
// Pas suffisant avec l'application de modèles sur la suite des patterns
|
|
233
|
+
// La sélection doit se faire en fonction des types.
|
|
234
|
+
selectionClip = selectRandomInList(derniersPatternsJoues[instrument], listeSelectionClip);
|
|
235
|
+
if (selectionClip === undefined) {
|
|
236
|
+
console.log("ERR:selectNextClip:selectionClip undefined");
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
if (debug) console.log("*** selectNextClip:selectionClip:", selectionClip);
|
|
240
|
+
|
|
241
|
+
return selectionClip;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/*********************************************
|
|
245
|
+
|
|
246
|
+
WEBSOCKET AVEC NODE JS
|
|
247
|
+
|
|
248
|
+
**********************************************/
|
|
249
|
+
|
|
250
|
+
function initWSSocket(port) {
|
|
251
|
+
var tempoInstantListClip = 0;
|
|
252
|
+
|
|
253
|
+
if (ws !== undefined) {
|
|
254
|
+
if (debug1) console.log("INFO: simulateurFork.js: close the socket");
|
|
255
|
+
ws.close();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
ws = new WebSocket("ws://" + ipConfig.serverIPAddress + ":" + ipConfig.websocketServeurPort); // NODE JS
|
|
259
|
+
|
|
260
|
+
// Par défaut je suis hors audience
|
|
261
|
+
var monIdentite = "simulateur";
|
|
262
|
+
if (jeSuisUneAudience) monIdentite = "sim";
|
|
263
|
+
|
|
264
|
+
ws.onopen = function (event) {
|
|
265
|
+
if (debug) console.log("INFO: simulateurFork.js Websocket : ", "ws://" + ipConfig.serverIPAddress + ":" + port + "/hop/serv");
|
|
266
|
+
msg.type = "startSpectateur";
|
|
267
|
+
msg.text = monIdentite;
|
|
268
|
+
msg.id = id;
|
|
269
|
+
ws.send(JSON.stringify(msg));
|
|
270
|
+
|
|
271
|
+
msg.type = "getNombreDePatternsPossibleEnListe";
|
|
272
|
+
ws.send(JSON.stringify(msg));
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
//Traitement de la Réception sur le client
|
|
276
|
+
ws.onmessage = function (event) {
|
|
277
|
+
var msgRecu = JSON.parse(event.data);
|
|
278
|
+
//console.log( "Client: received [%s]", event.data );
|
|
279
|
+
switch (msgRecu.type) {
|
|
280
|
+
|
|
281
|
+
case "DAWON":
|
|
282
|
+
DAWON = msgRecu.value;
|
|
283
|
+
actionSurDAWON();
|
|
284
|
+
break;
|
|
285
|
+
|
|
286
|
+
case "DAWStatus":
|
|
287
|
+
if (debug) console.log("Reçu DAWStatus:", event.value);
|
|
288
|
+
DAWON = msgRecu.value;
|
|
289
|
+
actionSurDAWON();
|
|
290
|
+
break;
|
|
291
|
+
|
|
292
|
+
case "demandeDeSonParPseudo":
|
|
293
|
+
if (debug) console.log("Reçu Texte Broadcast demande de son par pseudo:", msgRecu.value);
|
|
294
|
+
break;
|
|
295
|
+
|
|
296
|
+
case "dureeAttente": // Quand le son a été demandé
|
|
297
|
+
if (debug) console.log("SimulatuerFork.js: dureeAttente:", msgRecu.text, msgRecu.son);
|
|
298
|
+
dureeAttente = parseInt(msgRecu.text);
|
|
299
|
+
break;
|
|
300
|
+
|
|
301
|
+
case "groupe":
|
|
302
|
+
//Si le simulateur doit être dissocicé de l'audience,
|
|
303
|
+
// il sera dans le dernier groupe de la table des possibles.
|
|
304
|
+
if (jeSuisUneAudience) {
|
|
305
|
+
// Le simulateur simule l'audience.
|
|
306
|
+
// Il se comporte comme tout le monde, avec le groupe que le serveur assigne
|
|
307
|
+
monGroupe = msgRecu.noDeGroupe;
|
|
308
|
+
if (debug) console.log("SIMULATION DE L'AUDIENCE");
|
|
309
|
+
} else if (!par.simulatorInAseperateGroup) {
|
|
310
|
+
// Je suis ne pas un simulateur de l'audience
|
|
311
|
+
// et la config n'a pas prévu de simulateur indépendant de l'audience.
|
|
312
|
+
// On force un comportement de simulateur d'audience.
|
|
313
|
+
console.log("WARN: le simulateur demande à être indépendant, mais ce n'est pas prévu dans la configuration");
|
|
314
|
+
monGroupe = msgRecu.noDeGroupe;
|
|
315
|
+
} else {
|
|
316
|
+
// La config a prévu un simulateur indépendant de l'audience
|
|
317
|
+
// et je ne suis pas un simulateur d'audience.
|
|
318
|
+
// Je définis mon groupe en m'attribuant donc le dernier groupe de client
|
|
319
|
+
// Ceci est redondant avec le serveur dans ce cas qui fournit aussi le même groupe
|
|
320
|
+
// resérvé.
|
|
321
|
+
console.log("SIMULATION INDEPENDANTE DE L'AUDIENCE");
|
|
322
|
+
monGroupe = par.nbeDeGroupesClients - 1;
|
|
323
|
+
}
|
|
324
|
+
if (debug1) console.log("INFO: Simulator in group:", monGroupe, "pseudo:", pseudo);
|
|
325
|
+
actionSurDAWON();
|
|
326
|
+
break;
|
|
327
|
+
|
|
328
|
+
case "groupeClientStatus":
|
|
329
|
+
if (debug) console.log("Reçu Broadcast: groupeClientStatus:", msgRecu, msgRecu.groupeClient);
|
|
330
|
+
if (msgRecu.groupeClient == monGroupe || msgRecu.groupeClient == 255) {
|
|
331
|
+
actionSurGroupeClientStatus(msgRecu.groupeName, msgRecu.status);
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
|
|
335
|
+
case "infoPlayDAW":
|
|
336
|
+
if (debug) console.log("Reçu Texte Broadcast infoPlayDAW:", msgRecu.value);
|
|
337
|
+
break;
|
|
338
|
+
|
|
339
|
+
case "listClips":
|
|
340
|
+
listClips = msgRecu.listClips;
|
|
341
|
+
if (listClips === -1) {
|
|
342
|
+
if (debug) console.log("WS Recu : listClips: groupe de client inexistant", listClips);
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (listClips === undefined) {
|
|
347
|
+
if (debug) console.log("WS Recu : listClips: undefined, pas de clip");
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (listClips.length === 0) {
|
|
352
|
+
if (debug) console.log("WS Recu : listClips vide");
|
|
353
|
+
if (tempoMax === tempoMin) {
|
|
354
|
+
console.log("WARN: tempoMin and tempoMax must no be equal");
|
|
355
|
+
tempoInstantListClip = 10;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
tempoInstantListClip = Math.floor(tempoMin + (Math.random() * (tempoMax - tempoMin)));
|
|
359
|
+
}
|
|
360
|
+
if (debug) console.log("TEMPO INSTANT LIST CLIP:", tempoInstantListClip, tempoMax, tempoMin );
|
|
361
|
+
if (DAWON) setTimeout(function () {
|
|
362
|
+
selectListClips();
|
|
363
|
+
},
|
|
364
|
+
tempoInstantListClip);
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Selection de clips dans la liste
|
|
369
|
+
if (debug) console.log("\n--- WS Recu : listClips 1ere ligne:", listClips[0][4], "Nombre clip dispo:", listClips.length);
|
|
370
|
+
var sequenceLocale = [];
|
|
371
|
+
|
|
372
|
+
for (var i = 0; i < nombreDePatternsPossible; i++) {
|
|
373
|
+
//Version qui évite trop de répétitions
|
|
374
|
+
numClip = selectNextClip();
|
|
375
|
+
sequenceLocale[i] = numClip;
|
|
376
|
+
|
|
377
|
+
// On a une liste
|
|
378
|
+
if (debug) console.log("--- WS Recu : listClips: choisi", numClip, " : ", listClips[numClip][4], "\n");
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (debug) console.log("-- sendPatternSequence: attente:", dureeAttente, limiteDureeAttente);
|
|
382
|
+
if (dureeAttente < limiteDureeAttente) {
|
|
383
|
+
if (debug) console.log("-- sendPatternSequence", sequenceLocale, pseudo);
|
|
384
|
+
msg.type = "sendPatternSequence";
|
|
385
|
+
msg.patternSequence = sequenceLocale;
|
|
386
|
+
msg.pseudo = pseudo;
|
|
387
|
+
msg.groupe = monGroupe;
|
|
388
|
+
msg.idClient = id;
|
|
389
|
+
ws.send(JSON.stringify(msg));
|
|
390
|
+
} else {
|
|
391
|
+
msg.type = "sendPatternSequence";
|
|
392
|
+
msg.patternSequence = [];
|
|
393
|
+
msg.pseudo = pseudo;
|
|
394
|
+
msg.groupe = monGroupe;
|
|
395
|
+
msg.idClient = id;
|
|
396
|
+
ws.send(JSON.stringify(msg));
|
|
397
|
+
dureeAttente = 0;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
tempoInstantListClip = Math.floor((Math.random() * (tempoMax - tempoMin)) + tempoMin);
|
|
401
|
+
if (debug) console.log("TEMPO INSTANT LIST CLIP:", tempoInstantListClip, pseudo);
|
|
402
|
+
if (DAWON) setTimeout(function () {
|
|
403
|
+
selectListClips();
|
|
404
|
+
},
|
|
405
|
+
tempoInstantListClip);
|
|
406
|
+
break;
|
|
407
|
+
|
|
408
|
+
case "message":
|
|
409
|
+
if (debug) console.log(msgRecu.text);
|
|
410
|
+
break;
|
|
411
|
+
|
|
412
|
+
case "nombreDePatternsPossibleEnListe":
|
|
413
|
+
if (debug) console.log("socket : nombreDePatternsPossibleEnListe: msgRecu: ", msgRecu.nombreDePatternsPossible);
|
|
414
|
+
var nombreDePatternsPossibleEnListe = msgRecu.nombreDePatternsPossible;
|
|
415
|
+
var flagFin = false;
|
|
416
|
+
|
|
417
|
+
// Mise à jour du suivi des longueurs de listes d'abord / au groupe
|
|
418
|
+
for (var i = 0; i < nombreDePatternsPossibleEnListe.length; i++) {
|
|
419
|
+
if (nombreDePatternsPossibleEnListe[i][1] === monGroupe) {
|
|
420
|
+
nombreDePatternsPossible = nombreDePatternsPossibleEnListe[i][0];
|
|
421
|
+
flagFin = true;
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (!flagFin) {
|
|
426
|
+
// Sinon en fonction du broadcast 255
|
|
427
|
+
for (var i = 0; i < nombreDePatternsPossibleEnListe.length; i++) {
|
|
428
|
+
if (nombreDePatternsPossibleEnListe[i][1] === 255) {
|
|
429
|
+
nombreDePatternsPossible = nombreDePatternsPossibleEnListe[i][0];
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (debug) console.log("Reçu socket : nombreDePatternsPossible:nombreSonsPossibleInit ", nombreDePatternsPossible);
|
|
435
|
+
break;
|
|
436
|
+
|
|
437
|
+
case "patternSequenceAck":
|
|
438
|
+
if (debug) console.log("Reçu socket : patternSequenceAck: score ", msgRecu.score);
|
|
439
|
+
break;
|
|
440
|
+
|
|
441
|
+
case "texteServeur":
|
|
442
|
+
if (debug) console.log("Reçu Broadcast:", msgRecu.value);
|
|
443
|
+
break;
|
|
444
|
+
|
|
445
|
+
default: if (debug) console.log("Le simulateur reçoit un message inconnu", msgRecu);
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
ws.onerror = function (event) {
|
|
451
|
+
console.log("simulateur.js : received ERROR on WS");
|
|
452
|
+
/* console.log( "reconnecting...");
|
|
453
|
+
setTimeout(function() {
|
|
454
|
+
initTempi();
|
|
455
|
+
initWSSocket(port);
|
|
456
|
+
}, 5000);*/
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
ws.onclose = function (event) {
|
|
460
|
+
console.log("INFO: simulateurFork.js : on CLOSE on WS");
|
|
461
|
+
//setTimeout(function () { initWSSocket(port); }, 3000);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
//- Attention d'avoir initialisation avant de faire server.addEventListener('DAWStatus', function( event )---
|
|
466
|
+
// Cette fonction de remise à jour de l'affichage est appelée sur plusieurs évènements :
|
|
467
|
+
// onload, Modif DAW, Modif sur groupe de sons, reconnexion, rechargement de la page.
|
|
468
|
+
|
|
469
|
+
function initialisation() {
|
|
470
|
+
//var index = monGroupe;
|
|
471
|
+
//msg.pseudo = pseudo;
|
|
472
|
+
if (debug) console.log("simulateur.js:initialisation: PSEUDO ", pseudo);
|
|
473
|
+
sendPseudo(pseudo);
|
|
474
|
+
}
|
|
475
|
+
exports.initialisation = initialisation;
|
|
476
|
+
|
|
477
|
+
function init(port) {
|
|
478
|
+
//listenMachine = makeListenMachine();
|
|
479
|
+
initWSSocket(port);
|
|
480
|
+
}
|
|
481
|
+
exports.init = init;
|
|
482
|
+
|
|
483
|
+
function actionSurDAWON() {
|
|
484
|
+
if (DAWON == false) {
|
|
485
|
+
if (debug) console.log("simulateur.js:actionSurDAWON:false");
|
|
486
|
+
initialisation();
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (debug) console.log("simulateur.js:actionSurDAWON:true:", DAWON);
|
|
491
|
+
initialisation(); //Pour le cas où le client recharge sa page en cours d'interaction
|
|
492
|
+
selectListClips(); // Pour le déclenchement de la simulation
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function actionSurGroupeClientStatus(sons, status) {
|
|
496
|
+
if (DAWON == false) {
|
|
497
|
+
if (debug) console.log("simulateur.js:actionSurGroupeClientStatus:DAWON:false");
|
|
498
|
+
initialisation();
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (debug) console.log("WS actionSurGroupeClientStatus:", monGroupe);
|
|
502
|
+
|
|
503
|
+
if (sons == "" || sons == undefined) {
|
|
504
|
+
} else {
|
|
505
|
+
if (status) {
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
//========== Controle des CLIPS =================================
|
|
511
|
+
function selectListClips() { // selecteurV2
|
|
512
|
+
if (debug) console.log("selectListClips: groupe", monGroupe);
|
|
513
|
+
|
|
514
|
+
msg.type = "selectAllClips";
|
|
515
|
+
msg.groupe = monGroupe;
|
|
516
|
+
ws.send(JSON.stringify(msg));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Demande au serveur de lancer le clip
|
|
520
|
+
var compteurTest = 0;
|
|
521
|
+
function startClip(indexChoisi) {
|
|
522
|
+
|
|
523
|
+
if (indexChoisi == -1) return -1; // Protection sur un choix sans selection au départ
|
|
524
|
+
msg.pseudo = pseudo; //noms[index];
|
|
525
|
+
|
|
526
|
+
msg.type = "DAWStartClip";
|
|
527
|
+
msg.clipChoisi = listClips[indexChoisi];
|
|
528
|
+
|
|
529
|
+
compteurTest++;
|
|
530
|
+
console.log("startClip:", compteurTest, " :", listClips[indexChoisi][3], "par", pseudo);
|
|
531
|
+
//msg.pseudo = pseudo;
|
|
532
|
+
msg.groupe = monGroupe;
|
|
533
|
+
ws.send(JSON.stringify(msg));
|
|
534
|
+
indexChoisi = -1;
|
|
535
|
+
}
|
|
536
|
+
exports.startClip = startClip;
|
|
537
|
+
|
|
538
|
+
// ========================= Lancement du simulateur =================
|
|
539
|
+
process.on('message', (message) => {
|
|
540
|
+
// This is necessary, I dont know why. Otherwise I have an erro on message in the switch
|
|
541
|
+
// ReferenceError: Cannot access 'message' before initialization
|
|
542
|
+
var messageLocal = message;
|
|
543
|
+
|
|
544
|
+
if (debug) console.log("INFO: Simulator message : ", messageLocal);
|
|
545
|
+
|
|
546
|
+
switch (messageLocal.type) {
|
|
547
|
+
case 'START_SIMULATOR':
|
|
548
|
+
//console.log('Simulator received START message');
|
|
549
|
+
init(port);
|
|
550
|
+
setTimeout(() => selectListClips(), 1000);
|
|
551
|
+
let message = `Simulation Launched by ${pseudo}`;
|
|
552
|
+
process.send(message);
|
|
553
|
+
break;
|
|
554
|
+
|
|
555
|
+
case 'PARAMETERS':
|
|
556
|
+
if (debug) console.log("INFO: Simulator parameters : ", messageLocal.data.groupesDesSons[0]);
|
|
557
|
+
par = messageLocal.data;
|
|
558
|
+
initTempi();
|
|
559
|
+
break;
|
|
560
|
+
|
|
561
|
+
case 'STOP_SIMULATOR':
|
|
562
|
+
if (debug1) console.log("INFO: simulateurFork.js : Simulator Stopped");
|
|
563
|
+
ws.close();
|
|
564
|
+
process.exit(0);
|
|
565
|
+
break;
|
|
566
|
+
|
|
567
|
+
default: console.log("INFO: Fork Simulator: Type de message inconnu : ", messageLocal);
|
|
568
|
+
}
|
|
569
|
+
});
|