about summary refs log tree commit diff stats
path: root/generator/mood.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'generator/mood.cpp')
-rw-r--r--generator/mood.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/generator/mood.cpp b/generator/mood.cpp new file mode 100644 index 0000000..9f53dce --- /dev/null +++ b/generator/mood.cpp
@@ -0,0 +1,94 @@
1#include "mood.h"
2
3namespace cadence {
4 namespace generator {
5
6 // The categories are:
7 // - party (+danceable, -acoustic, +electronic, +party) = ~.21
8 // - chill (-danceable, +acoustic, -aggressive, -electronic, -party, +relaxed) = ~.49
9 // - crazy (+aggressive, -relaxed) = ~.02
10 // - happy (+happy, -sad) = ~.009
11 // - sad (-happy, +sad) = ~.02
12 // - instrumental (+instrumental) = ~.12
13 // - vocal (-instrumental) = ~.10
14
15 mood::mood(type t, double prob) : type_(t)
16 {
17 if (prob >= 0.5)
18 {
19 probability_ = prob;
20 positive_ = true;
21 } else {
22 probability_ = 1.0 - prob;
23 positive_ = false;
24 }
25
26 switch (t)
27 {
28 case type::danceable:
29 {
30 category_ = (positive_ ? "party" : "chill");
31
32 break;
33 }
34
35 case type::acoustic:
36 {
37 category_ = (positive_ ? "chill" : "party");
38
39 break;
40 }
41
42 case type::aggressive:
43 {
44 category_ = (positive_ ? "crazy" : "chill");
45
46 break;
47 }
48
49 case type::electronic:
50 {
51 category_ = (positive_ ? "party" : "chill");
52
53 break;
54 }
55
56 case type::happy:
57 {
58 category_ = (positive_ ? "happy" : "sad");
59
60 break;
61 }
62
63 case type::party:
64 {
65 category_ = (positive_ ? "party" : "chill");
66
67 break;
68 }
69
70 case type::relaxed:
71 {
72 category_ = (positive_ ? "chill" : "crazy");
73
74 break;
75 }
76
77 case type::sad:
78 {
79 category_ = (positive_ ? "sad" : "happy");
80
81 break;
82 }
83
84 case type::instrumental:
85 {
86 category_ = (positive_ ? "instrumental" : "vocal");
87
88 break;
89 }
90 }
91 }
92
93 };
94};