Guitarix
gx_resampler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3 * Copyright (C) 2011 Pete Shorthose
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * --------------------------------------------------------------------------
19 */
20
21/* ------- This is the guitarix resampler, to use zita-resampler ------- */
22
23#pragma once
24
25#ifndef SRC_HEADERS_GX_RESAMPLER_H_
26#define SRC_HEADERS_GX_RESAMPLER_H_
27
28#include <zita-resampler/resampler.h>
29
30namespace gx_resample {
31
32#define MAX_UPSAMPLE 8
33
35 private:
36 Resampler r_up, r_down;
37 int m_fact;
38 public:
40 void setup(int sampleRate, unsigned int fact);
41 void up(int count, float *input, float *output);
42 void down(int count, float *input, float *output);
43};
44
45class BufferResampler: Resampler {
46 public:
47 float *process(int fs_inp, int ilen, float *input, int fs_outp, int* olen);
48};
49
50class StreamingResampler: Resampler {
51 private:
54 public:
55 bool setup(int srcRate, int dstRate, int nchan);
56 int get_max_out_size(int i_size) { return (i_size * ratio_b) / ratio_a + 1; }
57 int process(int count, float *input, float *output);
58 int flush(float *output); // check source for max. output size
59};
60
62private:
63 Resampler r_up, r_down;
65public:
66 int setup(int _inputRate, int _outputRate);
67 int up(int count, float *input, float *output);
68 void down(float *input, float *output);
69 int max_out_count(int in_count) {
70 if (inputRate > outputRate) return in_count;
71 return static_cast<int>(ceil((in_count*static_cast<double>(outputRate))/inputRate)); }
72};
73
74}
75#endif // SRC_HEADERS_GX_RESAMPLER_H_
float * process(int fs_inp, int ilen, float *input, int fs_outp, int *olen)
int max_out_count(int in_count)
Definition: gx_resampler.h:69
void down(float *input, float *output)
int up(int count, float *input, float *output)
int setup(int _inputRate, int _outputRate)
void up(int count, float *input, float *output)
void down(int count, float *input, float *output)
void setup(int sampleRate, unsigned int fact)
int process(int count, float *input, float *output)
bool setup(int srcRate, int dstRate, int nchan)
int get_max_out_size(int i_size)
Definition: gx_resampler.h:56