qm-dsp
1.8
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 /* 00003 QM DSP Library 00004 00005 Centre for Digital Music, Queen Mary, University of London. 00006 This file by Chris Cannam. 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. See the file 00012 COPYING included with this distribution for more information. 00013 */ 00014 00015 #ifndef RESAMPLER_H 00016 #define RESAMPLER_H 00017 00018 #include <vector> 00019 00030 class Resampler 00031 { 00032 public: 00037 Resampler(int sourceRate, int targetRate); 00038 00043 Resampler(int sourceRate, int targetRate, 00044 double snr, double bandwidth); 00045 00046 virtual ~Resampler(); 00047 00055 int process(const double *src, double *dst, int n); 00056 00061 std::vector<double> process(const double *src, int n); 00062 00068 int getLatency() const { return m_latency; } 00069 00074 static std::vector<double> resample 00075 (int sourceRate, int targetRate, const double *data, int n); 00076 00077 private: 00078 int m_sourceRate; 00079 int m_targetRate; 00080 int m_gcd; 00081 int m_filterLength; 00082 int m_bufferLength; 00083 int m_latency; 00084 double m_peakToPole; 00085 00086 struct Phase { 00087 int nextPhase; 00088 std::vector<double> filter; 00089 int drop; 00090 }; 00091 00092 Phase *m_phaseData; 00093 int m_phase; 00094 std::vector<double> m_buffer; 00095 int m_bufferOrigin; 00096 00097 void initialise(double, double); 00098 double reconstructOne(); 00099 }; 00100 00101 #endif 00102