-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChallengeFactory.hpp
More file actions
86 lines (71 loc) · 2.78 KB
/
Copy pathChallengeFactory.hpp
File metadata and controls
86 lines (71 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef CHALLENGEFACTORY_HPP
#define CHALLENGEFACTORY_HPP
#include <map>
#include <random>
#include <string>
#include <vector>
/**
* @brief Classe ChallengeFactory
* Centralise la génération aléatoire de notes et d'accords
* harmonisée avec le protocole (c, d, e, f, g, a, b / maj, min)
*/
class ChallengeFactory {
private:
std::mt19937 rng; ///< Générateur de nombres aléatoires
int lastChordIdx{-1};
int currentChordIdx{-1}; ///< Index de l'accord en cours
int lastOctave{-1};
enum class LastGenType { None, Note, Chord, InversedChord };
LastGenType lastGenType{LastGenType::None};
// Matrices pour le modèle de génération (Markov) et Répétition Espacée (SR)
std::vector<std::vector<double>> markovMatrix;
std::vector<std::vector<double>> srMultiplier;
// Pour le jeu de notes (SR uniquement)
int currentNoteIdx{-1};
std::vector<double> noteSrMultiplier;
// Pour les renversements (Markov + SR)
int lastInversion{-1};
int currentInversion{-1};
std::vector<std::vector<double>> invMarkovMatrix;
std::vector<std::vector<double>> invSrMultiplier;
void initMarkovAndSR();
// Tables de gammes harmonisées avec le protocole
static const std::map<std::string, std::vector<std::string>> scales;
public:
ChallengeFactory();
/**
* @brief Retour sur l'exercice précédent pour adapter la répétition espacée
* @param success true si l'exercice a été réussi, false si échec
* @param durationMs temps de réponse en millisecondes
*/
void feedbackLastChallenge(bool success, int durationMs = 0);
/**
* @brief Génère une note aléatoire dans une gamme et un mode
* @param scale Gamme (c, d, e, f, g, a, b)
* @param mode Mode (maj, min)
* @return Note au format string (ex: "c4")
*/
std::string generateNote(const std::string& scale, const std::string& mode);
/**
* @brief Génère un accord aléatoire
* @param scale Gamme (c, d, e, f, g, a, b)
* @param mode Mode (maj, min)
* @return Paire {nom de l'accord, vecteur de notes}
*/
std::pair<std::string, std::vector<std::string>>
generateChord(const std::string& scale, const std::string& mode);
/**
* @brief Génère un accord avec renversement
* @param scale Gamme (c, d, e, f, g, a, b)
* @param mode Mode (maj, min)
* @return Tuple {nom, notes, renversement(1-3)}
*/
std::tuple<std::string, std::vector<std::string>, int>
generateInversedChord(const std::string& scale, const std::string& mode);
/**
* @brief Récupère les notes d'une gamme
*/
static std::vector<std::string> getScaleNotes(const std::string& scale,
const std::string& mode);
};
#endif // CHALLENGEFACTORY_HPP