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,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileOverview
|
|
3
|
+
* For evaluating and giving "game scores" when using Skini for interactive Game
|
|
4
|
+
* using the selection of sequences of patterns on the client (audience) side.
|
|
5
|
+
* @copyright (C) 2022 Bertrand Petit-Hédelin
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+
* @author Bertrand Petit-Hédelin <bertrand@hedelin.fr>
|
|
21
|
+
* @version 1.4
|
|
22
|
+
*/
|
|
23
|
+
'use strict'
|
|
24
|
+
|
|
25
|
+
import * as DAW from './controleDAW.mjs'
|
|
26
|
+
//var DAW = require('./controleDAW');
|
|
27
|
+
|
|
28
|
+
var debug = false;
|
|
29
|
+
var debug1 = true;
|
|
30
|
+
|
|
31
|
+
const typeDebut = 1;
|
|
32
|
+
const typeMilieu = 2;
|
|
33
|
+
const typeFin = 3;
|
|
34
|
+
const typeNeutre = 4;
|
|
35
|
+
const typeMauvais = 5;
|
|
36
|
+
|
|
37
|
+
/*===================================================================================
|
|
38
|
+
|
|
39
|
+
Memo of Pattern : Note, Note stop, Flag usage, Texte, Fichier son,
|
|
40
|
+
Instrument [5], Slot, Type [7], not used, Groupe, Durée
|
|
41
|
+
|
|
42
|
+
Gestion des clients memorySortable
|
|
43
|
+
|
|
44
|
+
clientsEnCours est un tableau d'objets client :
|
|
45
|
+
|
|
46
|
+
var client = {
|
|
47
|
+
pseudo : pseudo,
|
|
48
|
+
score : 0,
|
|
49
|
+
preSequence : -1,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
=====================================================================================*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A Adds a client to the list of connected clients if it does not already exist.
|
|
56
|
+
* @param {string} pseudo
|
|
57
|
+
* @param {number} id
|
|
58
|
+
* @param {number} groupe
|
|
59
|
+
* @param {array} clientsEnCours
|
|
60
|
+
*/
|
|
61
|
+
export function putInClientsEnCours(pseudo, id, groupe, clientsEnCours) {
|
|
62
|
+
// On se base sur le pseudo
|
|
63
|
+
// l'id pourrait être utilisé plus tard
|
|
64
|
+
if (clientsEnCours !== undefined) {
|
|
65
|
+
for (var i = 0; i < clientsEnCours.length; i++) {
|
|
66
|
+
if (clientsEnCours[i].pseudo === pseudo) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
var client = {
|
|
72
|
+
pseudo: pseudo,
|
|
73
|
+
groupe: groupe,
|
|
74
|
+
score: 0,
|
|
75
|
+
preSequence: -1,
|
|
76
|
+
}
|
|
77
|
+
clientsEnCours.push(client);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Compute a new score for a player using the pseudo.
|
|
83
|
+
* @param {string} pseudo the player
|
|
84
|
+
* @param {number} score value of the new score
|
|
85
|
+
* @param {array} clientsEnCours list of players
|
|
86
|
+
*/
|
|
87
|
+
export function updateScore(pseudo, score, clientsEnCours) {
|
|
88
|
+
var scoreTotal = 0;
|
|
89
|
+
if (clientsEnCours !== undefined) {
|
|
90
|
+
for (var i = 0; i < clientsEnCours.length; i++) {
|
|
91
|
+
if (clientsEnCours[i].pseudo === pseudo) {
|
|
92
|
+
clientsEnCours[i].score += score;
|
|
93
|
+
scoreTotal = clientsEnCours[i].score;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (debug) console.log("computeScore.js: updateScore: ", clientsEnCours);
|
|
98
|
+
return scoreTotal;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* In order to check if a client is asking for the same sequence several times.
|
|
103
|
+
* @param {string} pseudo
|
|
104
|
+
* @param {array} clientsEnCours
|
|
105
|
+
*/
|
|
106
|
+
export function getPreSequence(pseudo, clientsEnCours) {
|
|
107
|
+
for (var i = 0; i < clientsEnCours.length; i++) {
|
|
108
|
+
if (clientsEnCours[i].pseudo === pseudo) {
|
|
109
|
+
return clientsEnCours[i].preSequence;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
console.log("WARN: computeScore.js: getPreSequence : pas de présequence pour ", pseudo, clientsEnCours);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Insert a sequence of patterns in a list for a specific client.
|
|
118
|
+
* @param {string} pseudo
|
|
119
|
+
* @param {array} sequence
|
|
120
|
+
* @param {array} clientsEnCours
|
|
121
|
+
*/
|
|
122
|
+
export function setPreSequence(pseudo, sequence, clientsEnCours) {
|
|
123
|
+
for (var i = 0; i < clientsEnCours.length; i++) {
|
|
124
|
+
if (clientsEnCours[i].pseudo === pseudo) {
|
|
125
|
+
// Plutot que de simplement remplacer preSequence comme on le fait ici, on pourrait ajouter la sequence à la liste
|
|
126
|
+
// pour avoir des traitements plus riches que de vérifier une simple répetition immédiate
|
|
127
|
+
clientsEnCours[i].preSequence = sequence;
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
console.log("WARN: computeScore.js: setPreSequence : pas de pseudo :", pseudo);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Clean the list of scores.
|
|
137
|
+
* @param {} clientsEnCours
|
|
138
|
+
*/
|
|
139
|
+
export function resetClientEnCours(clientsEnCours) {
|
|
140
|
+
if (clientsEnCours !== undefined) {
|
|
141
|
+
for (var i = 0; i < clientsEnCours.length; i++) {
|
|
142
|
+
clientsEnCours[i].score = 0;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (debug) console.log("computeScore.js: resetClientEnCours: ", clientsEnCours);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function isInstrumentInTheList(instr, liste) {
|
|
149
|
+
for (var j = 0; j < liste.length; j++) {
|
|
150
|
+
if (liste[j] === instr) {
|
|
151
|
+
return true; // déja dans la liste
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*=================================================================
|
|
158
|
+
wasPatternAlreadySelected
|
|
159
|
+
|
|
160
|
+
sequence est un tableau de notes skini
|
|
161
|
+
|
|
162
|
+
===================================================================*/
|
|
163
|
+
/**
|
|
164
|
+
* To check if a pattern was already in the sequence.
|
|
165
|
+
* @param {number} index pattern number
|
|
166
|
+
* @param {array} sequence
|
|
167
|
+
* @returns {boolean}
|
|
168
|
+
*/
|
|
169
|
+
function wasPatternAlreadySelected(index, sequence) {
|
|
170
|
+
if (sequence === -1) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
for (var i = 0; i < sequence.length; i++) {
|
|
174
|
+
if (sequence[i] == index) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/*=================================================================
|
|
182
|
+
computeScoreDMFN, Régles de notation début, milieu, fin, neutre et mauvais
|
|
183
|
+
|
|
184
|
+
Retourne un score en fonction d'un tableau de types de patterns
|
|
185
|
+
et du tableau des précédents types de patterns qui avait été
|
|
186
|
+
envoyé au serveur.
|
|
187
|
+
|
|
188
|
+
- ListeTypes est un tableau ordonné d'elements correspondant à une liste de patterns:
|
|
189
|
+
var element = {
|
|
190
|
+
type : // Selon le fichier csv
|
|
191
|
+
index : // Note Skini
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
- preSequence est un tableau de note Skini
|
|
195
|
+
|
|
196
|
+
La répétition d'un pattern est pénalisée
|
|
197
|
+
|
|
198
|
+
===================================================================*/
|
|
199
|
+
/**
|
|
200
|
+
* Compute a score using a list of Skini Notes (pattern numbers ) according
|
|
201
|
+
* to a previous sequence (list of patterns).
|
|
202
|
+
* @param {array} listeTypes
|
|
203
|
+
* @param {array} preSequence
|
|
204
|
+
* @returns {number} score
|
|
205
|
+
*/
|
|
206
|
+
function computeScoreDMFN(listeTypes, preSequence) {
|
|
207
|
+
if (debug) console.log("computeScore.js:computeScore: preSequence:", preSequence);
|
|
208
|
+
|
|
209
|
+
var score = 0;
|
|
210
|
+
if (listeTypes.length > 1) {
|
|
211
|
+
// Traitement du Début
|
|
212
|
+
if (wasPatternAlreadySelected(listeTypes[0].index, preSequence)) {
|
|
213
|
+
score -= 5;
|
|
214
|
+
} else if (listeTypes[0].type === typeDebut) {
|
|
215
|
+
score += 10;
|
|
216
|
+
} else if (listeTypes[0].type === typeMilieu || listeTypes[0].type === typeNeutre) {
|
|
217
|
+
score += 5;
|
|
218
|
+
} else if (listeTypes[0].type === typeFin) {
|
|
219
|
+
score -= 10;
|
|
220
|
+
} else if (listeTypes[0].type === typeMauvais) {
|
|
221
|
+
score -= 15;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Fin
|
|
225
|
+
if (wasPatternAlreadySelected(listeTypes[listeTypes.length - 1].index, preSequence)) {
|
|
226
|
+
score -= 5;
|
|
227
|
+
} else if (listeTypes[listeTypes.length - 1].type === typeFin) {
|
|
228
|
+
score += 10;
|
|
229
|
+
} else if (listeTypes[listeTypes.length - 1].type === typeMilieu || listeTypes[listeTypes.length - 1].type === typeNeutre) {
|
|
230
|
+
score += 5;
|
|
231
|
+
} else if (listeTypes[listeTypes.length - 1].type === typeDebut) {
|
|
232
|
+
score -= 10;
|
|
233
|
+
} else if (listeTypes[listeTypes.length - 1].type === typeMauvais) {
|
|
234
|
+
score -= 15;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Le reste
|
|
238
|
+
for (var i = 1; i < listeTypes.length - 1; i++) {
|
|
239
|
+
if (wasPatternAlreadySelected(listeTypes[i].index, preSequence)) {
|
|
240
|
+
score -= 5;
|
|
241
|
+
} else if (listeTypes[i].type === typeFin || listeTypes[i].type === typeDebut) {
|
|
242
|
+
score -= 5;
|
|
243
|
+
} else if (listeTypes[i].type === typeMilieu) {
|
|
244
|
+
score += 10;
|
|
245
|
+
} else if (listeTypes[i].type === typeNeutre) {
|
|
246
|
+
score += 5;
|
|
247
|
+
} else if (listeTypes[i].type === typeMauvais) {
|
|
248
|
+
score -= 15;
|
|
249
|
+
}
|
|
250
|
+
if (debug) console.log("computeScore.js:computeScore: le reste:", listeTypes[i], score);
|
|
251
|
+
}
|
|
252
|
+
} else if (wasPatternAlreadySelected(listeTypes[0].index, preSequence)) { // Pour un seul élément
|
|
253
|
+
score -= 5;
|
|
254
|
+
} else if (listeTypes[0].type === typeMilieu || listeTypes[0].type === typeNeutre) {
|
|
255
|
+
score += 5;
|
|
256
|
+
} else if (listeTypes[0].type === typeMauvais) {
|
|
257
|
+
score -= 15;
|
|
258
|
+
}
|
|
259
|
+
if (debug) console.log("computeScore.js: computeScore", listeTypes, ": score:", score);
|
|
260
|
+
return score;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/*=================================================================
|
|
264
|
+
computeScoreInclass
|
|
265
|
+
|
|
266
|
+
Retourne un score en fonction d'un tableau de types de patterns
|
|
267
|
+
et du tableau des précédents types de patterns qui avait été
|
|
268
|
+
envoyé au serveur.
|
|
269
|
+
|
|
270
|
+
- ListeTypes est un tableau d'elements:
|
|
271
|
+
var element = {
|
|
272
|
+
type : // Selon le fichier csv
|
|
273
|
+
index : // Note Skini
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
- preSequence est le tableau de note Skini de la précédente soumission.
|
|
277
|
+
|
|
278
|
+
===================================================================*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Compute a score according the classes of the patterns.
|
|
282
|
+
* If you ask for a pattern in the same class without repeating you get points.
|
|
283
|
+
* If you ask again for the same patterns as the previous time you lose points.
|
|
284
|
+
* If you repeat the same pattern in the sequence you lose points.
|
|
285
|
+
* @param {array} listeTypes list of previous selected classes of patterns
|
|
286
|
+
* @param {number} patternClass
|
|
287
|
+
* @param {array} preSequence previous sequence
|
|
288
|
+
* @returns {number} score the computed score
|
|
289
|
+
*/
|
|
290
|
+
function computeScoreInclass(listeTypes, patternClass, preSequence) {
|
|
291
|
+
var score = 0;
|
|
292
|
+
|
|
293
|
+
for (var i = 0; i < listeTypes.length; i++) {
|
|
294
|
+
if (debug) console.log("computeScore.js :computecomputeScoreInclass: listeTypes[i].type", listeTypes[i].type, " patternClass: ", patternClass);
|
|
295
|
+
if (listeTypes[i].type === patternClass) {
|
|
296
|
+
score += 10;
|
|
297
|
+
} else {
|
|
298
|
+
score -= 10;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Si on redemande les mêmes patterns que la fois précédente on perd des points
|
|
303
|
+
for (var i = 0; i < listeTypes.length; i++) {
|
|
304
|
+
if (wasPatternAlreadySelected(listeTypes[i].index, preSequence)) {
|
|
305
|
+
score -= 5;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Si on répète le même pattern dans la séquence on perd des points
|
|
310
|
+
for (var i = 0; i < listeTypes.length; i++) {
|
|
311
|
+
for (var j = i + 1; j < listeTypes.length; j++) {
|
|
312
|
+
if (listeTypes[i].index === listeTypes[j].index) {
|
|
313
|
+
score -= 10;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (debug) console.log("computeScore.js :computecomputeScoreInclass:", patternClass, " last computation:", score);
|
|
319
|
+
return score;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/*=================================================================
|
|
323
|
+
evaluateSequenceOfPatterns
|
|
324
|
+
|
|
325
|
+
- patternSequence : un tableau avec les notes Skini associées aux patterns
|
|
326
|
+
- preSequence : obtenu avec getPreSequence(msgRecu.pseudo, clientsEnCours), un pseudo et
|
|
327
|
+
- clientsEnCours qui est un tableau d'objets client :
|
|
328
|
+
|
|
329
|
+
var client = {
|
|
330
|
+
pseudo : pseudo,
|
|
331
|
+
score : 0,
|
|
332
|
+
preSequence : -1,
|
|
333
|
+
groupe : groupe
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
- computeScorePolicy définit le type de scoring, DMFN (début, milieu, fin, neutre), appartenance des patterns
|
|
337
|
+
à une classe (même tonalité, même mode, même style, même rytme...)
|
|
338
|
+
|
|
339
|
+
- computeScoreClass définit la classe pour les scorings qui en ont besoin (même tonalité, même mode, même style, même rytme...)
|
|
340
|
+
|
|
341
|
+
===================================================================*/
|
|
342
|
+
/**
|
|
343
|
+
* Compute the score when submitting a sequence of patten.
|
|
344
|
+
* @param {array} patternSequence
|
|
345
|
+
* @param {array} preSequence
|
|
346
|
+
* @param {number} computeScorePolicy define the algorithm used to compute the score
|
|
347
|
+
* @param {number} computeScoreClass
|
|
348
|
+
*/
|
|
349
|
+
export function evaluateSequenceOfPatterns(patternSequence, preSequence, computeScorePolicy, computeScoreClass) {
|
|
350
|
+
var score = 0;
|
|
351
|
+
var choix = new Array(patternSequence.length);
|
|
352
|
+
var lesInstruments = [];
|
|
353
|
+
|
|
354
|
+
// Etablir la liste des patterns (choix), car la séquence donnée en paramètre
|
|
355
|
+
// ne contient que des index (des notes midi au sens de SKini)
|
|
356
|
+
if (debug) console.log("computeScore.js: evaluateSequenceOfPatterns", patternSequence);
|
|
357
|
+
|
|
358
|
+
for (var i = 0; i < patternSequence.length; i++) {
|
|
359
|
+
var pattern = DAW.getPatternFromNote(patternSequence[i]);
|
|
360
|
+
if (pattern === undefined) {
|
|
361
|
+
if(debug) console.log("WARN: computeScore.js: evaluateSequenceOfPatterns: pattern undefined");
|
|
362
|
+
}
|
|
363
|
+
choix[i] = pattern;
|
|
364
|
+
}
|
|
365
|
+
if (debug) console.log("computeScore.js: evaluateSequenceOfPatterns: choix: ", choix);
|
|
366
|
+
|
|
367
|
+
//Quel sont les instruments concernés ? On en fait une liste "lesInstruments" dans un tableau
|
|
368
|
+
//à partir de choix
|
|
369
|
+
for (var i = 0; i < choix.length; i++) {
|
|
370
|
+
if (choix[i] !== undefined) {
|
|
371
|
+
if (!isInstrumentInTheList(choix[i][5], lesInstruments)) {
|
|
372
|
+
lesInstruments.push(choix[i][5]);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (debug) console.log("computeScore.js: evaluateSequenceOfPatterns: lesInstruments: ", lesInstruments);
|
|
377
|
+
|
|
378
|
+
//Pour chaque instrument quelle est l'évaluation du score ?
|
|
379
|
+
for (var i = 0; i < lesInstruments.length; i++) {
|
|
380
|
+
//Créer la liste des types et index de pattern pour un instrument
|
|
381
|
+
var typesInstrEnCours = [];
|
|
382
|
+
for (var j = 0; j < choix.length; j++) {
|
|
383
|
+
if (choix[j] !== undefined) {
|
|
384
|
+
if (choix[j][5] === lesInstruments[i]) {
|
|
385
|
+
var element = {
|
|
386
|
+
type: choix[j][7],
|
|
387
|
+
index: choix[j][0]
|
|
388
|
+
}
|
|
389
|
+
typesInstrEnCours.push(element);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
// Calculer le score pour cet instrument et l'ajouter au total
|
|
394
|
+
switch (computeScorePolicy) {
|
|
395
|
+
case 0:
|
|
396
|
+
if (debug) console.log("WARN: computeScore.js: evaluateSequenceOfPatterns: No policy for scoring this sequence.");
|
|
397
|
+
break;
|
|
398
|
+
|
|
399
|
+
case 1:
|
|
400
|
+
score += computeScoreDMFN(typesInstrEnCours, preSequence);
|
|
401
|
+
break;
|
|
402
|
+
|
|
403
|
+
case 2:
|
|
404
|
+
score += computeScoreInclass(typesInstrEnCours, computeScoreClass, preSequence);
|
|
405
|
+
break;
|
|
406
|
+
|
|
407
|
+
default:
|
|
408
|
+
console.log("WARN: computeScore.js: evaluateSequenceOfPatterns: Policy unknown for scoring this sequence:", computeScorePolicy);
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
if (debug) console.log("computeScore.js: evaluateSequenceOfPatterns: typesInstrEnCours: ", typesInstrEnCours, "preSequence:", preSequence, ":score: ", score);
|
|
414
|
+
return score;
|
|
415
|
+
}
|