Chris@19: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@19: Chris@42: /* Chris@42: Tipic Chris@42: Chris@42: Centre for Digital Music, Queen Mary, University of London. Chris@42: Chris@42: This program is free software; you can redistribute it and/or Chris@42: modify it under the terms of the GNU General Public License as Chris@42: published by the Free Software Foundation; either version 2 of the Chris@42: License, or (at your option) any later version. See the file Chris@42: COPYING included with this distribution for more information. Chris@42: */ Chris@42: Chris@19: #include "CRP.h" Chris@19: Chris@42: #include "maths/MathUtilities.h" Chris@24: #include "LogCompress.h" Chris@24: #include "OctaveFold.h" Chris@26: #include "Resize.h" Chris@19: Chris@19: #include Chris@19: #include Chris@19: Chris@19: using namespace std; Chris@19: Chris@26: CRP::CRP(Parameters params) : Chris@26: m_params(params), Chris@26: m_dctReduce(120, params.coefficientsToDrop) Chris@26: {} Chris@26: Chris@19: CRP::~CRP() Chris@26: {} Chris@19: Chris@19: RealBlock Chris@19: CRP::process(const RealBlock &in) Chris@19: { Chris@19: if (in.empty()) { Chris@19: return in; Chris@19: } Chris@25: Chris@19: RealBlock out; Chris@22: Chris@19: for (RealColumn col: in) { Chris@58: out.push_back(process(col)); Chris@58: } Chris@19: Chris@19: return out; Chris@19: } Chris@19: Chris@58: RealColumn Chris@58: CRP::process(RealColumn col) Chris@58: { Chris@58: if (m_params.applyLogCompression) { Chris@58: col = LogCompress::process Chris@58: (col, m_params.logFactor, m_params.logAddTerm); Chris@58: } Chris@58: Chris@58: return MathUtilities::normaliseLp Chris@58: (OctaveFold::process Chris@58: (m_dctReduce.process Chris@58: (Resize::process(col))), Chris@58: m_params.normP, m_params.normThresh); Chris@58: } Chris@58: