-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNoteEvaluationStats.cpp
74 lines (62 loc) · 1.91 KB
/
NoteEvaluationStats.cpp
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
//============================================================================
/**
Implementation file for NoteEvaluationStats.h
@author Johan Pauwels
@date 20101206
*/
//============================================================================
// Includes
#include "NoteEvaluationStats.h"
NoteEvaluationStats::NoteEvaluationStats(const Eigen::ArrayXXd& inConfusionMatrix)
: m_ConfusionMatrix(inConfusionMatrix), m_NumOfNotes(inConfusionMatrix.rows() - 1),
m_NotesMatrix(m_ConfusionMatrix.topLeftCorner(m_NumOfNotes, m_NumOfNotes))
{
}
NoteEvaluationStats::~NoteEvaluationStats()
{
// Nothing to do...
}
const double NoteEvaluationStats::getCorrectNotes() const
{
return m_NotesMatrix.matrix().trace();
}
const double NoteEvaluationStats::getCorrectNoNotes() const
{
return m_ConfusionMatrix(m_NumOfNotes, m_NumOfNotes);
}
const double NoteEvaluationStats::getNoteDeletions() const
{
return m_ConfusionMatrix.rightCols<1>().head(m_NumOfNotes).sum();
}
const double NoteEvaluationStats::getNoteInsertions() const
{
return m_ConfusionMatrix.bottomRows<1>().head(m_NumOfNotes).sum();
}
const double NoteEvaluationStats::getOctaveErrors() const
{
double theOctaveDuration = 0.;
for (Eigen::ArrayXXd::Index i = 12; i < m_NumOfNotes; i += 12)
{
theOctaveDuration += m_NotesMatrix.matrix().diagonal(i).sum() +
m_NotesMatrix.matrix().diagonal(-i).sum();
}
return theOctaveDuration;
}
const double NoteEvaluationStats::getFifthErrors() const
{
double theFifthDuration = 0.;
for (Eigen::ArrayXXd::Index i = 5; i < m_NumOfNotes; i += 12)
{
theFifthDuration += m_NotesMatrix.matrix().diagonal(i).sum() +
m_NotesMatrix.matrix().diagonal(-i).sum();
}
return theFifthDuration;
}
const double NoteEvaluationStats::getChromaticUpErrors() const
{
return m_NotesMatrix.matrix().diagonal(-1).sum();
}
const double NoteEvaluationStats::getChromaticDownErrors() const
{
return m_NotesMatrix.matrix().diagonal(1).sum();
}