qm-dsp 1.8
Resampler.h
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 QM DSP Library
4
5 Centre for Digital Music, Queen Mary, University of London.
6 This file by Chris Cannam.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13*/
14
15#ifndef RESAMPLER_H
16#define RESAMPLER_H
17
18#include <vector>
19
31{
32public:
37 Resampler(int sourceRate, int targetRate);
38
43 Resampler(int sourceRate, int targetRate,
44 double snr, double bandwidth);
45
46 virtual ~Resampler();
47
55 int process(const double *src, double *dst, int n);
56
61 std::vector<double> process(const double *src, int n);
62
68 int getLatency() const { return m_latency; }
69
74 static std::vector<double> resample
75 (int sourceRate, int targetRate, const double *data, int n);
76
77private:
80 int m_gcd;
85
86 struct Phase {
88 std::vector<double> filter;
89 int drop;
90 };
91
94 std::vector<double> m_buffer;
96
97 void initialise(double, double);
98 double reconstructOne();
99};
100
101#endif
102
Resampler resamples a stream from one integer sample rate to another (arbitrary) rate,...
Definition Resampler.h:31
int m_sourceRate
Definition Resampler.h:78
int m_targetRate
Definition Resampler.h:79
int m_bufferLength
Definition Resampler.h:82
int m_filterLength
Definition Resampler.h:81
virtual ~Resampler()
Definition Resampler.cpp:50
double reconstructOne()
std::vector< double > m_buffer
Definition Resampler.h:94
void initialise(double, double)
Definition Resampler.cpp:63
Phase * m_phaseData
Definition Resampler.h:92
int getLatency() const
Return the number of samples of latency at the output due by the filter.
Definition Resampler.h:68
int m_latency
Definition Resampler.h:83
int m_gcd
Definition Resampler.h:80
int m_bufferOrigin
Definition Resampler.h:95
static std::vector< double > resample(int sourceRate, int targetRate, const double *data, int n)
Carry out a one-off resample of a single block of n samples.
double m_peakToPole
Definition Resampler.h:84
int m_phase
Definition Resampler.h:93
int process(const double *src, double *dst, int n)
Read n input samples from src and write resampled data to dst.
std::vector< double > filter
Definition Resampler.h:88