1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Martin Gasser.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
16 #include "TonalEstimator.h"
22 #define PI (3.14159265358979232846)
25 TonalEstimator::TonalEstimator()
33 m_Basis
[i
].resize(12);
34 for (int iP
= 0; iP
< 12; iP
++)
36 m_Basis
[i
][iP
] = std::sin( (7.0 / 6.0) * iP
* PI
);
41 m_Basis
[i
].resize(12);
42 for (int iP
= 0; iP
< 12; iP
++)
44 m_Basis
[i
][iP
] = std::cos( (7.0 / 6.0) * iP
* PI
);
50 // circle of major thirds
51 m_Basis
[i
].resize(12);
52 for (int iP
= 0; iP
< 12; iP
++)
54 m_Basis
[i
][iP
] = 0.6 * std::sin( (2.0 / 3.0) * iP
* PI
);
59 m_Basis
[i
].resize(12);
60 for (int iP
= 0; iP
< 12; iP
++)
62 m_Basis
[i
][iP
] = 0.6 * std::cos( (2.0 / 3.0) * iP
* PI
);
68 // circle of minor thirds
69 m_Basis
[i
].resize(12);
70 for (int iP
= 0; iP
< 12; iP
++)
72 m_Basis
[i
][iP
] = 1.1 * std::sin( (3.0 / 2.0) * iP
* PI
);
77 m_Basis
[i
].resize(12);
78 for (int iP
= 0; iP
< 12; iP
++)
80 m_Basis
[i
][iP
] = 1.1 * std::cos( (3.0 / 2.0) * iP
* PI
);
85 TonalEstimator::~TonalEstimator()
89 TCSVector
TonalEstimator::transform2TCS(const ChromaVector
& rVector
)
92 vaRetVal
.resize(6, 0.0);
94 for (int i
= 0; i
< 6; i
++)
96 for (int iP
= 0; iP
< 12; iP
++)
98 vaRetVal
[i
] += m_Basis
[i
][iP
] * rVector
[iP
];