1
// -------------------------------------------------------------------------
3
// Copyright (C) 2005-2007 Fons Adriaensen <fons@kokkinizita.net>
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19
// -------------------------------------------------------------------------
26
//#define USE_SSE_AND_3DN
32
enum { CONV_OPT_SSE = 1, CONV_OPT_3DN = 2 };
39
Convdata (size_t part, size_t lmax, unsigned int opts);
42
size_t part (void) const { return _part; }
43
unsigned int npar (void) const { return _npar; }
44
unsigned int opts (void) const { return _opts; }
46
void prepare_part (unsigned int ipar, float gain, float *data, int step = 1);
47
void prepare_done (void);
49
int get_refc (void) const { return _refc; }
50
int inc_refc (void) { return ++_refc; }
51
int dec_refc (void) { return --_refc; }
55
static void swap (fftwf_complex *p, size_t n);
57
friend class Convolver;
59
int _refc; // reference counter
60
size_t _part; // partition size in frames
61
unsigned int _opts; // optimization flags
62
unsigned int _npar; // number of partitions
63
unsigned int _nact; // number of active partitions
64
float _norm; // gain normalization
65
float *_buff; // input buffer
66
fftwf_complex **_fftd; // transformed partitions
67
fftwf_plan _plan; // fftw plan
76
Convolver (size_t part, size_t size, unsigned int opts, unsigned int nip, unsigned int nop);
79
float *wr_ptr (unsigned int i) const { return _ip_buff + i * _part; }
80
float *rd_ptr (unsigned int i) const { return _op_buff + 2 * i * _part; }
82
int set_conv (unsigned int ip, unsigned int op, Convdata *C);
83
Convdata *get_conv (unsigned int ip, unsigned int op) const { return _conv [ip + _nip * op]; }
88
size_t part (void) const { return _part; }
89
unsigned int npar (void) const { return _npar; }
90
unsigned int opts (void) const { return _opts; }
91
unsigned int nip (void) const { return _nip; }
92
unsigned int nop (void) const { return _nop; }
98
size_t _part; // partition size in frames
99
unsigned int _opts; // optimization flags
100
unsigned int _npar; // number of partitions
101
unsigned int _nip; // number of inputs
102
unsigned int _nop; // number of outputs
103
Convdata **_conv; // array of Convdata pointers
104
fftwf_plan _fwd_plan; // fftw plans
105
fftwf_plan _rev_plan; //
109
float *_ip_buff; // input buffer
110
float *_op_buff; // output buffer
111
float *_oA_buff; // alternating output buffers
113
fftwf_complex **_fwd_data; // circular array of input parts
114
fftwf_complex *_mac_data; // multiplied data accumulator
118
float *_wr_buff; // input pointer for input 0
119
float *_rd_buff; // output pointer for output 0