about summary refs log tree commit diff stats
path: root/generator/mood.cpp
blob: 9f53dce01383737b270d87748bd74b7e067fcbb9 (plain) (blame)
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
87
88
89
90
91
92
93
94
#include "mood.h"

namespace cadence {
  namespace generator {
    
    // The categories are:
    // - party (+danceable, -acoustic, +electronic, +party) = ~.21
    // - chill (-danceable, +acoustic, -aggressive, -electronic, -party, +relaxed) = ~.49
    // - crazy (+aggressive, -relaxed) = ~.02
    // - happy (+happy, -sad) = ~.009
    // - sad (-happy, +sad) = ~.02
    // - instrumental (+instrumental) = ~.12
    // - vocal (-instrumental) = ~.10
    
    mood::mood(type t, double prob) : type_(t)
    {
      if (prob >= 0.5)
      {
        probability_ = prob;
        positive_ = true;
      } else {
        probability_ = 1.0 - prob;
        positive_ = false;
      }
      
      switch (t)
      {
        case type::danceable:
        {
          category_ = (positive_ ? "party" : "chill");
          
          break;
        }
        
        case type::acoustic:
        {
          category_ = (positive_ ? "chill" : "party");
          
          break;
        }
        
        case type::aggressive:
        {
          category_ = (positive_ ? "crazy" : "chill");
          
          break;
        }
        
        case type::electronic:
        {
          category_ = (positive_ ? "party" : "chill");
          
          break;
        }
        
        case type::happy:
        {
          category_ = (positive_ ? "happy" : "sad");
          
          break;
        }
        
        case type::party:
        {
          category_ = (positive_ ? "party" : "chill");
          
          break;
        }
        
        case type::relaxed:
        {
          category_ = (positive_ ? "chill" : "crazy");
          
          break;
        }
        
        case type::sad:
        {
          category_ = (positive_ ? "sad" : "happy");
          
          break;
        }
        
        case type::instrumental:
        {
          category_ = (positive_ ? "instrumental" : "vocal");
          
          break;
        }
      }
    }
    
  };
};