1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
|
// -----------------------------------------------------------------------
// Copyright (C) 2003-2011 Fons Adriaensen <fons@linuxaudio.org>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// -----------------------------------------------------------------------
#ifndef __ZITA_H__
#define __ZITA_H__
#include "effects/effect.h"
namespace Ms {
class EffectGui;
//---------------------------------------------------------
// Pareq
//---------------------------------------------------------
class Pareq
{
enum { BYPASS, STATIC, SMOOTH, MAXCH = 4 };
void calcpar1 (int nsamp, float g, float f);
void process1 (int nsamp, float*);
volatile int16_t _touch0;
volatile int16_t _touch1;
#if 0 // not yet (?) used
bool _bypass;
#endif
int _state;
float _fsamp;
float _g;
float _g0, _g1;
float _f;
float _f0, _f1;
float _c1, _dc1;
float _c2, _dc2;
float _gg, _dgg;
float _z1 [MAXCH];
float _z2 [MAXCH];
public:
Pareq();
void setfsamp(float fsamp);
void setparam(float f, float g) {
_f = f;
_g = g;
_f0 = f;
_g0 = powf (10.0f, 0.05f * g);
_touch0++;
}
void set_gn(float g) { setparam(_f, g); }
float gn() const { return _g; }
void set_fr(float f) { setparam(f, _g); }
float fr() const { return _f; }
void reset();
void prepare(int nsamp);
void process(int nsamp, float* data) {
if (_state != BYPASS)
process1(nsamp, data);
}
};
//---------------------------------------------------------
// Diff1
//---------------------------------------------------------
class Diff1
{
friend class ZitaReverb;
int _i;
float _c;
int _size = 0;
float* _line = 0;
Diff1() {}
~Diff1();
void init(int size, float c);
void fini();
float process(float x) {
float z = _line [_i];
x -= _c * z;
_line [_i] = x;
if (++_i == _size)
_i = 0;
return z + _c * x;
}
};
//---------------------------------------------------------
// Filt1
//---------------------------------------------------------
class Filt1
{
friend class ZitaReverb;
Filt1 () : _slo (0), _shi (0) {}
~Filt1 () {}
void set_params (float del, float tmf, float tlo, float wlo, float thi, float chi);
float process(float x) {
_slo += _wlo * (x - _slo) + 1e-10f;
x += _glo * _slo;
_shi += _whi * (x - _shi);
return _gmf * _shi;
}
float _gmf;
float _glo;
float _wlo;
float _whi;
float _slo;
float _shi;
};
//---------------------------------------------------------
// Delay
//---------------------------------------------------------
class Delay
{
friend class ZitaReverb;
Delay();
~Delay();
void init (int size);
void fini ();
float read () { return _line [_i]; }
void write (float x) {
_line [_i++] = x;
if (_i == _size)
_i = 0;
}
int _i;
int _size;
float *_line;
};
//---------------------------------------------------------
// Vdelay
//---------------------------------------------------------
class Vdelay
{
friend class ZitaReverb;
Vdelay();
~Vdelay();
void init (int size);
void fini ();
void set_delay (int del);
float read () {
float x = _line [_ir++];
if (_ir == _size)
_ir = 0;
return x;
}
void write (float x) {
_line [_iw++] = x;
if (_iw == _size)
_iw = 0;
}
int _ir;
int _iw;
int _size;
float* _line;
};
//---------------------------------------------------------
// ZitaReverb
//---------------------------------------------------------
class ZitaReverb : public Effect
{
Q_OBJECT
float _fsamp;
Vdelay _vdelay0;
Vdelay _vdelay1;
Diff1 _diff1[8];
Filt1 _filt1[8];
Delay _delay[8];
volatile int _cntA1;
volatile int _cntB1;
volatile int _cntC1;
int _cntA2;
int _cntB2;
int _cntC2;
float _ipdel;
float _xover;
float _rtlow;
float _rtmid;
float _fdamp;
float _opmix;
float _rgxyz;
float _g0, _d0;
float _g1, _d1;
Pareq _pareq1;
Pareq _pareq2;
static float _tdiff1 [8];
static float _tdelay [8];
int _fragm;
int _nsamp;
void prepare(int n);
public:
ZitaReverb() : Effect() {}
~ZitaReverb();
virtual void init(float fsamp);
void fini();
virtual void process(int n, float* inp, float* out);
void set_delay(float v) { _ipdel = v; _cntA1++; }
float delay() const { return _ipdel; }
void set_xover(float v) { _xover = v; _cntB1++; }
float xover() const { return _xover; }
void set_rtlow(float v) { _rtlow = v; _cntB1++; }
float rtlow() const { return _rtlow; }
void set_rtmid(float v) { _rtmid = v; _cntB1++; _cntC1++; }
float rtmid() const { return _rtmid; }
void set_fdamp(float v) { _fdamp = v; _cntB1++; }
float fdamp() const { return _fdamp; }
void set_eq1fr(float f) { _pareq1.set_fr(f); }
float eq1fr() const { return _pareq1.fr(); }
void set_eq1gn(float f) { _pareq1.set_gn(f); }
float eq1gn() const { return _pareq1.gn(); }
void set_eq2fr(float f) { _pareq2.set_fr(f); }
float eq2fr() const { return _pareq2.fr(); }
void set_eq2gn(float f) { _pareq2.set_gn(f); }
float eq2gn() const { return _pareq2.gn(); }
void set_opmix(float v) { _opmix = v; _cntC1++; }
float opmix() const { return _opmix; }
virtual const char* name() const { return "Zita1"; }
virtual EffectGui* gui();
virtual const std::vector<ParDescr>& parDescr() const;
virtual void setNValue(int parameter, double value);
virtual double nvalue(int idx) const;
virtual SynthesizerGroup state() const;
virtual void setState(const SynthesizerGroup&);
};
}
#endif
|