TCSgram.cpp
Go to the documentation of this file.
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 
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.
14 */
15 
16 #include "TCSgram.h"
17 
18 #include <valarray>
19 #include <cmath>
20 #include <iostream>
21 #include <limits>
22 
23 #include "maths/MathUtilities.h"
24 
26  m_uNumBins(6)
27 {
28 }
29 
31 {
32 }
33 
34 
35 void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const
36 {
37  if (iPosition < 0) {
38  rTCSVector = TCSVector();
39  } else if (iPosition >= int(m_VectorList.size())) {
40  rTCSVector = TCSVector();
41  } else {
42  rTCSVector = m_VectorList[iPosition].second;
43  }
44 }
45 
46 long TCSGram::getTime(size_t uPosition) const
47 {
48  return m_VectorList[uPosition].first;
49 }
50 
51 
52 void TCSGram::addTCSVector(const TCSVector& rTCSVector)
53 {
54  size_t uSize = m_VectorList.size();
55  long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS);
56  std::pair<long, TCSVector> p;
57  p.first = lMilliSeconds;
58  p.second = rTCSVector;
59 
60  m_VectorList.push_back(p);
61 }
62 
64 {
65  size_t uSize = m_VectorList.size();
66  return static_cast<long>(uSize*m_dFrameDurationMS);
67 }
68 
70 {
71  vectorlist_t::iterator vectorIterator = m_VectorList.begin();
72 
73  while (vectorIterator != m_VectorList.end()) {
74  vectorIterator->second.printDebug();
75  vectorIterator++;
76  }
77 }
TCSGram()
Definition: TCSgram.cpp:25
long getTime(size_t) const
Definition: TCSgram.cpp:46
void addTCSVector(const TCSVector &)
Definition: TCSgram.cpp:52
void getTCSVector(int, TCSVector &) const
Definition: TCSgram.cpp:35
vectorlist_t m_VectorList
Definition: TCSgram.h:48
double m_dFrameDurationMS
Definition: TCSgram.h:50
void printDebug()
Definition: TCSgram.cpp:69
~TCSGram()
Definition: TCSgram.cpp:30
long getDuration() const
Definition: TCSgram.cpp:63