qm-dsp
1.8
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 QM DSP Library 00005 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Martin Gasser. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #include "TCSgram.h" 00017 00018 #include <valarray> 00019 #include <cmath> 00020 #include <iostream> 00021 #include <limits> 00022 00023 #include "maths/MathUtilities.h" 00024 00025 TCSGram::TCSGram() : 00026 m_uNumBins(6) 00027 { 00028 } 00029 00030 TCSGram::~TCSGram() 00031 { 00032 } 00033 00034 00035 void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const 00036 { 00037 if (iPosition < 0) 00038 rTCSVector = TCSVector(); 00039 else if (iPosition >= m_VectorList.size()) 00040 rTCSVector = TCSVector(); 00041 else 00042 rTCSVector = m_VectorList[iPosition].second; 00043 } 00044 00045 long TCSGram::getTime(size_t uPosition) const 00046 { 00047 return m_VectorList[uPosition].first; 00048 } 00049 00050 00051 void TCSGram::addTCSVector(const TCSVector& rTCSVector) 00052 { 00053 size_t uSize = m_VectorList.size(); 00054 long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS); 00055 std::pair<long, TCSVector> p; 00056 p.first = lMilliSeconds; 00057 p.second = rTCSVector; 00058 00059 m_VectorList.push_back(p); 00060 } 00061 00062 long TCSGram::getDuration() const 00063 { 00064 size_t uSize = m_VectorList.size(); 00065 return static_cast<long>(uSize*m_dFrameDurationMS); 00066 } 00067 00068 void TCSGram::printDebug() 00069 { 00070 vectorlist_t::iterator vectorIterator = m_VectorList.begin(); 00071 00072 while (vectorIterator != m_VectorList.end()) 00073 { 00074 vectorIterator->second.printDebug(); 00075 vectorIterator++; 00076 } 00077 }