Chris@24: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@24: 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@24: #ifndef DCTREDUCE_H Chris@24: #define DCTREDUCE_H Chris@24: Chris@42: #include "dsp/transforms/DCT.h" Chris@42: Chris@24: #include Chris@24: Chris@24: class DCTReduce Chris@24: { Chris@24: public: Chris@24: DCTReduce(int size, int coefficientsToDrop) : Chris@24: m_size(size), Chris@24: m_dct(size), Chris@24: m_dctOut(size), Chris@24: m_coefficientsToDrop(coefficientsToDrop) Chris@24: { } Chris@24: Chris@24: std::vector process(std::vector in) { Chris@24: std::vector out(in.size()); Chris@24: m_dct.forward(in.data(), m_dctOut.data()); Chris@24: for (int i = 0; i < m_coefficientsToDrop && i < m_size; ++i) { Chris@24: m_dctOut[i] = 0.0; Chris@24: } Chris@24: m_dct.inverse(m_dctOut.data(), out.data()); Chris@49: return out; Chris@24: } Chris@24: Chris@24: private: Chris@24: int m_size; Chris@24: DCT m_dct; Chris@24: std::vector m_dctOut; Chris@24: int m_coefficientsToDrop; Chris@24: }; Chris@24: Chris@24: #endif Chris@24: