summaryrefslogtreecommitdiff
path: root/zam-plugins/zita-convolver4.patch
blob: d31db9eb67b2133f07062525282b38edf9616c0f (plain)
    1 From 71d221b7560c53d48bacf77a1624c467d816b413 Mon Sep 17 00:00:00 2001
    2 From: Damien Zammit <damien@zamaudio.com>
    3 Date: Sat, 9 Jun 2018 17:27:56 +1000
    4 Subject: [PATCH 1/3] lib: Update to zita-convolver 4.0.0
    5 
    6 ---
    7  Makefile                                      |   2 +-
    8  lib/zita-convolver-3.1.0/zita-convolver.h     | 471 -----------------
    9  .../zcsema-osx-win-compat.h                   |  40 ++
   10  .../zita-convolver.cpp                        | 465 +++++++++--------
   11  lib/zita-convolver-4.0.0/zita-convolver.h     | 475 ++++++++++++++++++
   12  plugins/ZamHeadX2/Makefile                    |   2 +-
   13  plugins/ZamHeadX2/convolution.cpp             |  10 +-
   14  plugins/ZamHeadX2/convolution.hpp             |   2 +-
   15  plugins/ZamVerb/Makefile                      |   2 +-
   16  plugins/ZamVerb/convolution.cpp               |  10 +-
   17  plugins/ZamVerb/convolution.hpp               |   2 +-
   18  11 files changed, 783 insertions(+), 698 deletions(-)
   19  delete mode 100644 lib/zita-convolver-3.1.0/zita-convolver.h
   20  create mode 100644 lib/zita-convolver-4.0.0/zcsema-osx-win-compat.h
   21  rename lib/{zita-convolver-3.1.0 => zita-convolver-4.0.0}/zita-convolver.cpp (68%)
   22  create mode 100644 lib/zita-convolver-4.0.0/zita-convolver.h
   23 
   24 diff --git a/Makefile b/Makefile
   25 index fc8991b..3220651 100644
   26 --- a/Makefile
   27 +++ b/Makefile
   28 @@ -68,7 +68,7 @@ ifeq ($(HAVE_DGL),true)
   29  	$(MAKE) clean -C dpf/dgl
   30  endif
   31  	$(MAKE) clean -C dpf/utils/lv2-ttl-generator
   32 -	rm -f lib/zita-convolver-3.1.0/*.o lib/zita-convolver-3.1.0/*.d
   33 +	rm -f lib/zita-convolver-4.0.0/*.o lib/zita-convolver-4.0.0/*.d
   34  	rm -f plugins/ZamSFZ/libsfz/*.o plugins/ZamSFZ/libsfz/*.d
   35  
   36  # --------------------------------------------------------------
   37 diff --git a/lib/zita-convolver-3.1.0/zita-convolver.h b/lib/zita-convolver-3.1.0/zita-convolver.h
   38 deleted file mode 100644
   39 index 37f4d03..0000000
   40 --- a/lib/zita-convolver-3.1.0/zita-convolver.h
   41 +++ /dev/null
   42 @@ -1,471 +0,0 @@
   43 -// ----------------------------------------------------------------------------
   44 -//
   45 -//  Copyright (C) 2006-2011 Fons Adriaensen <fons@linuxaudio.org>
   46 -//    
   47 -//  This program is free software; you can redistribute it and/or modify
   48 -//  it under the terms of the GNU General Public License as published by
   49 -//  the Free Software Foundation; either version 3 of the License, or
   50 -//  (at your option) any later version.
   51 -//
   52 -//  This program is distributed in the hope that it will be useful,
   53 -//  but WITHOUT ANY WARRANTY; without even the implied warranty of
   54 -//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   55 -//  GNU General Public License for more details.
   56 -//
   57 -//  You should have received a copy of the GNU General Public License
   58 -//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
   59 -//
   60 -// ----------------------------------------------------------------------------
   61 -
   62 -
   63 -#ifndef _ZITA_CONVOLVER_H
   64 -#define _ZITA_CONVOLVER_H
   65 -
   66 -#define _POSIX_PTHREAD_SEMANTICS
   67 -
   68 -#include <errno.h>
   69 -#include <pthread.h>
   70 -#include <fftw3.h>
   71 -
   72 -
   73 -#define ZITA_CONVOLVER_MAJOR_VERSION 3
   74 -#define ZITA_CONVOLVER_MINOR_VERSION 1
   75 -
   76 -
   77 -extern int zita_convolver_major_version (void);
   78 -extern int zita_convolver_minor_version (void);
   79 -
   80 -
   81 -// ----------------------------------------------------------------------------
   82 -
   83 -
   84 -#ifdef ZCSEMA_IS_IMPLEMENTED
   85 -#undef ZCSEMA_IS_IMPLEMENTED
   86 -#endif
   87 -
   88 -
   89 -#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__WIN32__)
   90 -
   91 -// NOTE: __FreeBSD_kernel__  and __GNU__ were added by the Debian maintainers
   92 -// (the latter for the HURD version of Debian). Things are reported to work
   93 -// with some applications but probably have not been tested in depth.
   94 -// __WIN32__ was added by DZ for MingW
   95 -
   96 -#include <semaphore.h>
   97 -
   98 -class ZCsema
   99 -{
  100 -public:
  101 -
  102 -    ZCsema (void) { init (0, 0); }
  103 -    ~ZCsema (void) { sem_destroy (&_sema); }
  104 -
  105 -    ZCsema (const ZCsema&); // disabled
  106 -    ZCsema& operator= (const ZCsema&); // disabled
  107 -
  108 -    int init (int s, int v) { return sem_init (&_sema, s, v); }
  109 -    int post (void) { return sem_post (&_sema); }
  110 -    int wait (void) { return sem_wait (&_sema); }
  111 -    int trywait (void) { return sem_trywait (&_sema); }
  112 -
  113 -private:
  114 -
  115 -    sem_t  _sema;
  116 -};
  117 -
  118 -#define ZCSEMA_IS_IMPLEMENTED
  119 -#endif
  120 -
  121 -
  122 -// ADDED BY DZ TO MAKE IT COMPILE FOR OSX 10.5 or Windows
  123 -#if defined(__APPLE__) || defined(__WIN32__)
  124 -inline int posix_memalign(void **memptr, size_t alignment, size_t size)
  125 -{
  126 -   *memptr = malloc(size);
  127 -   if (*memptr == NULL)
  128 -       return ENOMEM;
  129 -   return 0;
  130 -}
  131 -#endif
  132 -
  133 -
  134 -#ifdef __APPLE__
  135 -
  136 -// NOTE:  ***** I DO NOT REPEAT NOT PROVIDE SUPPORT FOR OSX *****
  137 -// 
  138 -// The following code partially emulates the POSIX sem_t for which
  139 -// OSX has only a crippled implementation. It may or may not compile,
  140 -// and if it compiles it may or may not work correctly. Blame APPLE
  141 -// for not following POSIX standards.
  142 -
  143 -class ZCsema
  144 -{
  145 -public:
  146 -
  147 -    ZCsema (void) : _count (0)
  148 -    {
  149 -        init (0, 0);
  150 -    }
  151 -
  152 -    ~ZCsema (void)
  153 -    {
  154 -        pthread_mutex_destroy (&_mutex);
  155 -        pthread_cond_destroy (&_cond);
  156 -    }
  157 -
  158 -    ZCsema (const ZCsema&); // disabled
  159 -    ZCsema& operator= (const ZCsema&); // disabled
  160 -
  161 -    int init (int s, int v)
  162 -    {
  163 -	_count = v;
  164 -        return pthread_mutex_init (&_mutex, 0) || pthread_cond_init (&_cond, 0);
  165 -    }
  166 -
  167 -    int post (void)
  168 -    {
  169 -	pthread_mutex_lock (&_mutex);
  170 -	_count++;
  171 -	if (_count == 1) pthread_cond_signal (&_cond);
  172 -	pthread_mutex_unlock (&_mutex);
  173 -	return 0;
  174 -    }
  175 -
  176 -    int wait (void)
  177 -    {
  178 -	pthread_mutex_lock (&_mutex);
  179 -	while (_count < 1) pthread_cond_wait (&_cond, &_mutex);
  180 -	_count--;
  181 -	pthread_mutex_unlock (&_mutex);
  182 -	return 0;
  183 -    }
  184 -
  185 -    int trywait (void)
  186 -    {
  187 -	if (pthread_mutex_trylock (&_mutex)) return -1;
  188 -	if (_count < 1)
  189 -	{
  190 -	    pthread_mutex_unlock (&_mutex);
  191 -	    return -1;
  192 -	}
  193 -        _count--;
  194 -        pthread_mutex_unlock (&_mutex);
  195 -        return 0;
  196 -    }
  197 -
  198 -private:
  199 -
  200 -    int              _count;
  201 -    pthread_mutex_t  _mutex;
  202 -    pthread_cond_t   _cond;
  203 -};
  204 -
  205 -#define ZCSEMA_IS_IMPLEMENTED
  206 -#endif
  207 -
  208 -
  209 -#ifndef ZCSEMA_IS_IMPLEMENTED
  210 -#error "The ZCsema class is not implemented."
  211 -#endif
  212 -
  213 -
  214 -// ----------------------------------------------------------------------------
  215 -
  216 -
  217 -class Inpnode   
  218 -{
  219 -private:
  220 -
  221 -    friend class Convlevel;
  222 -
  223 -    Inpnode        *_next;
  224 -    fftwf_complex **_ffta;
  225 -    unsigned int    _inp;
  226 -};
  227 -
  228 -
  229 -class Macnode  
  230 -{
  231 -private:
  232 -
  233 -    friend class Convlevel;
  234 -
  235 -    Macnode        *_next;
  236 -    Inpnode        *_inpn;
  237 -    fftwf_complex **_fftb;
  238 -    bool            _copy;
  239 -};
  240 -
  241 -
  242 -class Outnode   
  243 -{
  244 -private:
  245 -
  246 -    friend class Convlevel;
  247 -
  248 -    Outnode        *_next;
  249 -    Macnode        *_list;
  250 -    float          *_buff [3];
  251 -    unsigned int    _out;
  252 -};
  253 -
  254 -
  255 -class Converror
  256 -{
  257 -public:
  258 -
  259 -    enum
  260 -    {
  261 -	BAD_STATE = -1,
  262 -	BAD_PARAM = -2,
  263 -        MEM_ALLOC = -3
  264 -    };
  265 -
  266 -private:
  267 -
  268 -    friend class Convlevel;
  269 -    friend class Convproc;
  270 -
  271 -    Converror (int error) : _error (error) {}
  272 -
  273 -    int _error;
  274 -};
  275 -
  276 -
  277 -class Convlevel
  278 -{
  279 -private:
  280 -
  281 -    friend class Convproc;
  282 -
  283 -    enum 
  284 -    {
  285 -        OPT_FFTW_MEASURE = 1,
  286 -        OPT_VECTOR_MODE  = 2
  287 -    };
  288 -
  289 -    enum
  290 -    {
  291 -        ST_IDLE,
  292 -        ST_TERM,
  293 -        ST_PROC
  294 -    };
  295 -
  296 -    Convlevel (void);
  297 -    ~Convlevel (void);
  298 -
  299 -    void *alloc_aligned (size_t size);
  300 -
  301 -    void configure (int prio,
  302 -                    unsigned int offs,
  303 -                    unsigned int npar,
  304 -                    unsigned int parsize,
  305 -		    unsigned int options);
  306 -
  307 -    void impdata_create (unsigned int inp,
  308 -                         unsigned int out,
  309 -                         unsigned int step,
  310 -                         float *data,
  311 -                         int ind0,
  312 -                         int ind1); 
  313 -
  314 -    void impdata_update (unsigned int inp,
  315 -                         unsigned int out,
  316 -                         unsigned int step,
  317 -                         float *data,
  318 -                         int ind0,
  319 -                         int ind1); 
  320 -
  321 -    void impdata_copy (unsigned int inp1,
  322 -                       unsigned int out1,
  323 -                       unsigned int inp2,
  324 -                       unsigned int out2);
  325 -
  326 -    void reset (unsigned int inpsize,
  327 -                unsigned int outsize,
  328 -	        float **inpbuff,
  329 -	        float **outbuff);
  330 -
  331 -    void start (int absprio, int policy);
  332 -
  333 -    void process (bool sync);
  334 -
  335 -    int  readout (bool sync, unsigned int skipcnt);
  336 -
  337 -    void stop (void);
  338 -
  339 -    void cleanup (void);
  340 -
  341 -    void fftswap (fftwf_complex *p);
  342 -
  343 -    void print (FILE *F);
  344 -
  345 -    static void *static_main (void *arg);
  346 -
  347 -    void main (void);
  348 -
  349 -    Macnode *findmacnode (unsigned int inp, unsigned int out, bool create);
  350 -
  351 -    volatile unsigned int _stat;           // current processing state
  352 -    int                   _prio;           // relative priority
  353 -    unsigned int          _offs;           // offset from start of impulse response
  354 -    unsigned int          _npar;           // number of partitions
  355 -    unsigned int          _parsize;        // partition and outbut buffer size
  356 -    unsigned int          _outsize;        // step size for output buffer
  357 -    unsigned int          _outoffs;        // offset into output buffer
  358 -    unsigned int          _inpsize;        // size of shared input buffer 
  359 -    unsigned int          _inpoffs;        // offset into input buffer
  360 -    unsigned int          _options;        // various options
  361 -    unsigned int          _ptind;          // rotating partition index
  362 -    unsigned int          _opind;          // rotating output buffer index
  363 -    int                   _bits;           // bit identifiying this level
  364 -    int                   _wait;           // number of unfinished cycles
  365 -    pthread_t             _pthr;           // posix thread executing this level
  366 -    ZCsema                _trig;           // sema used to trigger a cycle
  367 -    ZCsema                _done;           // sema used to wait for a cycle
  368 -    Inpnode              *_inp_list;       // linked list of active inputs
  369 -    Outnode              *_out_list;       // linked list of active outputs
  370 -    fftwf_plan            _plan_r2c;       // FFTW plan, forward FFT
  371 -    fftwf_plan            _plan_c2r;       // FFTW plan, inverse FFT
  372 -    float                *_time_data;      // workspace
  373 -    float                *_prep_data;      // workspace
  374 -    fftwf_complex        *_freq_data;      // workspace
  375 -    float               **_inpbuff;        // array of shared input buffers
  376 -    float               **_outbuff;        // array of shared output buffers
  377 -};
  378 -
  379 -
  380 -// ----------------------------------------------------------------------------
  381 -
  382 -
  383 -class Convproc
  384 -{
  385 -public:
  386 -
  387 -    Convproc (void);
  388 -    ~Convproc (void);
  389 -
  390 -    enum
  391 -    {
  392 -        ST_IDLE,
  393 -	ST_STOP,
  394 -        ST_WAIT,
  395 -        ST_PROC
  396 -    };
  397 -
  398 -    enum
  399 -    {
  400 -        FL_LATE = 0x0000FFFF,
  401 -	FL_LOAD = 0x01000000
  402 -    };
  403 -
  404 -    enum 
  405 -    {
  406 -        OPT_FFTW_MEASURE = Convlevel::OPT_FFTW_MEASURE, 
  407 -        OPT_VECTOR_MODE  = Convlevel::OPT_VECTOR_MODE
  408 -    };
  409 -
  410 -    enum
  411 -    {
  412 -	MAXINP   = 64,
  413 -	MAXOUT   = 64,
  414 -	MAXLEV   = 8,
  415 -	MINPART  = 64,
  416 -	MAXPART  = 8192,
  417 -	MAXDIVIS = 16,
  418 -	MINQUANT = 16,
  419 -	MAXQUANT = 8192
  420 -    };
  421 -
  422 -    unsigned int state (void) const
  423 -    {
  424 -	return _state;
  425 -    }
  426 -
  427 -    float *inpdata (unsigned int inp) const
  428 -    {
  429 -	return _inpbuff [inp] + _inpoffs;
  430 -    }
  431 -
  432 -    float *outdata (unsigned int out) const
  433 -    {
  434 -	return _outbuff [out] + _outoffs;
  435 -    }
  436 -
  437 -    void set_density (float density);
  438 -
  439 -    void set_options (unsigned int options);
  440 -
  441 -    void set_skipcnt (unsigned int skipcnt);
  442 -
  443 -    int configure (unsigned int ninp,
  444 -                   unsigned int nout,
  445 -                   unsigned int maxsize,
  446 -                   unsigned int quantum,
  447 -                   unsigned int minpart,
  448 -                   unsigned int maxpart);
  449 -
  450 -    int impdata_create (unsigned int inp,
  451 -                        unsigned int out,
  452 -                        unsigned int step,
  453 -                        float       *data,
  454 -                        int          ind0,
  455 -                        int          ind1); 
  456 -
  457 -    int impdata_update (unsigned int inp,
  458 -                        unsigned int out,
  459 -                        unsigned int step,
  460 -                        float       *data,
  461 -                        int          ind0,
  462 -                        int          ind1); 
  463 -
  464 -    int impdata_copy (unsigned int inp1,
  465 -                      unsigned int out1,
  466 -                      unsigned int inp2,
  467 -                      unsigned int out2);
  468 -
  469 -    int reset (void);
  470 -
  471 -    int start_process (int abspri, int policy);
  472 -
  473 -    int process (bool sync = false);
  474 -
  475 -    int stop_process (void);
  476 -
  477 -    bool check_stop (void);
  478 -
  479 -    int cleanup (void);
  480 -
  481 -    void print (FILE *F = stdout);
  482 -
  483 -    static float _mac_cost;
  484 -    static float _fft_cost;
  485 -
  486 -private:
  487 -
  488 -    unsigned int    _state;                   // current state
  489 -    float          *_inpbuff [MAXINP];        // input buffers
  490 -    float          *_outbuff [MAXOUT];        // output buffers
  491 -    unsigned int    _inpoffs;                 // current offset in input buffers
  492 -    unsigned int    _outoffs;                 // current offset in output buffers
  493 -    unsigned int    _options;                 // option bits
  494 -    unsigned int    _skipcnt;                 // number of frames to skip 
  495 -    float           _density;                 // matrix density hint
  496 -    unsigned int    _ninp;                    // number of inputs
  497 -    unsigned int    _nout;                    // number of outputs
  498 -    unsigned int    _quantum;                 // processing block size
  499 -    unsigned int    _minpart;                 // smallest partition size
  500 -    unsigned int    _maxpart;                 // largest allowed partition size
  501 -    unsigned int    _nlevels;                 // number of partition sizes
  502 -    unsigned int    _inpsize;                 // size of input buffers
  503 -    unsigned int    _latecnt;                 // count of cycles ending too late
  504 -    Convlevel      *_convlev [MAXLEV];        // array of processors 
  505 -    void           *_dummy [64];
  506 -};
  507 -
  508 -
  509 -// ----------------------------------------------------------------------------
  510 -
  511 -
  512 -#endif
  513 -
  514 diff --git a/lib/zita-convolver-4.0.0/zcsema-osx-win-compat.h b/lib/zita-convolver-4.0.0/zcsema-osx-win-compat.h
  515 new file mode 100644
  516 index 0000000..807f6b8
  517 --- /dev/null
  518 +++ b/lib/zita-convolver-4.0.0/zcsema-osx-win-compat.h
  519 @@ -0,0 +1,40 @@
  520 +#if defined(__WIN32__)
  521 +
  522 +#include <semaphore.h>
  523 +
  524 +class ZCsema
  525 +{
  526 +public:
  527 +
  528 +    ZCsema (void) { init (0, 0); }
  529 +    ~ZCsema (void) { sem_destroy (&_sema); }
  530 +
  531 +    ZCsema (const ZCsema&); // disabled
  532 +    ZCsema& operator= (const ZCsema&); // disabled
  533 +
  534 +    int init (int s, int v) { return sem_init (&_sema, s, v); }
  535 +    int post (void) { return sem_post (&_sema); }
  536 +    int wait (void) { return sem_wait (&_sema); }
  537 +    int trywait (void) { return sem_trywait (&_sema); }
  538 +
  539 +private:
  540 +
  541 +    sem_t  _sema;
  542 +};
  543 +
  544 +#define ZCSEMA_IS_IMPLEMENTED
  545 +#endif
  546 +
  547 +
  548 +// ADDED BY DZ TO MAKE IT COMPILE FOR OSX 10.5 or Windows
  549 +#if defined(__APPLE__) || defined(__WIN32__)
  550 +#include <errno.h>
  551 +
  552 +inline int posix_memalign(void **memptr, size_t alignment, size_t size)
  553 +{
  554 +   *memptr = malloc(size);
  555 +   if (*memptr == NULL)
  556 +       return ENOMEM;
  557 +   return 0;
  558 +}
  559 +#endif
  560 diff --git a/lib/zita-convolver-3.1.0/zita-convolver.cpp b/lib/zita-convolver-4.0.0/zita-convolver.cpp
  561 similarity index 68%
  562 rename from lib/zita-convolver-3.1.0/zita-convolver.cpp
  563 rename to lib/zita-convolver-4.0.0/zita-convolver.cpp
  564 index a5155de..202533d 100644
  565 --- a/lib/zita-convolver-3.1.0/zita-convolver.cpp
  566 +++ b/lib/zita-convolver-4.0.0/zita-convolver.cpp
  567 @@ -1,6 +1,6 @@
  568  // ----------------------------------------------------------------------------
  569  //
  570 -//  Copyright (C) 2006-2011 Fons Adriaensen <fons@linuxaudio.org>
  571 +//  Copyright (C) 2006-2018 Fons Adriaensen <fons@linuxaudio.org>
  572  //    
  573  //  This program is free software; you can redistribute it and/or modify
  574  //  it under the terms of the GNU General Public License as published by
  575 @@ -42,11 +42,27 @@ float Convproc::_mac_cost = 1.0f;
  576  float Convproc::_fft_cost = 5.0f;
  577  
  578  
  579 +static float *calloc_real (uint32_t k)
  580 +{
  581 +    float *p = fftwf_alloc_real (k);
  582 +    if (!p) throw (Converror (Converror::MEM_ALLOC));
  583 +    memset (p, 0, k * sizeof (float));
  584 +    return p;
  585 +}
  586 +
  587 +static fftwf_complex *calloc_complex (uint32_t k)
  588 +{
  589 +    fftwf_complex *p = fftwf_alloc_complex (k);
  590 +    if (!p) throw (Converror (Converror::MEM_ALLOC));
  591 +    memset (p, 0, k * sizeof (fftwf_complex));
  592 +    return p;
  593 +}
  594 +
  595 +
  596  Convproc::Convproc (void) :
  597      _state (ST_IDLE),
  598      _options (0),
  599      _skipcnt (0),
  600 -    _density (0),
  601      _ninp (0),
  602      _nout (0),
  603      _quantum (0),
  604 @@ -63,41 +79,39 @@ Convproc::Convproc (void) :
  605  
  606  Convproc::~Convproc (void)
  607  {
  608 +    stop_process ();
  609      cleanup ();
  610  }
  611  
  612  
  613 -void Convproc::set_options (unsigned int options)
  614 +void Convproc::set_options (uint32_t options)
  615  {
  616      _options = options;
  617  }
  618  
  619  
  620 -void Convproc::set_density (float density)
  621 -{
  622 -    _density = density;
  623 -}
  624 -
  625 -
  626 -void Convproc::set_skipcnt (unsigned int skipcnt)
  627 +void Convproc::set_skipcnt (uint32_t skipcnt)
  628  {
  629      if ((_quantum == _minpart) && (_quantum == _maxpart)) _skipcnt = skipcnt;
  630  }
  631  
  632  
  633 -int Convproc::configure (unsigned int ninp,
  634 -                         unsigned int nout,
  635 -                         unsigned int maxsize,
  636 -                         unsigned int quantum,
  637 -                         unsigned int minpart,
  638 -			 unsigned int maxpart)
  639 +int Convproc::configure (uint32_t  ninp,
  640 +                         uint32_t  nout,
  641 +                         uint32_t  maxsize,
  642 +                         uint32_t  quantum,
  643 +                         uint32_t  minpart,
  644 +			 uint32_t  maxpart,
  645 +                         float     density)
  646  {
  647 -    unsigned int  offs, npar, size, pind, nmin, nmax, step, i;
  648 -    int           prio, d, r, s;
  649 -    float         cfft, cmac, t;
  650 +    uint32_t  offs, npar, size, pind, nmin, i;
  651 +    int       prio, step, d, r, s;
  652 +    float     cfft, cmac;
  653      
  654      if (_state != ST_IDLE) return Converror::BAD_STATE;
  655 -    if (   (quantum & (quantum - 1))
  656 +    if (   (ninp < 1) || (ninp > MAXINP)
  657 +        || (nout < 1) || (nout > MAXOUT)
  658 +	|| (quantum & (quantum - 1))
  659          || (quantum < MINQUANT)
  660          || (quantum > MAXQUANT)
  661          || (minpart & (minpart - 1))
  662 @@ -108,21 +122,12 @@ int Convproc::configure (unsigned int ninp,
  663  	|| (maxpart > MAXPART)
  664  	|| (maxpart < minpart)) return Converror::BAD_PARAM;
  665  
  666 -    if (ninp < nout) { nmin = ninp; nmax = nout; }
  667 -    else             { nmin = nout; nmax = ninp; }
  668 -
  669 -    if (_density <= 0) _density = 1.0 / nmin;
  670 -    else
  671 -    {
  672 -        t = 1.0f / nmax;
  673 -        if (_density < t) _density = t;
  674 -        if (_density > 1) _density = 1;
  675 -    }
  676 -
  677 +    nmin = (ninp < nout) ? ninp : nout;
  678 +    if (density <= 0.0f) density = 1.0f / nmin;
  679 +    if (density >  1.0f) density = 1.0f;
  680      cfft = _fft_cost * (ninp + nout);
  681 -    cmac = _mac_cost * ninp * nout * _density;
  682 +    cmac = _mac_cost * ninp * nout * density;
  683      step = (cfft < 4 * cmac) ? 1 : 2;
  684 -
  685      if (step == 2)
  686      {
  687          r = maxpart / minpart;
  688 @@ -131,7 +136,6 @@ int Convproc::configure (unsigned int ninp,
  689      else s = 1;
  690      nmin = (s == 1) ? 2 : 6;
  691      if (minpart == quantum) nmin++;
  692 -
  693      prio = 0;
  694      size = quantum;
  695      while (size < minpart)
  696 @@ -154,7 +158,6 @@ int Convproc::configure (unsigned int ninp,
  697  	    }
  698  	    _convlev [pind] = new Convlevel ();
  699  	    _convlev [pind]->configure (prio, offs, npar, size, _options);
  700 -
  701  	    offs += size * npar;
  702  	    if (offs < maxsize)
  703  	    {
  704 @@ -188,21 +191,22 @@ int Convproc::configure (unsigned int ninp,
  705  }
  706  
  707  
  708 -int Convproc::impdata_create (unsigned int inp,
  709 -                              unsigned int out,
  710 -                              unsigned int step,
  711 -                              float       *data,
  712 -                              int          ind0,
  713 -                              int          ind1)
  714 +int Convproc::impdata_create (uint32_t  inp,
  715 +                              uint32_t  out,
  716 +                              int32_t   step,
  717 +                              float     *data,
  718 +                              int32_t   ind0,
  719 +                              int32_t   ind1)
  720  {
  721 -    unsigned int j;
  722 +    uint32_t j;
  723  
  724      if (_state != ST_STOP) return Converror::BAD_STATE;
  725 +    if ((inp >= _ninp) || (out >= _nout)) return Converror::BAD_PARAM;
  726      try
  727      {
  728          for (j = 0; j < _nlevels; j++)
  729  	{
  730 -            _convlev [j]->impdata_create (inp, out, step, data, ind0, ind1);
  731 +            _convlev [j]->impdata_write (inp, out, step, data, ind0, ind1, true);
  732  	}
  733      }
  734      catch (...)
  735 @@ -214,37 +218,51 @@ int Convproc::impdata_create (unsigned int inp,
  736  }
  737  
  738  
  739 -int Convproc::impdata_update (unsigned int inp,
  740 -                              unsigned int out,
  741 -                              unsigned int step,
  742 -                              float       *data, 
  743 -                              int          ind0,
  744 -                              int          ind1)
  745 +int Convproc::impdata_clear (uint32_t inp, uint32_t out)
  746  {
  747 -    unsigned int j;
  748 +    uint32_t k;
  749  
  750      if (_state < ST_STOP) return Converror::BAD_STATE;
  751 +    for (k = 0; k < _nlevels; k++) _convlev [k]->impdata_clear (inp, out);
  752 +    return 0;
  753 +}
  754 +
  755 +
  756 +int Convproc::impdata_update (uint32_t  inp,
  757 +                              uint32_t  out,
  758 +                              int32_t   step,
  759 +                              float     *data, 
  760 +                              int32_t   ind0,
  761 +                              int32_t   ind1)
  762 +{
  763 +    uint32_t j;
  764 +
  765 +    if (_state < ST_STOP) return Converror::BAD_STATE;
  766 +    if ((inp >= _ninp) || (out >= _nout)) return Converror::BAD_PARAM;
  767      for (j = 0; j < _nlevels; j++)
  768      {
  769 -        _convlev [j]->impdata_update (inp, out, step, data, ind0, ind1);
  770 +        _convlev [j]->impdata_write (inp, out, step, data, ind0, ind1, false);
  771      }
  772      return 0;
  773  }
  774  
  775  
  776 -int Convproc::impdata_copy (unsigned int inp1,
  777 -                            unsigned int out1,
  778 -                            unsigned int inp2,
  779 -                            unsigned int out2) 
  780 +int Convproc::impdata_link (uint32_t inp1,
  781 +                            uint32_t out1,
  782 +                            uint32_t inp2,
  783 +                            uint32_t out2) 
  784  {
  785 -    unsigned int j;
  786 -
  787 +    uint32_t j;
  788 +    
  789 +    if ((inp1 >= _ninp) || (out1 >= _nout)) return Converror::BAD_PARAM;
  790 +    if ((inp2 >= _ninp) || (out2 >= _nout)) return Converror::BAD_PARAM;
  791 +    if ((inp1 == inp2) && (out1 == out2)) return Converror::BAD_PARAM;
  792      if (_state != ST_STOP) return Converror::BAD_STATE;
  793      try
  794      {
  795          for (j = 0; j < _nlevels; j++)
  796  	{
  797 -            _convlev [j]->impdata_copy (inp1, out1, inp2, out2);
  798 +            _convlev [j]->impdata_link (inp1, out1, inp2, out2);
  799  	}
  800      }
  801      catch (...)
  802 @@ -258,7 +276,7 @@ int Convproc::impdata_copy (unsigned int inp1,
  803  
  804  int Convproc::reset (void)
  805  {
  806 -    unsigned int k;
  807 +    uint32_t k;
  808  
  809      if (_state == ST_IDLE) return Converror::BAD_STATE;
  810      for (k = 0; k < _ninp; k++) memset (_inpbuff [k], 0, _inpsize * sizeof (float));
  811 @@ -270,17 +288,17 @@ int Convproc::reset (void)
  812  
  813  int Convproc::start_process (int abspri, int policy)
  814  {
  815 -    unsigned int k;
  816 +    uint32_t k;
  817  
  818      if (_state != ST_STOP) return Converror::BAD_STATE;
  819 -
  820      _latecnt = 0;
  821      _inpoffs = 0;
  822      _outoffs = 0;
  823      reset ();
  824 +
  825      for (k = (_minpart == _quantum) ? 1 : 0; k < _nlevels; k++)
  826      {
  827 -         _convlev [k]->start (abspri, policy);
  828 +        _convlev [k]->start (abspri, policy);
  829      }
  830      _state = ST_PROC;
  831      return 0;
  832 @@ -289,14 +307,12 @@ int Convproc::start_process (int abspri, int policy)
  833  
  834  int Convproc::process (bool sync)
  835  {
  836 -    unsigned int k;
  837 -    int f = 0;
  838 +    uint32_t  k;
  839 +    int       f = 0;
  840  
  841      if (_state != ST_PROC) return 0;
  842 -    
  843      _inpoffs += _quantum;
  844      if (_inpoffs == _inpsize) _inpoffs = 0;
  845 -
  846      _outoffs += _quantum;
  847      if (_outoffs == _minpart)
  848      {
  849 @@ -309,7 +325,7 @@ int Convproc::process (bool sync)
  850  	{
  851              if (++_latecnt >= 5)
  852              {
  853 -	        stop_process ();
  854 +	        if (~_options & OPT_LATE_CONTIN) stop_process ();
  855  	        f |= FL_LOAD;
  856  	    }
  857  	}
  858 @@ -321,7 +337,7 @@ int Convproc::process (bool sync)
  859  
  860  int Convproc::stop_process (void)
  861  {
  862 -    unsigned int k;
  863 +    uint32_t k;
  864  
  865      if (_state != ST_PROC) return Converror::BAD_STATE;
  866      for (k = 0; k < _nlevels; k++) _convlev [k]->stop ();
  867 @@ -332,17 +348,12 @@ int Convproc::stop_process (void)
  868  
  869  int Convproc::cleanup (void)
  870  {
  871 -    unsigned int k;
  872 +    uint32_t k;
  873  
  874      while (! check_stop ())
  875      {
  876          usleep (100000);
  877      }
  878 -    if (_state != ST_STOP)
  879 -    {
  880 -        return Converror::BAD_STATE;
  881 -    }
  882 -
  883      for (k = 0; k < _ninp; k++)
  884      {
  885          delete[] _inpbuff [k];
  886 @@ -362,7 +373,6 @@ int Convproc::cleanup (void)
  887      _state = ST_IDLE;
  888      _options = 0;
  889      _skipcnt = 0;
  890 -    _density = 0;
  891      _ninp = 0;
  892      _nout = 0;
  893      _quantum = 0;
  894 @@ -376,7 +386,7 @@ int Convproc::cleanup (void)
  895  
  896  bool Convproc::check_stop (void)
  897  {
  898 -    unsigned int k;
  899 +    uint32_t k;
  900  
  901      for (k = 0; (k < _nlevels) && (_convlev [k]->_stat == Convlevel::ST_IDLE); k++);
  902      if (k == _nlevels)
  903 @@ -390,7 +400,7 @@ bool Convproc::check_stop (void)
  904  
  905  void Convproc::print (FILE *F)
  906  {
  907 -    unsigned int k;
  908 +    uint32_t k;
  909  
  910      for (k = 0; k < _nlevels; k++) _convlev [k]->print (F);
  911  }
  912 @@ -424,21 +434,11 @@ Convlevel::~Convlevel (void)
  913  }
  914  
  915  
  916 -void *Convlevel::alloc_aligned (size_t size)
  917 -{
  918 -    void *p;
  919 -
  920 -    if (posix_memalign (&p, 16, size)) throw (Converror (Converror::MEM_ALLOC));
  921 -    memset (p, 0, size);
  922 -    return p;
  923 -}
  924 -
  925 -
  926 -void Convlevel::configure (int prio,
  927 -                           unsigned int offs,
  928 -                           unsigned int npar,
  929 -                           unsigned int parsize,
  930 -			   unsigned int options)
  931 +void Convlevel::configure (int       prio,
  932 +                           uint32_t  offs,
  933 +                           uint32_t  npar,
  934 +                           uint32_t  parsize,
  935 +			   uint32_t  options)
  936  {
  937      int fftwopt = (options & OPT_FFTW_MEASURE) ? FFTW_MEASURE : FFTW_ESTIMATE;
  938  
  939 @@ -448,9 +448,9 @@ void Convlevel::configure (int prio,
  940      _parsize = parsize;
  941      _options = options;
  942      
  943 -    _time_data = (float *)(alloc_aligned (2 * _parsize * sizeof (float)));
  944 -    _prep_data = (float *)(alloc_aligned (2 * _parsize * sizeof (float)));
  945 -    _freq_data = (fftwf_complex *)(alloc_aligned ((_parsize + 1) * sizeof (fftwf_complex)));
  946 +    _time_data = calloc_real (2 * _parsize);
  947 +    _prep_data = calloc_real (2 * _parsize);
  948 +    _freq_data = calloc_complex (_parsize + 1);
  949      _plan_r2c = fftwf_plan_dft_r2c_1d (2 * _parsize, _time_data, _freq_data, fftwopt);
  950      _plan_c2r = fftwf_plan_dft_c2r_1d (2 * _parsize, _freq_data, _time_data, fftwopt);
  951      if (_plan_r2c && _plan_c2r) return;
  952 @@ -458,42 +458,49 @@ void Convlevel::configure (int prio,
  953  }
  954  
  955  
  956 -void Convlevel::impdata_create (unsigned int inp,
  957 -                                unsigned int out,
  958 -                                unsigned int step,
  959 -                                float *data,
  960 -                                int i0,
  961 -                                int i1)
  962 +void Convlevel::impdata_write (uint32_t  inp,
  963 +                               uint32_t  out,
  964 +                               int32_t   step,
  965 +                               float     *data,
  966 +                               int32_t   i0,
  967 +                               int32_t   i1,
  968 +                               bool      create)
  969  {
  970 -    unsigned int   k;
  971 -    int            j, j0, j1, n;
  972 -    float          norm;
  973 -    fftwf_complex  *fftb;
  974 -    Macnode        *M;
  975 +    uint32_t        k;
  976 +    int32_t         j, j0, j1, n;
  977 +    float           norm;
  978 +    fftwf_complex   *fftb;
  979 +    Macnode         *M;
  980  
  981      n = i1 - i0;
  982      i0 = _offs - i0;
  983      i1 = i0 + _npar * _parsize;
  984      if ((i0 >= n) || (i1 <= 0)) return;
  985  
  986 -    M = findmacnode (inp, out, true);
  987 -    if (! (M->_fftb))
  988 +    if (create)
  989      {
  990 -	M->_fftb = new fftwf_complex * [_npar];
  991 -	memset (M->_fftb, 0, _npar * sizeof (fftwf_complex *));
  992 +        M = findmacnode (inp, out, true);
  993 +	if (M == 0 || M->_link) return;
  994 +	if (M->_fftb == 0) M->alloc_fftb (_npar);
  995      }
  996 -
  997 +    else
  998 +    {
  999 +        M = findmacnode (inp, out, false);
 1000 +	if (M == 0 || M->_link || M->_fftb == 0) return;
 1001 +    }
 1002 +    
 1003      norm = 0.5f / _parsize;
 1004      for (k = 0; k < _npar; k++)
 1005      {
 1006  	i1 = i0 + _parsize;
 1007  	if ((i0 < n) && (i1 > 0))
 1008  	{
 1009 -	    if (! (M->_fftb [k]))
 1010 -	    {
 1011 -		M->_fftb [k] = (fftwf_complex *)(alloc_aligned ((_parsize + 1) * sizeof (fftwf_complex)));
 1012 +	    fftb = M->_fftb [k];
 1013 +            if (fftb == 0 && create)
 1014 +            {
 1015 +		M->_fftb [k] = fftb = calloc_complex (_parsize + 1);
 1016  	    }
 1017 -	    if (data)
 1018 +	    if (fftb && data)
 1019  	    {
 1020  	        memset (_prep_data, 0, 2 * _parsize * sizeof (float));
 1021  	        j0 = (i0 < 0) ? 0 : i0;
 1022 @@ -503,7 +510,6 @@ void Convlevel::impdata_create (unsigned int inp,
 1023  #ifdef ENABLE_VECTOR_MODE
 1024  	        if (_options & OPT_VECTOR_MODE) fftswap (_freq_data);
 1025  #endif
 1026 -  	        fftb = M->_fftb [k];
 1027  	        for (j = 0; j <= (int)_parsize; j++)
 1028  	        {
 1029  	            fftb [j][0] += _freq_data [j][0];
 1030 @@ -516,52 +522,27 @@ void Convlevel::impdata_create (unsigned int inp,
 1031  }
 1032  
 1033  
 1034 -void Convlevel::impdata_update (unsigned int inp,
 1035 -                                unsigned int out,
 1036 -                                unsigned int step,
 1037 -                                float *data,
 1038 -                                int i0,
 1039 -                                int i1)
 1040 +void Convlevel::impdata_clear (uint32_t inp, uint32_t out)
 1041  {
 1042 -    unsigned int   k;
 1043 -    int            j, j0, j1, n;
 1044 -    float          norm;
 1045 -    fftwf_complex  *fftb;
 1046 -    Macnode        *M;
 1047 +    uint32_t  i;
 1048 +    Macnode   *M;
 1049  
 1050      M = findmacnode (inp, out, false);
 1051 -    if (! M) return;
 1052 -
 1053 -    n = i1 - i0;
 1054 -    i0 = _offs - i0;
 1055 -    i1 = i0 + _npar * _parsize;
 1056 -    if ((i0 >= n) || (i1 <= 0)) return;
 1057 -
 1058 -    norm = 0.5f / _parsize;
 1059 -    for (k = 0; k < _npar; k++)
 1060 +    if (M == 0 || M->_link || M->_fftb == 0) return;
 1061 +    for (i = 0; i < _npar; i++)
 1062      {
 1063 -	i1 = i0 + _parsize;
 1064 -	fftb = M->_fftb [k];
 1065 -	if (fftb && (i0 < n) && (i1 > 0))
 1066 -	{
 1067 -	    memset (_prep_data, 0, 2 * _parsize * sizeof (float));
 1068 -	    j0 = (i0 < 0) ? 0 : i0;
 1069 -	    j1 = (i1 > n) ? n : i1;
 1070 -	    for (j = j0; j < j1; j++) _prep_data [j - i0] = norm * data [j * step];
 1071 -	    fftwf_execute_dft_r2c (_plan_r2c, _prep_data, fftb);
 1072 -#ifdef ENABLE_VECTOR_MODE
 1073 -	    if (_options & OPT_VECTOR_MODE) fftswap (fftb);
 1074 -#endif
 1075 +        if (M->_fftb [i])
 1076 +        {
 1077 +  	    memset (M->_fftb [i], 0, (_parsize + 1) * sizeof (fftwf_complex));
 1078  	}
 1079 -	i0 = i1;
 1080      }
 1081  }
 1082  
 1083  
 1084 -void Convlevel::impdata_copy (unsigned int inp1,
 1085 -                              unsigned int out1,
 1086 -                              unsigned int inp2,
 1087 -                              unsigned int out2)
 1088 +void Convlevel::impdata_link (uint32_t inp1,
 1089 +                              uint32_t out1,
 1090 +                              uint32_t inp2,
 1091 +                              uint32_t out2)
 1092  {
 1093      Macnode  *M1;
 1094      Macnode  *M2;
 1095 @@ -569,18 +550,17 @@ void Convlevel::impdata_copy (unsigned int inp1,
 1096      M1 = findmacnode (inp1, out1, false);
 1097      if (! M1) return;
 1098      M2 = findmacnode (inp2, out2, true);
 1099 -    if (M2->_fftb) return;
 1100 -    M2->_fftb = M1->_fftb;
 1101 -    M2->_copy = true;
 1102 +    M2->free_fftb ();	
 1103 +    M2->_link = M1;
 1104  }
 1105  
 1106  
 1107 -void Convlevel::reset (unsigned int  inpsize,
 1108 -                       unsigned int  outsize,
 1109 +void Convlevel::reset (uint32_t  inpsize,
 1110 +                       uint32_t  outsize,
 1111  		       float         **inpbuff,
 1112  		       float         **outbuff)
 1113  {
 1114 -    unsigned int  i;
 1115 +    uint32_t     i;
 1116      Inpnode      *X; 
 1117      Outnode      *Y; 
 1118  
 1119 @@ -658,7 +638,6 @@ void Convlevel::stop (void)
 1120  
 1121  void Convlevel::cleanup (void)
 1122  {
 1123 -    unsigned int  i;
 1124      Inpnode       *X, *X1;
 1125      Outnode       *Y, *Y1;
 1126      Macnode       *M, *M1;
 1127 @@ -666,8 +645,6 @@ void Convlevel::cleanup (void)
 1128      X = _inp_list;
 1129      while (X)
 1130      {
 1131 -        for (i = 0; i < _npar; i++) free (X->_ffta [i]);
 1132 -	delete[] X->_ffta;
 1133  	X1 = X->_next;
 1134  	delete X;
 1135  	X = X1;
 1136 @@ -680,19 +657,10 @@ void Convlevel::cleanup (void)
 1137  	M = Y->_list;
 1138  	while (M)
 1139  	{
 1140 -	    if ((M->_fftb) && !(M->_copy))
 1141 -	    {
 1142 -	        for (i = 0; i < _npar; i++) 
 1143 -		{
 1144 -                    free (M->_fftb [i]);
 1145 -		}
 1146 -	        delete[] M->_fftb;
 1147 -	    }
 1148  	    M1 = M->_next;
 1149  	    delete M;
 1150  	    M = M1;
 1151  	}
 1152 -	for (i = 0; i < 3; i++) free (Y->_buff [i]);
 1153  	Y1 = Y->_next;
 1154  	delete Y;
 1155  	Y = Y1;
 1156 @@ -701,9 +669,9 @@ void Convlevel::cleanup (void)
 1157  
 1158      fftwf_destroy_plan (_plan_r2c);
 1159      fftwf_destroy_plan (_plan_c2r);
 1160 -    free (_time_data);
 1161 -    free (_prep_data);
 1162 -    free (_freq_data);
 1163 +    fftwf_free (_time_data);
 1164 +    fftwf_free (_prep_data);
 1165 +    fftwf_free (_freq_data);
 1166      _plan_r2c = 0;
 1167      _plan_c2r = 0;
 1168      _time_data = 0;
 1169 @@ -739,9 +707,7 @@ void Convlevel::main (void)
 1170  
 1171  void Convlevel::process (bool skip)
 1172  {
 1173 -    unsigned int    i, j, k;
 1174 -    unsigned int    i1, n1, n2, opi1, opi2;
 1175 -
 1176 +    uint32_t        i, i1, j, k, n1, n2, opi1, opi2;
 1177      Inpnode         *X;
 1178      Macnode         *M;
 1179      Outnode         *Y;
 1180 @@ -796,7 +762,7 @@ void Convlevel::process (bool skip)
 1181  		for (j = 0; j < _npar; j++)
 1182  		{
 1183  		    ffta = X->_ffta [i];
 1184 -		    fftb = M->_fftb [j];
 1185 +		    fftb = M->_link ? M->_link->_fftb [j] : M->_fftb [j];
 1186  		    if (fftb)
 1187  		    {
 1188  #ifdef ENABLE_VECTOR_MODE
 1189 @@ -847,11 +813,11 @@ void Convlevel::process (bool skip)
 1190  }
 1191  
 1192  
 1193 -int Convlevel::readout (bool sync, unsigned int skipcnt)
 1194 +int Convlevel::readout (bool sync, uint32_t skipcnt)
 1195  {
 1196 -    unsigned int  i;
 1197 -    float         *p, *q;	
 1198 -    Outnode       *Y;
 1199 +    uint32_t   i;
 1200 +    float      *p, *q;	
 1201 +    Outnode    *Y;
 1202  
 1203      _outoffs += _outsize;
 1204      if (_outoffs == _parsize)
 1205 @@ -893,58 +859,38 @@ void Convlevel::print (FILE *F)
 1206  }
 1207  
 1208  
 1209 -Macnode *Convlevel::findmacnode (unsigned int inp, unsigned int out, bool create)
 1210 +Macnode *Convlevel::findmacnode (uint32_t inp, uint32_t out, bool create)
 1211  {
 1212 -    unsigned int  i;
 1213 -    Inpnode       *X;
 1214 -    Outnode       *Y;
 1215 -    Macnode       *M;
 1216 +    Inpnode   *X;
 1217 +    Outnode   *Y;
 1218 +    Macnode   *M;
 1219  
 1220      for (X = _inp_list; X && (X->_inp != inp); X = X->_next);
 1221      if (! X)
 1222      {
 1223  	if (! create) return 0;
 1224 -	X = new Inpnode;
 1225 +	X = new Inpnode (inp);
 1226  	X->_next = _inp_list;
 1227  	_inp_list = X;
 1228 -	X->_inp = inp;
 1229 -	X->_ffta = new fftwf_complex * [_npar];
 1230 -	memset (X->_ffta, 0, _npar * sizeof (fftw_complex *));
 1231 -        for (i = 0; i < _npar; i++)
 1232 -	{
 1233 -            X->_ffta [i] = (fftwf_complex *)(alloc_aligned ((_parsize + 1) * sizeof (fftwf_complex)));
 1234 -	}
 1235 +	X->alloc_ffta (_npar, _parsize);
 1236      }
 1237  
 1238      for (Y = _out_list; Y && (Y->_out != out); Y = Y->_next);
 1239      if (! Y)
 1240      {
 1241  	if (! create) return 0;
 1242 -	Y = new Outnode;
 1243 +	Y = new Outnode (out, _parsize);
 1244  	Y->_next = _out_list;
 1245  	_out_list = Y;
 1246 -	Y->_out = out;
 1247 -	Y->_list = 0;
 1248 -        for (i = 0; i < 3; i++)
 1249 -	{
 1250 -	    Y->_buff [i] = 0;
 1251 -	}
 1252 -        for (i = 0; i < 3; i++)
 1253 -	{
 1254 -	    Y->_buff [i] = (float *)(alloc_aligned (_parsize * sizeof (float)));
 1255 -	}
 1256      }
 1257  
 1258      for (M = Y->_list; M && (M->_inpn != X); M = M->_next);
 1259      if (! M)
 1260      {
 1261  	if (! create) return 0;
 1262 -	M = new Macnode;
 1263 +	M = new Macnode (X);
 1264  	M->_next = Y->_list;
 1265  	Y->_list = M;
 1266 -	M->_inpn = X;
 1267 -	M->_fftb = 0;
 1268 -	M->_copy = false;
 1269      }
 1270  
 1271      return M;
 1272 @@ -955,8 +901,8 @@ Macnode *Convlevel::findmacnode (unsigned int inp, unsigned int out, bool create
 1273  
 1274  void Convlevel::fftswap (fftwf_complex *p)
 1275  {
 1276 -    unsigned int  n = _parsize;
 1277 -    float         a, b;
 1278 +    uint32_t  n = _parsize;
 1279 +    float     a, b;
 1280  
 1281      while (n)
 1282      {
 1283 @@ -974,3 +920,98 @@ void Convlevel::fftswap (fftwf_complex *p)
 1284  #endif
 1285  
 1286  
 1287 +Inpnode::Inpnode (uint16_t inp):
 1288 +    _next (0),
 1289 +    _ffta (0),	
 1290 +    _npar (0),
 1291 +    _inp (inp)
 1292 +{
 1293 +}
 1294 +    
 1295 +
 1296 +Inpnode::~Inpnode (void)
 1297 +{
 1298 +    free_ffta ();
 1299 +}
 1300 +    
 1301 +
 1302 +void Inpnode::alloc_ffta (uint16_t npar, int32_t size)
 1303 +{
 1304 +    _npar = npar;
 1305 +    _ffta = new fftwf_complex * [_npar];
 1306 +    for (int i = 0; i < _npar; i++)
 1307 +    {
 1308 +        _ffta [i] = calloc_complex (size + 1);
 1309 +    }
 1310 +}
 1311 +
 1312 +
 1313 +void Inpnode::free_ffta (void)
 1314 +{
 1315 +    if (!_ffta) return;
 1316 +    for (uint16_t i = 0; i < _npar; i++)
 1317 +    {
 1318 +        fftwf_free ( _ffta [i]);
 1319 +    }
 1320 +    delete[] _ffta;
 1321 +    _ffta = 0;
 1322 +    _npar = 0;
 1323 +}
 1324 +
 1325 +
 1326 +Macnode::Macnode (Inpnode *inpn):
 1327 +    _next (0),
 1328 +    _inpn (inpn),
 1329 +    _link (0),
 1330 +    _fftb (0),
 1331 +    _npar (0)
 1332 +{}
 1333 +
 1334 +
 1335 +Macnode::~Macnode (void)
 1336 +{
 1337 +    free_fftb ();
 1338 +}
 1339 +
 1340 +
 1341 +void Macnode::alloc_fftb (uint16_t npar)
 1342 +{
 1343 +    _npar = npar;
 1344 +    _fftb = new fftwf_complex * [_npar];
 1345 +    for (uint16_t i = 0; i < _npar; i++)
 1346 +    {
 1347 +        _fftb [i] = 0;
 1348 +    }
 1349 +}
 1350 +
 1351 +
 1352 +void Macnode::free_fftb (void)
 1353 +{
 1354 +    if (!_fftb) return;
 1355 +    for (uint16_t i = 0; i < _npar; i++)
 1356 +    {
 1357 +        fftwf_free ( _fftb [i]);
 1358 +    }
 1359 +    delete[] _fftb;
 1360 +    _fftb = 0;
 1361 +    _npar = 0;
 1362 +}
 1363 +
 1364 +
 1365 +Outnode::Outnode (uint16_t out, int32_t size):
 1366 +    _next (0),
 1367 +    _list (0),
 1368 +    _out (out)
 1369 +{
 1370 +    _buff [0] = calloc_real (size);
 1371 +    _buff [1] = calloc_real (size);
 1372 +    _buff [2] = calloc_real (size);
 1373 +}
 1374 +    
 1375 +
 1376 +Outnode::~Outnode (void)
 1377 +{
 1378 +    fftwf_free (_buff [0]);
 1379 +    fftwf_free (_buff [1]);
 1380 +    fftwf_free (_buff [2]);
 1381 +}
 1382 diff --git a/lib/zita-convolver-4.0.0/zita-convolver.h b/lib/zita-convolver-4.0.0/zita-convolver.h
 1383 new file mode 100644
 1384 index 0000000..0236bc0
 1385 --- /dev/null
 1386 +++ b/lib/zita-convolver-4.0.0/zita-convolver.h
 1387 @@ -0,0 +1,475 @@
 1388 +// ----------------------------------------------------------------------------
 1389 +//
 1390 +//  Copyright (C) 2006-2018 Fons Adriaensen <fons@linuxaudio.org>
 1391 +//    
 1392 +//  This program is free software; you can redistribute it and/or modify
 1393 +//  it under the terms of the GNU General Public License as published by
 1394 +//  the Free Software Foundation; either version 3 of the License, or
 1395 +//  (at your option) any later version.
 1396 +//
 1397 +//  This program is distributed in the hope that it will be useful,
 1398 +//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 1399 +//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 1400 +//  GNU General Public License for more details.
 1401 +//
 1402 +//  You should have received a copy of the GNU General Public License
 1403 +//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 1404 +//
 1405 +// ----------------------------------------------------------------------------
 1406 +
 1407 +
 1408 +#ifndef _ZITA_CONVOLVER_H
 1409 +#define _ZITA_CONVOLVER_H
 1410 +
 1411 +
 1412 +#include <pthread.h>
 1413 +#include <stdint.h>
 1414 +#include <fftw3.h>
 1415 +
 1416 +
 1417 +#define ZITA_CONVOLVER_MAJOR_VERSION 4
 1418 +#define ZITA_CONVOLVER_MINOR_VERSION 0
 1419 +
 1420 +
 1421 +extern int zita_convolver_major_version (void);
 1422 +extern int zita_convolver_minor_version (void);
 1423 +
 1424 +
 1425 +// ----------------------------------------------------------------------------
 1426 +
 1427 +
 1428 +#ifdef ZCSEMA_IS_IMPLEMENTED
 1429 +#undef ZCSEMA_IS_IMPLEMENTED
 1430 +#endif
 1431 +
 1432 +//XXX DZ: Hack for windows/osx10.5
 1433 +#include "zcsema-osx-win-compat.h"
 1434 +
 1435 +#if defined(__linux__)  || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 1436 +
 1437 +#include <semaphore.h>
 1438 +
 1439 +class ZCsema
 1440 +{
 1441 +public:
 1442 +
 1443 +    ZCsema (void) { init (0, 0); }
 1444 +    ~ZCsema (void) { sem_destroy (&_sema); }
 1445 +
 1446 +    ZCsema (const ZCsema&); // disabled
 1447 +    ZCsema& operator= (const ZCsema&); // disabled
 1448 +
 1449 +    int init (int s, int v) { return sem_init (&_sema, s, v); }
 1450 +    int post (void) { return sem_post (&_sema); }
 1451 +    int wait (void) { return sem_wait (&_sema); }
 1452 +    int trywait (void) { return sem_trywait (&_sema); }
 1453 +
 1454 +private:
 1455 +
 1456 +    sem_t  _sema;
 1457 +};
 1458 +
 1459 +#define ZCSEMA_IS_IMPLEMENTED
 1460 +#endif
 1461 +
 1462 +
 1463 +#ifdef __APPLE__
 1464 +
 1465 +// NOTE:  ***** I DO NOT REPEAT NOT PROVIDE SUPPORT FOR OSX *****
 1466 +// 
 1467 +// The following code partially emulates the POSIX sem_t for which
 1468 +// OSX has only a crippled implementation. It may or may not compile,
 1469 +// and if it compiles it may or may not work correctly. Blame APPLE
 1470 +// for not following POSIX standards.
 1471 +
 1472 +class ZCsema
 1473 +{
 1474 +public:
 1475 +
 1476 +    ZCsema (void) : _count (0)
 1477 +    {
 1478 +        init (0, 0);
 1479 +    }
 1480 +
 1481 +    ~ZCsema (void)
 1482 +    {
 1483 +        pthread_mutex_destroy (&_mutex);
 1484 +        pthread_cond_destroy (&_cond);
 1485 +    }
 1486 +
 1487 +    ZCsema (const ZCsema&); // disabled
 1488 +    ZCsema& operator= (const ZCsema&); // disabled
 1489 +
 1490 +    int init (int s, int v)
 1491 +    {
 1492 +	_count = v;
 1493 +        return pthread_mutex_init (&_mutex, 0) || pthread_cond_init (&_cond, 0);
 1494 +    }
 1495 +
 1496 +    int post (void)
 1497 +    {
 1498 +	pthread_mutex_lock (&_mutex);
 1499 +	_count++;
 1500 +	if (_count == 1) pthread_cond_signal (&_cond);
 1501 +	pthread_mutex_unlock (&_mutex);
 1502 +	return 0;
 1503 +    }
 1504 +
 1505 +    int wait (void)
 1506 +    {
 1507 +	pthread_mutex_lock (&_mutex);
 1508 +	while (_count < 1) pthread_cond_wait (&_cond, &_mutex);
 1509 +	_count--;
 1510 +	pthread_mutex_unlock (&_mutex);
 1511 +	return 0;
 1512 +    }
 1513 +
 1514 +    int trywait (void)
 1515 +    {
 1516 +	if (pthread_mutex_trylock (&_mutex)) return -1;
 1517 +	if (_count < 1)
 1518 +	{
 1519 +	    pthread_mutex_unlock (&_mutex);
 1520 +	    return -1;
 1521 +	}
 1522 +        _count--;
 1523 +        pthread_mutex_unlock (&_mutex);
 1524 +        return 0;
 1525 +    }
 1526 +
 1527 +private:
 1528 +
 1529 +    int              _count;
 1530 +    pthread_mutex_t  _mutex;
 1531 +    pthread_cond_t   _cond;
 1532 +};
 1533 +
 1534 +#define ZCSEMA_IS_IMPLEMENTED
 1535 +#endif
 1536 +
 1537 +
 1538 +#ifndef ZCSEMA_IS_IMPLEMENTED
 1539 +#error "The ZCsema class is not implemented."
 1540 +#endif
 1541 +
 1542 +
 1543 +// ----------------------------------------------------------------------------
 1544 +
 1545 +
 1546 +class Inpnode   
 1547 +{
 1548 +private:
 1549 +
 1550 +    friend class Convlevel;
 1551 +
 1552 +    Inpnode (uint16_t inp);
 1553 +    ~Inpnode (void);
 1554 +    void alloc_ffta (uint16_t npar, int32_t size);
 1555 +    void free_ffta (void);
 1556 +    
 1557 +    Inpnode        *_next;
 1558 +    fftwf_complex **_ffta;
 1559 +    uint16_t        _npar;
 1560 +    uint16_t        _inp;
 1561 +};
 1562 +
 1563 +
 1564 +class Macnode  
 1565 +{
 1566 +private:
 1567 +
 1568 +    friend class Convlevel;
 1569 +
 1570 +    Macnode (Inpnode *inpn);
 1571 +    ~Macnode (void);
 1572 +    void alloc_fftb (uint16_t npar);
 1573 +    void free_fftb (void);
 1574 +
 1575 +    Macnode        *_next;
 1576 +    Inpnode        *_inpn;
 1577 +    Macnode        *_link;
 1578 +    fftwf_complex **_fftb;
 1579 +    uint16_t        _npar;
 1580 +};
 1581 +
 1582 +
 1583 +class Outnode   
 1584 +{
 1585 +private:
 1586 +
 1587 +    friend class Convlevel;
 1588 +
 1589 +    Outnode (uint16_t out, int32_t size);
 1590 +    ~Outnode (void);
 1591 +    
 1592 +    Outnode        *_next;
 1593 +    Macnode        *_list;
 1594 +    float          *_buff [3];
 1595 +    uint16_t        _out;
 1596 +};
 1597 +
 1598 +
 1599 +class Converror
 1600 +{
 1601 +public:
 1602 +
 1603 +    enum
 1604 +    {
 1605 +	BAD_STATE = -1,
 1606 +	BAD_PARAM = -2,
 1607 +        MEM_ALLOC = -3
 1608 +    };
 1609 +
 1610 +    Converror (int error) : _error (error) {}
 1611 +
 1612 +private:
 1613 +
 1614 +    int _error;
 1615 +};
 1616 +
 1617 +
 1618 +class Convlevel
 1619 +{
 1620 +private:
 1621 +
 1622 +    friend class Convproc;
 1623 +
 1624 +    enum 
 1625 +    {
 1626 +        OPT_FFTW_MEASURE = 1,
 1627 +        OPT_VECTOR_MODE  = 2,
 1628 +        OPT_LATE_CONTIN  = 4
 1629 +    };
 1630 +
 1631 +    enum
 1632 +    {
 1633 +        ST_IDLE,
 1634 +        ST_TERM,
 1635 +        ST_PROC
 1636 +    };
 1637 +
 1638 +    Convlevel (void);
 1639 +    ~Convlevel (void);
 1640 +
 1641 +    void configure (int      prio,
 1642 +                    uint32_t offs,
 1643 +                    uint32_t npar,
 1644 +                    uint32_t parsize,
 1645 +		    uint32_t options);
 1646 +
 1647 +    void impdata_write (uint32_t  inp,
 1648 +                        uint32_t  out,
 1649 +                        int32_t   step,
 1650 +                        float     *data,
 1651 +                        int32_t   ind0,
 1652 +                        int32_t   ind1,
 1653 +                        bool      create);
 1654 +
 1655 +    void impdata_clear (uint32_t  inp,
 1656 +	                uint32_t  out);
 1657 +
 1658 +    void impdata_link (uint32_t  inp1,
 1659 +                       uint32_t  out1,
 1660 +                       uint32_t  inp2,
 1661 +                       uint32_t  out2);
 1662 +
 1663 +    void reset (uint32_t  inpsize,
 1664 +                uint32_t  outsize,
 1665 +	        float     **inpbuff,
 1666 +	        float     **outbuff);
 1667 +
 1668 +    void start (int absprio, int policy);
 1669 +
 1670 +    void process (bool sync);
 1671 +
 1672 +    int  readout (bool sync, uint32_t skipcnt);
 1673 +
 1674 +    void stop (void);
 1675 +
 1676 +    void cleanup (void);
 1677 +
 1678 +    void fftswap (fftwf_complex *p);
 1679 +
 1680 +    void print (FILE *F);
 1681 +
 1682 +    static void *static_main (void *arg);
 1683 +
 1684 +    void main (void);
 1685 +
 1686 +    Macnode *findmacnode (uint32_t inp, uint32_t out, bool create);
 1687 +
 1688 +
 1689 +    volatile uint32_t   _stat;           // current processing state
 1690 +    int                 _prio;           // relative priority
 1691 +    uint32_t            _offs;           // offset from start of impulse response
 1692 +    uint32_t            _npar;           // number of partitions
 1693 +    uint32_t            _parsize;        // partition and outbut buffer size
 1694 +    uint32_t            _outsize;        // step size for output buffer
 1695 +    uint32_t            _outoffs;        // offset into output buffer
 1696 +    uint32_t            _inpsize;        // size of shared input buffer 
 1697 +    uint32_t            _inpoffs;        // offset into input buffer
 1698 +    uint32_t            _options;        // various options
 1699 +    uint32_t            _ptind;          // rotating partition index
 1700 +    uint32_t            _opind;          // rotating output buffer index
 1701 +    int                 _bits;           // bit identifiying this level
 1702 +    int                 _wait;           // number of unfinished cycles
 1703 +    pthread_t           _pthr;           // posix thread executing this level
 1704 +    ZCsema              _trig;           // sema used to trigger a cycle
 1705 +    ZCsema              _done;           // sema used to wait for a cycle
 1706 +    Inpnode            *_inp_list;       // linked list of active inputs
 1707 +    Outnode            *_out_list;       // linked list of active outputs
 1708 +    fftwf_plan          _plan_r2c;       // FFTW plan, forward FFT
 1709 +    fftwf_plan          _plan_c2r;       // FFTW plan, inverse FFT
 1710 +    float              *_time_data;      // workspace
 1711 +    float              *_prep_data;      // workspace
 1712 +    fftwf_complex      *_freq_data;      // workspace
 1713 +    float             **_inpbuff;        // array of shared input buffers
 1714 +    float             **_outbuff;        // array of shared output buffers
 1715 +};
 1716 +
 1717 +
 1718 +// ----------------------------------------------------------------------------
 1719 +
 1720 +
 1721 +class Convproc
 1722 +{
 1723 +public:
 1724 +
 1725 +    Convproc (void);
 1726 +    ~Convproc (void);
 1727 +
 1728 +    enum
 1729 +    {
 1730 +        ST_IDLE,
 1731 +	ST_STOP,
 1732 +        ST_WAIT,
 1733 +        ST_PROC
 1734 +    };
 1735 +
 1736 +    enum
 1737 +    {
 1738 +        FL_LATE = 0x0000FFFF,
 1739 +	FL_LOAD = 0x01000000
 1740 +    };
 1741 +
 1742 +    enum 
 1743 +    {
 1744 +        OPT_FFTW_MEASURE = Convlevel::OPT_FFTW_MEASURE, 
 1745 +        OPT_VECTOR_MODE  = Convlevel::OPT_VECTOR_MODE,
 1746 +        OPT_LATE_CONTIN  = Convlevel::OPT_LATE_CONTIN
 1747 +    };
 1748 +
 1749 +    enum
 1750 +    {
 1751 +	MAXINP   = 64,
 1752 +	MAXOUT   = 64,
 1753 +	MAXLEV   = 8,
 1754 +	MINPART  = 64,
 1755 +	MAXPART  = 8192,
 1756 +	MAXDIVIS = 16,
 1757 +	MINQUANT = 16,
 1758 +	MAXQUANT = 8192
 1759 +    };
 1760 +
 1761 +    uint32_t state (void) const
 1762 +    {
 1763 +	return _state;
 1764 +    }
 1765 +
 1766 +    float *inpdata (uint32_t inp) const
 1767 +    {
 1768 +	return _inpbuff [inp] + _inpoffs;
 1769 +    }
 1770 +
 1771 +    float *outdata (uint32_t out) const
 1772 +    {
 1773 +	return _outbuff [out] + _outoffs;
 1774 +    }
 1775 +
 1776 +    int configure (uint32_t  ninp,
 1777 +                   uint32_t  nout,
 1778 +                   uint32_t  maxsize,
 1779 +                   uint32_t  quantum,
 1780 +                   uint32_t  minpart,
 1781 +                   uint32_t  maxpart,
 1782 +		   float     density);
 1783 +
 1784 +    int impdata_create (uint32_t  inp,
 1785 +                        uint32_t  out,
 1786 +                        int32_t   step,
 1787 +                        float     *data,
 1788 +                        int32_t   ind0,
 1789 +                        int32_t   ind1); 
 1790 +
 1791 +    int impdata_clear (uint32_t  inp,
 1792 +	               uint32_t  out);
 1793 +
 1794 +    int impdata_update (uint32_t  inp,
 1795 +                        uint32_t  out,
 1796 +                        int32_t   step,
 1797 +                        float     *data,
 1798 +                        int32_t   ind0,
 1799 +                        int32_t   ind1); 
 1800 +
 1801 +    int impdata_link (uint32_t  inp1,
 1802 +                      uint32_t  out1,
 1803 +                      uint32_t  inp2,
 1804 +                      uint32_t  out2);
 1805 +
 1806 +    // Deprecated, use impdata_link() instead.
 1807 +    int impdata_copy (uint32_t  inp1,
 1808 +                      uint32_t  out1,
 1809 +                      uint32_t  inp2,
 1810 +                      uint32_t  out2)
 1811 +    {
 1812 +	return impdata_link (inp1, out1, inp2, out2);
 1813 +    }
 1814 +    
 1815 +    void set_options (uint32_t options);
 1816 +
 1817 +    void set_skipcnt (uint32_t skipcnt);
 1818 +
 1819 +    int  reset (void);
 1820 +
 1821 +    int  start_process (int abspri, int policy);
 1822 +
 1823 +    int  process (bool sync = false);
 1824 +
 1825 +    int  stop_process (void);
 1826 +
 1827 +    bool check_stop (void);
 1828 +
 1829 +    int  cleanup (void);
 1830 +
 1831 +    void print (FILE *F = stdout);
 1832 +
 1833 +private:
 1834 +
 1835 +    uint32_t    _state;                   // current state
 1836 +    float      *_inpbuff [MAXINP];        // input buffers
 1837 +    float      *_outbuff [MAXOUT];        // output buffers
 1838 +    uint32_t    _inpoffs;                 // current offset in input buffers
 1839 +    uint32_t    _outoffs;                 // current offset in output buffers
 1840 +    uint32_t    _options;                 // option bits
 1841 +    uint32_t    _skipcnt;                 // number of frames to skip 
 1842 +    uint32_t    _ninp;                    // number of inputs
 1843 +    uint32_t    _nout;                    // number of outputs
 1844 +    uint32_t    _quantum;                 // processing block size
 1845 +    uint32_t    _minpart;                 // smallest partition size
 1846 +    uint32_t    _maxpart;                 // largest allowed partition size
 1847 +    uint32_t    _nlevels;                 // number of partition sizes
 1848 +    uint32_t    _inpsize;                 // size of input buffers
 1849 +    uint32_t    _latecnt;                 // count of cycles ending too late
 1850 +    Convlevel  *_convlev [MAXLEV];        // array of processors 
 1851 +    void       *_dummy [64];
 1852 +
 1853 +    static float  _mac_cost;
 1854 +    static float  _fft_cost;
 1855 +};
 1856 +
 1857 +
 1858 +// ----------------------------------------------------------------------------
 1859 +
 1860 +
 1861 +#endif
 1862 +
 1863 diff --git a/plugins/ZamHeadX2/Makefile b/plugins/ZamHeadX2/Makefile
 1864 index c838293..8500534 100644
 1865 --- a/plugins/ZamHeadX2/Makefile
 1866 +++ b/plugins/ZamHeadX2/Makefile
 1867 @@ -13,7 +13,7 @@ NAME = ZamHeadX2
 1868  # Files to build
 1869  
 1870  OBJS_DSP = \
 1871 -	../../lib/zita-convolver-3.1.0/zita-convolver.cpp.o \
 1872 +	../../lib/zita-convolver-4.0.0/zita-convolver.cpp.o \
 1873  	convolution.cpp.o \
 1874  	ZamHeadX2Plugin.cpp.o
 1875  
 1876 diff --git a/plugins/ZamHeadX2/convolution.cpp b/plugins/ZamHeadX2/convolution.cpp
 1877 index 81847e0..0026ba2 100644
 1878 --- a/plugins/ZamHeadX2/convolution.cpp
 1879 +++ b/plugins/ZamHeadX2/convolution.cpp
 1880 @@ -42,12 +42,12 @@
 1881  #include <pthread.h>
 1882  #include <assert.h>
 1883  
 1884 -#include "../../lib/zita-convolver-3.1.0/zita-convolver.h"
 1885 +#include "../../lib/zita-convolver-4.0.0/zita-convolver.h"
 1886  #include <samplerate.h>
 1887  #include "convolution.hpp"
 1888  
 1889 -#if ZITA_CONVOLVER_MAJOR_VERSION != 3
 1890 -# error "This programs requires zita-convolver 3.x.x"
 1891 +#if ZITA_CONVOLVER_MAJOR_VERSION != 4
 1892 +# error "This programs requires zita-convolver 4.x.x"
 1893  #endif
 1894  
 1895  #ifndef SRC_QUALITY
 1896 @@ -557,7 +557,6 @@ int LV2convolv::clv_initialize (
 1897  
 1898  	convproc = new Convproc();
 1899  	convproc->set_options (options);
 1900 -	convproc->set_density (density);
 1901  
 1902  	float fir_coeffs_lr[400] = { 0 };
 1903  	for (int i = 0; i < 200; i++) {
 1904 @@ -600,7 +599,8 @@ int LV2convolv::clv_initialize (
 1905  			/*max-convolution length */ max_size,
 1906  			/*quantum*/  buffersize,
 1907  			/*min-part*/ buffersize,
 1908 -			/*max-part*/ buffersize
 1909 +			/*max-part*/ buffersize,
 1910 +			density
 1911  			)) {
 1912  		fprintf (stderr, "convolution: Cannot initialize convolution engine.\n");
 1913  		goto errout;
 1914 diff --git a/plugins/ZamHeadX2/convolution.hpp b/plugins/ZamHeadX2/convolution.hpp
 1915 index ddf3d08..80be8e6 100644
 1916 --- a/plugins/ZamHeadX2/convolution.hpp
 1917 +++ b/plugins/ZamHeadX2/convolution.hpp
 1918 @@ -19,7 +19,7 @@
 1919  #ifndef CONVOLUTION_H_
 1920  #define CONVOLUTION_H_
 1921  
 1922 -#include "../../lib/zita-convolver-3.1.0/zita-convolver.h"
 1923 +#include "../../lib/zita-convolver-4.0.0/zita-convolver.h"
 1924  
 1925  #define MAX_CHANNEL_MAPS (4)
 1926  #define VERBOSE_printf(x, ...)
 1927 diff --git a/plugins/ZamVerb/Makefile b/plugins/ZamVerb/Makefile
 1928 index 82c3bab..eacc080 100644
 1929 --- a/plugins/ZamVerb/Makefile
 1930 +++ b/plugins/ZamVerb/Makefile
 1931 @@ -16,7 +16,7 @@ OBJS_DSP = \
 1932  	ZamVerbPlugin.cpp.o \
 1933  	ZamVerbImpulses.cpp.o \
 1934  	convolution.cpp.o \
 1935 -	../../lib/zita-convolver-3.1.0/zita-convolver.cpp.o
 1936 +	../../lib/zita-convolver-4.0.0/zita-convolver.cpp.o
 1937  
 1938  OBJS_UI  = \
 1939  	ZamVerbArtwork.cpp.o \
 1940 diff --git a/plugins/ZamVerb/convolution.cpp b/plugins/ZamVerb/convolution.cpp
 1941 index 517a3cb..27374e0 100644
 1942 --- a/plugins/ZamVerb/convolution.cpp
 1943 +++ b/plugins/ZamVerb/convolution.cpp
 1944 @@ -42,13 +42,13 @@
 1945  #include <pthread.h>
 1946  #include <assert.h>
 1947  
 1948 -#include "../../lib/zita-convolver-3.1.0/zita-convolver.h"
 1949 +#include "../../lib/zita-convolver-4.0.0/zita-convolver.h"
 1950  #include <samplerate.h>
 1951  #include "convolution.hpp"
 1952  #include "ZamVerbImpulses.hpp"
 1953  
 1954 -#if ZITA_CONVOLVER_MAJOR_VERSION != 3
 1955 -# error "This programs requires zita-convolver 3.x.x"
 1956 +#if ZITA_CONVOLVER_MAJOR_VERSION != 4
 1957 +# error "This programs requires zita-convolver 4.x.x"
 1958  #endif
 1959  
 1960  #ifndef SRC_QUALITY
 1961 @@ -295,7 +295,6 @@ int LV2convolv::clv_initialize (
 1962  
 1963  	convproc = new Convproc();
 1964  	convproc->set_options (options);
 1965 -	convproc->set_density (density);
 1966  /*
 1967  	if (audiofile_read (ir_fn, sample_rate, &p, &n_chan, &n_frames)) {
 1968  		fprintf(stderr, "convolution: failed to read IR.\n");
 1969 @@ -337,7 +336,8 @@ int LV2convolv::clv_initialize (
 1970  			/*max-convolution length */ max_size,
 1971  			/*quantum*/  buffersize,
 1972  			/*min-part*/ buffersize,
 1973 -			/*max-part*/ buffersize
 1974 +			/*max-part*/ buffersize,
 1975 +			density
 1976  			)) {
 1977  		fprintf (stderr, "convolution: Cannot initialize convolution engine.\n");
 1978  		goto errout;
 1979 diff --git a/plugins/ZamVerb/convolution.hpp b/plugins/ZamVerb/convolution.hpp
 1980 index 4eeada5..1c89971 100644
 1981 --- a/plugins/ZamVerb/convolution.hpp
 1982 +++ b/plugins/ZamVerb/convolution.hpp
 1983 @@ -19,7 +19,7 @@
 1984  #ifndef CONVOLUTION_H_
 1985  #define CONVOLUTION_H_
 1986  
 1987 -#include "../../lib/zita-convolver-3.1.0/zita-convolver.h"
 1988 +#include "../../lib/zita-convolver-4.0.0/zita-convolver.h"
 1989  
 1990  #define MAX_CHANNEL_MAPS (4)
 1991  #define VERBOSE_printf(x, ...)
 1992 -- 
 1993 2.18.0

Generated by cgit