Mercurial > hg > qm-dsp
comparison dsp/tonal/TCSgram.cpp @ 0:d7116e3183f8
* Queen Mary C++ DSP library
author | cannam |
---|---|
date | Wed, 05 Apr 2006 17:35:59 +0000 |
parents | |
children | 2e3f5d2d62c1 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d7116e3183f8 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 QM DSP Library | |
5 | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Martin Gasser. | |
8 All rights reserved. | |
9 */ | |
10 | |
11 #include "TCSgram.h" | |
12 | |
13 #include <valarray> | |
14 #include <cmath> | |
15 #include <iostream> | |
16 #include <limits> | |
17 | |
18 #include "dsp/maths/MathUtilities.h" | |
19 | |
20 TCSGram::TCSGram() : | |
21 m_uNumBins(6) | |
22 { | |
23 } | |
24 | |
25 TCSGram::~TCSGram() | |
26 { | |
27 } | |
28 | |
29 | |
30 void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const | |
31 { | |
32 if (iPosition < 0) | |
33 rTCSVector = TCSVector(); | |
34 else if (iPosition >= m_VectorList.size()) | |
35 rTCSVector = TCSVector(); | |
36 else | |
37 rTCSVector = m_VectorList[iPosition].second; | |
38 } | |
39 | |
40 long TCSGram::getTime(size_t uPosition) const | |
41 { | |
42 return m_VectorList[uPosition].first; | |
43 } | |
44 | |
45 | |
46 void TCSGram::addTCSVector(const TCSVector& rTCSVector) | |
47 { | |
48 size_t uSize = m_VectorList.size(); | |
49 long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS); | |
50 std::pair<long, TCSVector> p; | |
51 p.first = lMilliSeconds; | |
52 p.second = rTCSVector; | |
53 | |
54 m_VectorList.push_back(p); | |
55 } | |
56 | |
57 long TCSGram::getDuration() const | |
58 { | |
59 size_t uSize = m_VectorList.size(); | |
60 return static_cast<long>(uSize*m_dFrameDurationMS); | |
61 } | |
62 | |
63 void TCSGram::printDebug() | |
64 { | |
65 vectorlist_t::iterator vectorIterator = m_VectorList.begin(); | |
66 | |
67 while (vectorIterator != m_VectorList.end()) | |
68 { | |
69 vectorIterator->second.printDebug(); | |
70 vectorIterator++; | |
71 } | |
72 } |