diff options
author | Robin Gareus <robin@gareus.org> | 2017-09-16 15:34:11 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-09-16 18:31:54 +0200 |
commit | eb71eddbc81f868343764bcf6383d590b67600dd (patch) | |
tree | 91838664c5484fdff7b9b6acd1ee2844282d2465 /libs/zita-resampler/zita-resampler | |
parent | f53cec1d8fad264fdbc4ecd0e444715d2440c0b9 (diff) |
Add libzita-resampler as lib
This simplifies x-compiling and x-platform builds as well
allows to statically link, if needed.
Diffstat (limited to 'libs/zita-resampler/zita-resampler')
-rw-r--r-- | libs/zita-resampler/zita-resampler/cresampler.h | 66 | ||||
-rw-r--r-- | libs/zita-resampler/zita-resampler/resampler-table.h | 69 | ||||
-rw-r--r-- | libs/zita-resampler/zita-resampler/resampler.h | 78 | ||||
-rw-r--r-- | libs/zita-resampler/zita-resampler/vresampler.h | 84 | ||||
-rw-r--r-- | libs/zita-resampler/zita-resampler/zresampler_visibility.h | 32 |
5 files changed, 329 insertions, 0 deletions
diff --git a/libs/zita-resampler/zita-resampler/cresampler.h b/libs/zita-resampler/zita-resampler/cresampler.h new file mode 100644 index 0000000000..f5e2a96fb1 --- /dev/null +++ b/libs/zita-resampler/zita-resampler/cresampler.h @@ -0,0 +1,66 @@ +// ---------------------------------------------------------------------------- +// +// Copyright (C) 2013 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 3 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, see <http://www.gnu.org/licenses/>. +// +// ---------------------------------------------------------------------------- + + +#ifndef _ZITA_CRESAMPLER_H_ +#define _ZITA_CRESAMPLER_H_ + +#include "zita-resampler/zresampler_visibility.h" + +namespace ArdourZita { + +class LIBZRESAMPLER_API CResampler +{ +public: + CResampler (void); + ~CResampler (void); + + int setup (double ratio, unsigned int nchan); + + void clear (void); + int reset (void); + int nchan (void) const { return _nchan; } + int inpsize (void) const; + double inpdist (void) const; + int process (void); + + void set_ratio (double r); + void set_phase (double p); + + unsigned int inp_count; + unsigned int out_count; + float *inp_data; + float *out_data; + void *inp_list; + void *out_list; + +private: + unsigned int _nchan; + unsigned int _inmax; + unsigned int _index; + unsigned int _nread; + unsigned int _nzero; + double _phase; + double _pstep; + float *_buff; +}; + +}; + +#endif diff --git a/libs/zita-resampler/zita-resampler/resampler-table.h b/libs/zita-resampler/zita-resampler/resampler-table.h new file mode 100644 index 0000000000..6fcc0a37fa --- /dev/null +++ b/libs/zita-resampler/zita-resampler/resampler-table.h @@ -0,0 +1,69 @@ +// ---------------------------------------------------------------------------- +// +// Copyright (C) 2006-2012 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 3 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, see <http://www.gnu.org/licenses/>. +// +// ---------------------------------------------------------------------------- + + +#ifndef _ZITA_RESAMPLER_TABLE_H_ +#define _ZITA_RESAMPLER_TABLE_H_ + +#include <pthread.h> +#include "zita-resampler/zresampler_visibility.h" + +namespace ArdourZita { + +class LIBZRESAMPLER_API Resampler_mutex +{ +private: + + friend class Resampler_table; + + Resampler_mutex (void) { pthread_mutex_init (&_mutex, 0); } + ~Resampler_mutex (void) { pthread_mutex_destroy (&_mutex); } + void lock (void) { pthread_mutex_lock (&_mutex); } + void unlock (void) { pthread_mutex_unlock (&_mutex); } + + pthread_mutex_t _mutex; +}; + + +class LIBZRESAMPLER_API Resampler_table +{ +private: + Resampler_table (double fr, unsigned int hl, unsigned int np); + ~Resampler_table (void); + + friend class Resampler; + friend class VResampler; + + Resampler_table *_next; + unsigned int _refc; + float *_ctab; + double _fr; + unsigned int _hl; + unsigned int _np; + + static Resampler_table *create (double fr, unsigned int hl, unsigned int np); + static void destroy (Resampler_table *T); + + static Resampler_table *_list; + static Resampler_mutex _mutex; +}; + +}; + +#endif diff --git a/libs/zita-resampler/zita-resampler/resampler.h b/libs/zita-resampler/zita-resampler/resampler.h new file mode 100644 index 0000000000..713b98e36d --- /dev/null +++ b/libs/zita-resampler/zita-resampler/resampler.h @@ -0,0 +1,78 @@ +// ---------------------------------------------------------------------------- +// +// Copyright (C) 2006-2012 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 3 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, see <http://www.gnu.org/licenses/>. +// +// ---------------------------------------------------------------------------- + + +#ifndef _ZITA_RESAMPLER_H_ +#define _ZITA_RESAMPLER_H_ + +#include "zita-resampler/zresampler_visibility.h" +#include "zita-resampler/resampler-table.h" + +namespace ArdourZita { + +class LIBZRESAMPLER_API Resampler +{ + +public: + + Resampler (void); + ~Resampler (void); + + int setup (unsigned int fs_inp, + unsigned int fs_out, + unsigned int nchan, + unsigned int hlen); + + int setup (unsigned int fs_inp, + unsigned int fs_out, + unsigned int nchan, + unsigned int hlen, + double frel); + + void clear (void); + int reset (void); + int nchan (void) const { return _nchan; } + int inpsize (void) const; + double inpdist (void) const; + int process (void); + + unsigned int inp_count; + unsigned int out_count; + float *inp_data; + float *out_data; + void *inp_list; + void *out_list; + +private: + + Resampler_table *_table; + unsigned int _nchan; + unsigned int _inmax; + unsigned int _index; + unsigned int _nread; + unsigned int _nzero; + unsigned int _phase; + unsigned int _pstep; + float *_buff; + void *_dummy [8]; +}; + +}; + +#endif diff --git a/libs/zita-resampler/zita-resampler/vresampler.h b/libs/zita-resampler/zita-resampler/vresampler.h new file mode 100644 index 0000000000..056427dae0 --- /dev/null +++ b/libs/zita-resampler/zita-resampler/vresampler.h @@ -0,0 +1,84 @@ +// ---------------------------------------------------------------------------- +// +// Copyright (C) 2006-2012 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 3 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, see <http://www.gnu.org/licenses/>. +// +// ---------------------------------------------------------------------------- + + +#ifndef _ZITA_VRESAMPLER_H_ +#define _ZITA_VRESAMPLER_H_ + +#include "zita-resampler/zresampler_visibility.h" +#include "zita-resampler/resampler-table.h" + +namespace ArdourZita { + +class LIBZRESAMPLER_API VResampler +{ +public: + VResampler (void); + ~VResampler (void); + + int setup (double ratio, + unsigned int nchan, + unsigned int hlen); + + int setup (double ratio, + unsigned int nchan, + unsigned int hlen, + double frel); + + void clear (void); + int reset (void); + int nchan (void) const { return _nchan; } + int inpsize (void) const; + double inpdist (void) const; + int process (void); + + void set_phase (double p); + void set_rrfilt (double t); + void set_rratio (double r); + + unsigned int inp_count; + unsigned int out_count; + float *inp_data; + float *out_data; + void *inp_list; + void *out_list; + +private: + enum { NPHASE = 256 }; + + Resampler_table *_table; + unsigned int _nchan; + unsigned int _inmax; + unsigned int _index; + unsigned int _nread; + unsigned int _nzero; + double _ratio; + double _phase; + double _pstep; + double _qstep; + double _wstep; + float *_buff; + float *_c1; + float *_c2; + void *_dummy [8]; +}; + +}; + +#endif diff --git a/libs/zita-resampler/zita-resampler/zresampler_visibility.h b/libs/zita-resampler/zita-resampler/zresampler_visibility.h new file mode 100644 index 0000000000..6ebfee9a9e --- /dev/null +++ b/libs/zita-resampler/zita-resampler/zresampler_visibility.h @@ -0,0 +1,32 @@ +#ifndef __libzreampler_visibility_h__ +#define __libzreampler_visibility_h__ + +#if defined(COMPILER_MSVC) + #define LIBZRESAMPLER_DLL_IMPORT __declspec(dllimport) + #define LIBZRESAMPLER_DLL_EXPORT __declspec(dllexport) + #define LIBZRESAMPLER_DLL_LOCAL +#else + #define LIBZRESAMPLER_DLL_IMPORT __attribute__ ((visibility ("default"))) + #define LIBZRESAMPLER_DLL_EXPORT __attribute__ ((visibility ("default"))) + #define LIBZRESAMPLER_DLL_LOCAL __attribute__ ((visibility ("hidden"))) +#endif + +#ifdef LIBZRESAMPLER_STATIC // libzita-reampler is a DLL + #define LIBZRESAMPLER_API + #define LIBZRESAMPLER_LOCAL + #define LIBZRESAMPLER_TEMPLATE_API + #define LIBZRESAMPLER_TEMPLATE_MEMBER_API +#else + #ifdef LIBZRESAMPLER_DLL_EXPORTS // defined if we are building the libzita-resampler DLL (instead of using it) + #define LIBZRESAMPLER_API LIBZRESAMPLER_DLL_EXPORT + #define LIBZRESAMPLER_TEMPLATE_API LIBZRESAMPLER_TEMPLATE_DLL_EXPORT + #define LIBZRESAMPLER_TEMPLATE_MEMBER_API LIBZRESAMPLER_TEMPLATE_MEMBER_DLL_EXPORT + #else + #define LIBZRESAMPLER_API LIBZRESAMPLER_DLL_IMPORT + #define LIBZRESAMPLER_TEMPLATE_API LIBZRESAMPLER_TEMPLATE_DLL_IMPORT + #define LIBZRESAMPLER_TEMPLATE_MEMBER_API LIBZRESAMPLER_TEMPLATE_MEMBER_DLL_IMPORT + #endif + #define LIBZRESAMPLER_LOCAL LIBZRESAMPLER_DLL_LOCAL +#endif + +#endif |