cannam@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
cannam@0
|
2
|
cannam@0
|
3 /*
|
cannam@0
|
4 QM DSP Library
|
cannam@0
|
5
|
cannam@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
cannam@0
|
7 This file copyright 2006 Martin Gasser.
|
Chris@84
|
8
|
Chris@84
|
9 This program is free software; you can redistribute it and/or
|
Chris@84
|
10 modify it under the terms of the GNU General Public License as
|
Chris@84
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@84
|
12 License, or (at your option) any later version. See the file
|
Chris@84
|
13 COPYING included with this distribution for more information.
|
cannam@0
|
14 */
|
cannam@0
|
15
|
cannam@0
|
16 #include "TCSgram.h"
|
cannam@0
|
17
|
cannam@0
|
18 #include <valarray>
|
cannam@0
|
19 #include <cmath>
|
cannam@0
|
20 #include <iostream>
|
cannam@0
|
21 #include <limits>
|
cannam@0
|
22
|
cannam@16
|
23 #include "maths/MathUtilities.h"
|
cannam@0
|
24
|
cannam@0
|
25 TCSGram::TCSGram() :
|
cannam@0
|
26 m_uNumBins(6)
|
cannam@0
|
27 {
|
cannam@0
|
28 }
|
cannam@0
|
29
|
cannam@0
|
30 TCSGram::~TCSGram()
|
cannam@0
|
31 {
|
cannam@0
|
32 }
|
cannam@0
|
33
|
cannam@0
|
34
|
cannam@0
|
35 void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const
|
cannam@0
|
36 {
|
cannam@0
|
37 if (iPosition < 0)
|
cannam@0
|
38 rTCSVector = TCSVector();
|
cannam@0
|
39 else if (iPosition >= m_VectorList.size())
|
cannam@0
|
40 rTCSVector = TCSVector();
|
cannam@0
|
41 else
|
cannam@0
|
42 rTCSVector = m_VectorList[iPosition].second;
|
cannam@0
|
43 }
|
cannam@0
|
44
|
cannam@0
|
45 long TCSGram::getTime(size_t uPosition) const
|
cannam@0
|
46 {
|
cannam@0
|
47 return m_VectorList[uPosition].first;
|
cannam@0
|
48 }
|
cannam@0
|
49
|
cannam@0
|
50
|
cannam@0
|
51 void TCSGram::addTCSVector(const TCSVector& rTCSVector)
|
cannam@0
|
52 {
|
cannam@0
|
53 size_t uSize = m_VectorList.size();
|
cannam@0
|
54 long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS);
|
cannam@0
|
55 std::pair<long, TCSVector> p;
|
cannam@0
|
56 p.first = lMilliSeconds;
|
cannam@0
|
57 p.second = rTCSVector;
|
cannam@0
|
58
|
cannam@0
|
59 m_VectorList.push_back(p);
|
cannam@0
|
60 }
|
cannam@0
|
61
|
cannam@0
|
62 long TCSGram::getDuration() const
|
cannam@0
|
63 {
|
cannam@0
|
64 size_t uSize = m_VectorList.size();
|
cannam@0
|
65 return static_cast<long>(uSize*m_dFrameDurationMS);
|
cannam@0
|
66 }
|
cannam@0
|
67
|
cannam@0
|
68 void TCSGram::printDebug()
|
cannam@0
|
69 {
|
cannam@0
|
70 vectorlist_t::iterator vectorIterator = m_VectorList.begin();
|
cannam@0
|
71
|
cannam@0
|
72 while (vectorIterator != m_VectorList.end())
|
cannam@0
|
73 {
|
cannam@0
|
74 vectorIterator->second.printDebug();
|
cannam@0
|
75 vectorIterator++;
|
cannam@0
|
76 }
|
cannam@0
|
77 }
|