[SCM] calf/master: Add patches cherry-picked upstream to fix GCC 6 compilation (replacing patch 3001).
js at users.alioth.debian.org
js at users.alioth.debian.org
Mon Jul 31 03:19:43 UTC 2017
The following commit has been merged in the master branch:
commit 88fa0517d232cd09da2a27639848af0b3f87025c
Author: Jonas Smedegaard <dr at jones.dk>
Date: Sun Jul 30 18:00:14 2017 -0400
Add patches cherry-picked upstream to fix GCC 6 compilation (replacing patch 3001).
diff --git a/debian/patches/3001_gcc6_transition_fixes.patch b/debian/patches/020160718~784c842.patch
similarity index 51%
rename from debian/patches/3001_gcc6_transition_fixes.patch
rename to debian/patches/020160718~784c842.patch
index 9748f10..26a3604 100644
--- a/debian/patches/3001_gcc6_transition_fixes.patch
+++ b/debian/patches/020160718~784c842.patch
@@ -1,70 +1,68 @@
-Description: Fix compilation errors when using GCC 6.
- .
-Author: Johannes Brandstätter <jbrandst at 2ds.eu>
-Bug-Debian: https://bugs.debian.org/811883
-Last-Update: <2016-09-24>
+Description: Fix some type errors
+Origin: upstream, https://github.com/calf-studio-gear/calf/commit/784c842
+Bug: https://github.com/calf-studio-gear/calf/issues/82
+Author: cisoun <cysoun at gmail.com>
+Forwarded: yes
+Last-Update: 2017-07-30
---- calf-0.0.60.orig/src/analyzer.cpp
-+++ calf-0.0.60/src/analyzer.cpp
-@@ -470,13 +470,13 @@ void analyzer::draw(int subindex, float
- lastoutL = fft_outL[_iter];
+--- a/src/analyzer.cpp
++++ b/src/analyzer.cpp
+@@ -471,12 +471,12 @@
//pumping up actual signal an erase surrounding
// sounds
-- fft_outL[_iter] = 0.25f * std::max(n * 0.6f * \
+ fft_outL[_iter] = 0.25f * std::max(n * 0.6f * \
- fabs(fft_outL[_iter]) - var1L , 1e-20);
-+ fft_outL[_iter] = 0.25f * std::max(static_cast<double>(
-+ n * 0.6f * fabs(fft_outL[_iter]) - var1L) , 1e-20);
++ fabs(fft_outL[_iter]) - var1L , 1e-20f);
if(_mode == 3 or _mode == 4) {
// do the same with R channel if needed
lastoutR = fft_outR[_iter];
-- fft_outR[_iter] = 0.25f * std::max(n * \
+ fft_outR[_iter] = 0.25f * std::max(n * \
- 0.6f * fabs(fft_outR[_iter]) - var1R , 1e-20);
-+ fft_outR[_iter] = 0.25f * std::max(static_cast<double>(
-+ n * 0.6f * fabs(fft_outR[_iter]) - var1R) , 1e-20);
++ 0.6f * fabs(fft_outR[_iter]) - var1R , 1e-20f);
}
break;
}
---- calf-0.0.60.orig/src/jack_client.cpp
-+++ calf-0.0.60/src/jack_client.cpp
-@@ -226,7 +226,7 @@ void jack_client::calculate_plugin_order
+--- a/src/jack_client.cpp
++++ b/src/jack_client.cpp
+@@ -226,7 +226,7 @@
map<string, int>::const_iterator p = port_to_plugin.find((*k) + cnlen + 1);
if (p != port_to_plugin.end())
{
- run_before.insert(make_pair<int, int>(p->second, i));
-+ run_before.insert(make_pair(p->second, i));
++ run_before.insert(make_pair<const int&, unsigned int&>(p->second, i));
}
}
jack_free(conns);
---- calf-0.0.60.orig/src/modules_dist.cpp
-+++ calf-0.0.60/src/modules_dist.cpp
-@@ -794,8 +794,8 @@ uint32_t tapesimulator_audio_module::pro
+--- a/src/modules_dist.cpp
++++ b/src/modules_dist.cpp
+@@ -794,8 +794,8 @@
lfo2.advance(1);
// dot
- rms = std::max((double)rms, (fabs(Lo) + fabs(Ro)) / 2);
- input = std::max((double)input, (fabs(Lc) + fabs(Rc)) / 2);
-+ rms = std::max(rms, (fabs(Lo) + fabs(Ro)) / 2);
-+ input = std::max(input, (fabs(Lc) + fabs(Rc)) / 2);
++ rms = std::max((double)rms, (double)((fabs(Lo) + fabs(Ro)) / 2));
++ input = std::max((double)input, (double)((fabs(Lc) + fabs(Rc)) / 2));
float values[] = {inL, inR, outs[0][i], outs[1][i]};
meters.process(values);
---- calf-0.0.60.orig/src/modules_limit.cpp
-+++ calf-0.0.60/src/modules_limit.cpp
-@@ -429,7 +429,7 @@ uint32_t multibandlimiter_audio_module::
+--- a/src/modules_limit.cpp
++++ b/src/modules_limit.cpp
+@@ -429,7 +429,7 @@
}
// write multiband coefficient to buffer
- buffer[pos] = std::min(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR)), 1.0);
-+ buffer[pos] = std::min(static_cast<double>(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR))), 1.0);
++ buffer[pos] = std::min(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR)), 1.0f);
// step forward in multiband buffer
pos = (pos + channels) % buffer_size;
-@@ -811,7 +811,7 @@ uint32_t sidechainlimiter_audio_module::
+@@ -811,7 +811,7 @@
}
// write multiband coefficient to buffer
- buffer[pos] = std::min(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR)), 1.0);
-+ buffer[pos] = std::min(static_cast<double>(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR))), 1.0);
++ buffer[pos] = std::min(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR)), 1.0f);
// step forward in multiband buffer
pos = (pos + channels) % buffer_size;
diff --git a/debian/patches/020161210~f392c59.patch b/debian/patches/020161210~f392c59.patch
new file mode 100644
index 0000000..d6c3cfc
--- /dev/null
+++ b/debian/patches/020161210~f392c59.patch
@@ -0,0 +1,2153 @@
+Description: Fix type errors causing gcc5/gcc6 build failure
+ Fix some type errors which prevented either gcc5 or gcc6 from building.
+ Fix some warnings.
+Origin: upstream, https://github.com/calf-studio-gear/calf/commit/f392c59
+Author: Markus Schmidt <schmidt at boomshop.net>
+Forwarded: yes
+Last-Update: 2017-07-30
+
+--- a/src/analyzer.cpp
++++ b/src/analyzer.cpp
+@@ -470,13 +470,13 @@
+ lastoutL = fft_outL[_iter];
+ //pumping up actual signal an erase surrounding
+ // sounds
+- fft_outL[_iter] = 0.25f * std::max(n * 0.6f * \
+- fabs(fft_outL[_iter]) - var1L , 1e-20f);
++ fft_outL[_iter] = 0.25f * std::max((float)(n * 0.6f * \
++ fabs(fft_outL[_iter]) - var1L), 1e-20f);
+ if(_mode == 3 or _mode == 4) {
+ // do the same with R channel if needed
+ lastoutR = fft_outR[_iter];
+- fft_outR[_iter] = 0.25f * std::max(n * \
+- 0.6f * fabs(fft_outR[_iter]) - var1R , 1e-20f);
++ fft_outR[_iter] = 0.25f * std::max((float)(n * \
++ 0.6f * fabs(fft_outR[_iter]) - var1R), 1e-20f);
+ }
+ break;
+ }
+--- a/src/calf/orfanidis_eq.h
++++ b/src/calf/orfanidis_eq.h
+@@ -16,10 +16,10 @@
+
+ //Eq types
+ typedef enum {
+- none,
+- butterworth,
+- chebyshev1,
+- chebyshev2
++ none,
++ butterworth,
++ chebyshev1,
++ chebyshev2
+ } filter_type;
+
+ static const char *get_eq_text(filter_type type) {
+@@ -39,9 +39,9 @@
+
+ //Eq errors
+ typedef enum {
+- no_error,
+- invalid_input_data_error,
+- processing_error
++ no_error,
++ invalid_input_data_error,
++ processing_error
+ } eq_error_t;
+
+ //Constants
+@@ -79,255 +79,255 @@
+ //------------ Conversion functions class ------------
+ class conversions
+ {
+- int db_min_max;
+- std::vector<eq_double_t> lin_gains;
++ int db_min_max;
++ std::vector<eq_double_t> lin_gains;
+
+- int lin_gains_index(eq_double_t x) {
+- int int_x = (int)x;
+- if((x >= -db_min_max) && (x < db_min_max - 1))
+- return db_min_max + int_x;
+-
+- return db_min_max;
+- }
++ int lin_gains_index(eq_double_t x) {
++ int int_x = (int)x;
++ if((x >= -db_min_max) && (x < db_min_max - 1))
++ return db_min_max + int_x;
++
++ return db_min_max;
++ }
+
+- conversions(){}
++ conversions(){}
+
+ public:
+- conversions(int min_max) {
+- db_min_max = min_max;
+- //Update table (vector elements) for fast conversions
+- int step = -min_max;
+- while(step <= min_max)
+- lin_gains.push_back(db_2_lin(step++));
+- }
+-
+- inline eq_double_t fast_db_2_lin(eq_double_t x) {
+- int int_part = (int)x;
+- eq_double_t frac_part = x - int_part;
+- return lin_gains[lin_gains_index(int_part)]*(1-frac_part) +
+- (lin_gains[lin_gains_index(int_part + 1)])*frac_part;
+- }
+-
+- inline eq_double_t fast_lin_2_db(eq_double_t x) {
+- if((x >= lin_gains[0]) && (x < lin_gains[lin_gains.size() - 1])) {
+- for (unsigned int i = 0; i < lin_gains.size() - 2; i++)
+- if((x >= lin_gains[i]) && (x < lin_gains[i + 1])) {
+- int int_part = i - db_min_max;
+- eq_double_t frac_part = x - (int)(x);
+- return int_part + frac_part;
+- }
+- }
+- return 0;
+- }
+-
+- inline static eq_double_t db_2_lin(eq_double_t x) {
+- return pow(10, x/20);
+- }
+-
+- inline static eq_double_t lin_2_db(eq_double_t x) {
+- return 20*log10(x);
+- }
+-
+- inline static eq_double_t rad_2_hz(eq_double_t x, eq_double_t fs) {
+- return 2*pi/x*fs;
+- }
+-
+- inline static eq_double_t hz_2_rad(eq_double_t x, eq_double_t fs) {
+- return 2*pi*x/fs;
+- }
++ conversions(int min_max) {
++ db_min_max = min_max;
++ //Update table (vector elements) for fast conversions
++ int step = -min_max;
++ while(step <= min_max)
++ lin_gains.push_back(db_2_lin(step++));
++ }
++
++ inline eq_double_t fast_db_2_lin(eq_double_t x) {
++ int int_part = (int)x;
++ eq_double_t frac_part = x - int_part;
++ return lin_gains[lin_gains_index(int_part)]*(1-frac_part) +
++ (lin_gains[lin_gains_index(int_part + 1)])*frac_part;
++ }
++
++ inline eq_double_t fast_lin_2_db(eq_double_t x) {
++ if((x >= lin_gains[0]) && (x < lin_gains[lin_gains.size() - 1])) {
++ for (unsigned int i = 0; i < lin_gains.size() - 2; i++)
++ if((x >= lin_gains[i]) && (x < lin_gains[i + 1])) {
++ int int_part = i - db_min_max;
++ eq_double_t frac_part = x - (int)(x);
++ return int_part + frac_part;
++ }
++ }
++ return 0;
++ }
++
++ inline static eq_double_t db_2_lin(eq_double_t x) {
++ return pow(10, x/20);
++ }
++
++ inline static eq_double_t lin_2_db(eq_double_t x) {
++ return 20*log10(x);
++ }
++
++ inline static eq_double_t rad_2_hz(eq_double_t x, eq_double_t fs) {
++ return 2*pi/x*fs;
++ }
++
++ inline static eq_double_t hz_2_rad(eq_double_t x, eq_double_t fs) {
++ return 2*pi*x/fs;
++ }
+ };
+
+ //------------ Band freq's structure ------------
+ struct band_freqs {
+ private:
+- band_freqs();
++ band_freqs();
+
+ public:
+- eq_double_t min_freq;
+- eq_double_t center_freq;
+- eq_double_t max_freq;
++ eq_double_t min_freq;
++ eq_double_t center_freq;
++ eq_double_t max_freq;
+
+- band_freqs(eq_double_t f1, eq_double_t f0, eq_double_t f2):
+- min_freq(f1), center_freq(f0), max_freq(f2){}
++ band_freqs(eq_double_t f1, eq_double_t f0, eq_double_t f2):
++ min_freq(f1), center_freq(f0), max_freq(f2){}
+
+- ~band_freqs(){}
++ ~band_freqs(){}
+ };
+
+ //------------ Frequency grid class ------------
+ class freq_grid {
+ private:
+- std::vector<band_freqs> freqs_;
++ std::vector<band_freqs> freqs_;
+
+ public:
+- freq_grid(){}
+- freq_grid(const freq_grid& fg){this->freqs_ = fg.freqs_;}
+- ~freq_grid(){}
+-
+- eq_error_t set_band(eq_double_t fmin, eq_double_t f0, eq_double_t fmax) {
+- freqs_.clear();
+- return add_band(fmin, f0, fmax);
+- }
+-
+- //fc, fmin, fmax
+- eq_error_t add_band(eq_double_t fmin, eq_double_t f0, eq_double_t fmax) {
+- if(fmin < f0 && f0 < fmax)
+- freqs_.push_back(band_freqs(fmin, f0, fmax));
+- else
+- return invalid_input_data_error;
+- return no_error;
+- }
+-
+- //f0, deltaf = fmax - fmin
+- eq_error_t add_band(eq_double_t f0, eq_double_t df) {
+- if(f0 >= df/2)
+- {
+- eq_double_t fmin = f0 - df/2;
+- eq_double_t fmax = f0 + df/2;
+- freqs_.push_back(band_freqs(fmin, f0, fmax));
+- }
+- else
+- return invalid_input_data_error;
+- return no_error;
+- }
+-
+- eq_error_t set_5_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
+- freqs_.clear();
+- if(lowest_audio_freq_hz < center_freq &&
+- center_freq < highest_audio_freq_hz) {
+-
+- //Find lowest center frequency in band
+- eq_double_t lowest_center_freq = center_freq;
+- while(lowest_center_freq > lowest_grid_center_freq_hz)
+- lowest_center_freq/=4.0;
+- if(lowest_center_freq < lowest_grid_center_freq_hz)
+- lowest_center_freq*=4.0;
+-
+- //Calculate freq's
+- eq_double_t f0 = lowest_center_freq;
+- for(unsigned int i = 0; i < 5 ; i++) {
+- freqs_.push_back(band_freqs(f0/2, f0, f0*2));
+- f0 *= 4;
+- }
+- }
+- else
+- return invalid_input_data_error;
+- return no_error;
+- }
+-
+- eq_error_t set_10_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
+- freqs_.clear();
+- if(lowest_audio_freq_hz < center_freq &&
+- center_freq < highest_audio_freq_hz) {
+-
+- //Find lowest center frequency in band
+- eq_double_t lowest_center_freq = center_freq;
+- while(lowest_center_freq > lowest_grid_center_freq_hz)
+- lowest_center_freq/=2;
+- if(lowest_center_freq < lowest_grid_center_freq_hz)
+- lowest_center_freq*=2;
+-
+- //Calculate freq's
+- eq_double_t f0 = lowest_center_freq;
+- for(unsigned int i = 0; i < 10; i++) {
+- freqs_.push_back(band_freqs(f0/pow(2,0.5), f0, f0*pow(2,0.5)));
+- f0 *= 2;
+- }
+- }
+- else
+- return invalid_input_data_error;
+- return no_error;
+- }
+-
+- eq_error_t set_20_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
+- freqs_.clear();
+- if(lowest_audio_freq_hz < center_freq &&
+- center_freq < highest_audio_freq_hz) {
+-
+- //Find lowest center frequency in band
+- eq_double_t lowest_center_freq = center_freq;
+- while(lowest_center_freq > lowest_audio_freq_hz)
+- lowest_center_freq/=pow(2,0.5);
+- if(lowest_center_freq < lowest_audio_freq_hz)
+- lowest_center_freq*=pow(2,0.5);
+-
+- //Calculate freq's
+- eq_double_t f0 = lowest_center_freq;
+- for(unsigned int i = 0; i < 20; i++) {
+- freqs_.push_back(band_freqs(f0/pow(2,0.25),
+- f0, f0*pow(2,0.25)));
+- f0 *= pow(2,0.5);
+- }
+- }
+- else
+- return invalid_input_data_error;
+- return no_error;
+- }
+-
+- eq_error_t set_30_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
+- freqs_.clear();
+- if(lowest_audio_freq_hz < center_freq &&
+- center_freq < highest_audio_freq_hz) {
+-
+- //Find lowest center frequency in band
+- eq_double_t lowest_center_freq = center_freq;
+- while(lowest_center_freq > lowest_audio_freq_hz)
+- lowest_center_freq/=pow(2.0,1.0/3.0);
+- if(lowest_center_freq < lowest_audio_freq_hz)
+- lowest_center_freq*=pow(2.0,1.0/3.0);
+-
+- //Calculate freq's
+- eq_double_t f0 = lowest_center_freq;
+- for(unsigned int i = 0; i < 30; i++) {
+- freqs_.push_back(band_freqs(f0/pow(2.0,1.0/6.0),
+- f0, f0*pow(2.0,1.0/6.0)));
+- f0 *= pow(2,1.0/3.0);
+- }
+- }
+- else
+- return invalid_input_data_error;
+- return no_error;
+- }
+-
+- unsigned int get_number_of_bands(){return freqs_.size();}
+-
+- std::vector<band_freqs> get_freqs(){return freqs_;}
+-
+- unsigned int get_freq(unsigned int number) {
+- if(number < freqs_.size())
+- return freqs_[number].center_freq;
+- else
+- return 0;
+- }
+-
+- unsigned int get_rounded_freq(unsigned int number) {
+- if(number < freqs_.size()) {
+- unsigned int freq = freqs_[number].center_freq;
+- if (freq < 100)
+- return freq;
+- else if(freq >= 100 && freq < 1000) {
+- unsigned int rest = freq%10;
+- if(rest < 5)
+- return freq - rest;
+- else
+- return freq - rest + 10;
+- }
+- else if(freq >= 1000 && freq < 10000) {
+- unsigned int rest = freq%100;
+- if(rest < 50)
+- return freq - rest;
+- else
+- return freq - rest + 100;
+- }
+- else if(freq >= 10000) {
+- unsigned int rest = freq%1000;
+- if(rest < 500)
+- return freq - rest;
+- else
+- return freq - rest + 1000;
+- }
+- }
+- return 0;
+- }
++ freq_grid(){}
++ freq_grid(const freq_grid& fg){this->freqs_ = fg.freqs_;}
++ ~freq_grid(){}
++
++ eq_error_t set_band(eq_double_t fmin, eq_double_t f0, eq_double_t fmax) {
++ freqs_.clear();
++ return add_band(fmin, f0, fmax);
++ }
++
++ //fc, fmin, fmax
++ eq_error_t add_band(eq_double_t fmin, eq_double_t f0, eq_double_t fmax) {
++ if(fmin < f0 && f0 < fmax)
++ freqs_.push_back(band_freqs(fmin, f0, fmax));
++ else
++ return invalid_input_data_error;
++ return no_error;
++ }
++
++ //f0, deltaf = fmax - fmin
++ eq_error_t add_band(eq_double_t f0, eq_double_t df) {
++ if(f0 >= df/2)
++ {
++ eq_double_t fmin = f0 - df/2;
++ eq_double_t fmax = f0 + df/2;
++ freqs_.push_back(band_freqs(fmin, f0, fmax));
++ }
++ else
++ return invalid_input_data_error;
++ return no_error;
++ }
++
++ eq_error_t set_5_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
++ freqs_.clear();
++ if(lowest_audio_freq_hz < center_freq &&
++ center_freq < highest_audio_freq_hz) {
++
++ //Find lowest center frequency in band
++ eq_double_t lowest_center_freq = center_freq;
++ while(lowest_center_freq > lowest_grid_center_freq_hz)
++ lowest_center_freq/=4.0;
++ if(lowest_center_freq < lowest_grid_center_freq_hz)
++ lowest_center_freq*=4.0;
++
++ //Calculate freq's
++ eq_double_t f0 = lowest_center_freq;
++ for(unsigned int i = 0; i < 5 ; i++) {
++ freqs_.push_back(band_freqs(f0/2, f0, f0*2));
++ f0 *= 4;
++ }
++ }
++ else
++ return invalid_input_data_error;
++ return no_error;
++ }
++
++ eq_error_t set_10_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
++ freqs_.clear();
++ if(lowest_audio_freq_hz < center_freq &&
++ center_freq < highest_audio_freq_hz) {
++
++ //Find lowest center frequency in band
++ eq_double_t lowest_center_freq = center_freq;
++ while(lowest_center_freq > lowest_grid_center_freq_hz)
++ lowest_center_freq/=2;
++ if(lowest_center_freq < lowest_grid_center_freq_hz)
++ lowest_center_freq*=2;
++
++ //Calculate freq's
++ eq_double_t f0 = lowest_center_freq;
++ for(unsigned int i = 0; i < 10; i++) {
++ freqs_.push_back(band_freqs(f0/pow(2,0.5), f0, f0*pow(2,0.5)));
++ f0 *= 2;
++ }
++ }
++ else
++ return invalid_input_data_error;
++ return no_error;
++ }
++
++ eq_error_t set_20_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
++ freqs_.clear();
++ if(lowest_audio_freq_hz < center_freq &&
++ center_freq < highest_audio_freq_hz) {
++
++ //Find lowest center frequency in band
++ eq_double_t lowest_center_freq = center_freq;
++ while(lowest_center_freq > lowest_audio_freq_hz)
++ lowest_center_freq/=pow(2,0.5);
++ if(lowest_center_freq < lowest_audio_freq_hz)
++ lowest_center_freq*=pow(2,0.5);
++
++ //Calculate freq's
++ eq_double_t f0 = lowest_center_freq;
++ for(unsigned int i = 0; i < 20; i++) {
++ freqs_.push_back(band_freqs(f0/pow(2,0.25),
++ f0, f0*pow(2,0.25)));
++ f0 *= pow(2,0.5);
++ }
++ }
++ else
++ return invalid_input_data_error;
++ return no_error;
++ }
++
++ eq_error_t set_30_bands(eq_double_t center_freq = bands_grid_center_freq_hz) {
++ freqs_.clear();
++ if(lowest_audio_freq_hz < center_freq &&
++ center_freq < highest_audio_freq_hz) {
++
++ //Find lowest center frequency in band
++ eq_double_t lowest_center_freq = center_freq;
++ while(lowest_center_freq > lowest_audio_freq_hz)
++ lowest_center_freq/=pow(2.0,1.0/3.0);
++ if(lowest_center_freq < lowest_audio_freq_hz)
++ lowest_center_freq*=pow(2.0,1.0/3.0);
++
++ //Calculate freq's
++ eq_double_t f0 = lowest_center_freq;
++ for(unsigned int i = 0; i < 30; i++) {
++ freqs_.push_back(band_freqs(f0/pow(2.0,1.0/6.0),
++ f0, f0*pow(2.0,1.0/6.0)));
++ f0 *= pow(2,1.0/3.0);
++ }
++ }
++ else
++ return invalid_input_data_error;
++ return no_error;
++ }
++
++ unsigned int get_number_of_bands(){return freqs_.size();}
++
++ std::vector<band_freqs> get_freqs(){return freqs_;}
++
++ unsigned int get_freq(unsigned int number) {
++ if(number < freqs_.size())
++ return freqs_[number].center_freq;
++ else
++ return 0;
++ }
++
++ unsigned int get_rounded_freq(unsigned int number) {
++ if(number < freqs_.size()) {
++ unsigned int freq = freqs_[number].center_freq;
++ if (freq < 100)
++ return freq;
++ else if(freq >= 100 && freq < 1000) {
++ unsigned int rest = freq%10;
++ if(rest < 5)
++ return freq - rest;
++ else
++ return freq - rest + 10;
++ }
++ else if(freq >= 1000 && freq < 10000) {
++ unsigned int rest = freq%100;
++ if(rest < 50)
++ return freq - rest;
++ else
++ return freq - rest + 100;
++ }
++ else if(freq >= 10000) {
++ unsigned int rest = freq%1000;
++ if(rest < 500)
++ return freq - rest;
++ else
++ return freq - rest + 1000;
++ }
++ }
++ return 0;
++ }
+ };
+
+ //------------ Forth order sections ------------
+@@ -340,551 +340,551 @@
+ eq_single_t denumBuf[fo_section_order];
+
+ inline eq_single_t df1_fo_process(eq_single_t in) {
+- eq_single_t out = 0;
+- out+= b0*in;
+- out+= (b1*numBuf[0] - denumBuf[0]*a1);
+- out+= (b2*numBuf[1] - denumBuf[1]*a2);
+- out+= (b3*numBuf[2] - denumBuf[2]*a3);
+- out+= (b4*numBuf[3] - denumBuf[3]*a4);
+-
+- numBuf[3] = numBuf[2];
+- numBuf[2] = numBuf[1];
+- numBuf[1] = numBuf[0];
+- *numBuf = in;
+-
+- denumBuf[3] = denumBuf[2];
+- denumBuf[2] = denumBuf[1];
+- denumBuf[1] = denumBuf[0];
+- *denumBuf = out;
++ eq_single_t out = 0;
++ out+= b0*in;
++ out+= (b1*numBuf[0] - denumBuf[0]*a1);
++ out+= (b2*numBuf[1] - denumBuf[1]*a2);
++ out+= (b3*numBuf[2] - denumBuf[2]*a3);
++ out+= (b4*numBuf[3] - denumBuf[3]*a4);
++
++ numBuf[3] = numBuf[2];
++ numBuf[2] = numBuf[1];
++ numBuf[1] = numBuf[0];
++ *numBuf = in;
++
++ denumBuf[3] = denumBuf[2];
++ denumBuf[2] = denumBuf[1];
++ denumBuf[1] = denumBuf[0];
++ *denumBuf = out;
+
+- return(out);
+- }
++ return(out);
++ }
+
+ public:
+- fo_section() {
+- b0 = 1; b1 = 0; b2 = 0; b3 = 0; b4 = 0;
+- a0 = 1; a1 = 0; a2 = 0; a3 = 0; a4 = 0;
+-
+- for(unsigned int i = 0; i < fo_section_order; i++) {
+- numBuf[i] = 0;
+- denumBuf[i] = 0;
+- }
+- }
+-
+- virtual ~fo_section(){}
+-
+- eq_single_t process(eq_single_t in) {
+- return df1_fo_process(in);
+- }
+-
+- virtual fo_section get() {
+- return *this;
+- }
++ fo_section() {
++ b0 = 1; b1 = 0; b2 = 0; b3 = 0; b4 = 0;
++ a0 = 1; a1 = 0; a2 = 0; a3 = 0; a4 = 0;
++
++ for(unsigned int i = 0; i < fo_section_order; i++) {
++ numBuf[i] = 0;
++ denumBuf[i] = 0;
++ }
++ }
++
++ virtual ~fo_section(){}
++
++ eq_single_t process(eq_single_t in) {
++ return df1_fo_process(in);
++ }
++
++ virtual fo_section get() {
++ return *this;
++ }
+ };
+
+ class butterworth_fo_section : public fo_section {
+- butterworth_fo_section(){}
+- butterworth_fo_section(butterworth_fo_section&){}
++ butterworth_fo_section(){}
++ butterworth_fo_section(butterworth_fo_section&){}
+ public:
+- butterworth_fo_section(eq_double_t beta,
+- eq_double_t s, eq_double_t g, eq_double_t g0,
+- eq_double_t D, eq_double_t c0) {
+- b0 = (g*g*beta*beta + 2*g*g0*s*beta + g0*g0)/D;
+- b1 = -4*c0*(g0*g0 + g*g0*s*beta)/D;
+- b2 = 2*(g0*g0*(1 + 2*c0*c0) - g*g*beta*beta)/D;
+- b3 = -4*c0*(g0*g0 - g*g0*s*beta)/D;
+- b4 = (g*g*beta*beta - 2*g*g0*s*beta + g0*g0)/D;
+-
+- a0 = 1;
+- a1 = -4*c0*(1 + s*beta)/D;
+- a2 = 2*(1 + 2*c0*c0 - beta*beta)/D;
+- a3 = -4*c0*(1 - s*beta)/D;
+- a4 = (beta*beta - 2*s*beta + 1)/D;
+- }
++ butterworth_fo_section(eq_double_t beta,
++ eq_double_t s, eq_double_t g, eq_double_t g0,
++ eq_double_t D, eq_double_t c0) {
++ b0 = (g*g*beta*beta + 2*g*g0*s*beta + g0*g0)/D;
++ b1 = -4*c0*(g0*g0 + g*g0*s*beta)/D;
++ b2 = 2*(g0*g0*(1 + 2*c0*c0) - g*g*beta*beta)/D;
++ b3 = -4*c0*(g0*g0 - g*g0*s*beta)/D;
++ b4 = (g*g*beta*beta - 2*g*g0*s*beta + g0*g0)/D;
++
++ a0 = 1;
++ a1 = -4*c0*(1 + s*beta)/D;
++ a2 = 2*(1 + 2*c0*c0 - beta*beta)/D;
++ a3 = -4*c0*(1 - s*beta)/D;
++ a4 = (beta*beta - 2*s*beta + 1)/D;
++ }
+
+- fo_section get() {return *this;}
++ fo_section get() {return *this;}
+ };
+
+ class chebyshev_type1_fo_section : public fo_section {
+- chebyshev_type1_fo_section(){}
+- chebyshev_type1_fo_section(chebyshev_type1_fo_section&){}
++ chebyshev_type1_fo_section(){}
++ chebyshev_type1_fo_section(chebyshev_type1_fo_section&){}
+ public:
+- chebyshev_type1_fo_section(eq_double_t a,
+- eq_double_t c, eq_double_t tetta_b,
+- eq_double_t g0, eq_double_t s, eq_double_t b,
+- eq_double_t D, eq_double_t c0) {
+- b0 = ((b*b + g0*g0*c*c)*tetta_b*tetta_b + 2*g0*b*s*tetta_b + g0*g0)/D;
+- b1 = -4*c0*(g0*g0 + g0*b*s*tetta_b)/D;
+- b2 = 2*(g0*g0*(1 + 2*c0*c0) - (b*b + g0*g0*c*c)*tetta_b*tetta_b)/D;
+- b3 = -4*c0*(g0*g0 - g0*b*s*tetta_b)/D;
+- b4 = ((b*b + g0*g0*c*c)*tetta_b*tetta_b - 2*g0*b*s*tetta_b + g0*g0)/D;
+-
+- a0 = 1;
+- a1 = -4*c0*(1 + a*s*tetta_b)/D;
+- a2 = 2*(1 + 2*c0*c0 - (a*a + c*c)*tetta_b*tetta_b)/D;
+- a3 = -4*c0*(1 - a*s*tetta_b)/D;
+- a4 = ((a*a + c*c)*tetta_b*tetta_b - 2*a*s*tetta_b + 1)/D;
+- }
++ chebyshev_type1_fo_section(eq_double_t a,
++ eq_double_t c, eq_double_t tetta_b,
++ eq_double_t g0, eq_double_t s, eq_double_t b,
++ eq_double_t D, eq_double_t c0) {
++ b0 = ((b*b + g0*g0*c*c)*tetta_b*tetta_b + 2*g0*b*s*tetta_b + g0*g0)/D;
++ b1 = -4*c0*(g0*g0 + g0*b*s*tetta_b)/D;
++ b2 = 2*(g0*g0*(1 + 2*c0*c0) - (b*b + g0*g0*c*c)*tetta_b*tetta_b)/D;
++ b3 = -4*c0*(g0*g0 - g0*b*s*tetta_b)/D;
++ b4 = ((b*b + g0*g0*c*c)*tetta_b*tetta_b - 2*g0*b*s*tetta_b + g0*g0)/D;
++
++ a0 = 1;
++ a1 = -4*c0*(1 + a*s*tetta_b)/D;
++ a2 = 2*(1 + 2*c0*c0 - (a*a + c*c)*tetta_b*tetta_b)/D;
++ a3 = -4*c0*(1 - a*s*tetta_b)/D;
++ a4 = ((a*a + c*c)*tetta_b*tetta_b - 2*a*s*tetta_b + 1)/D;
++ }
+
+- fo_section get() {return *this;}
++ fo_section get() {return *this;}
+ };
+
+ class chebyshev_type2_fo_section : public fo_section {
+- chebyshev_type2_fo_section(){}
+- chebyshev_type2_fo_section(chebyshev_type2_fo_section&){}
++ chebyshev_type2_fo_section(){}
++ chebyshev_type2_fo_section(chebyshev_type2_fo_section&){}
+ public:
+- chebyshev_type2_fo_section(eq_double_t a,
+- eq_double_t c, eq_double_t tetta_b,
+- eq_double_t g, eq_double_t s, eq_double_t b,
+- eq_double_t D, eq_double_t c0) {
+- b0 = (g*g*tetta_b*tetta_b + 2*g*b*s*tetta_b + b*b + g*g*c*c)/D;
+- b1 = -4*c0*(b*b + g*g*c*c + g*b*s*tetta_b)/D;
+- b2 = 2*((b*b + g*g*c*c)*(1 + 2*c0*c0) - g*g*tetta_b*tetta_b)/D;
+- b3 = -4*c0*(b*b + g*g*c*c - g*b*s*tetta_b)/D;
+- b4 = (g*g*tetta_b*tetta_b - 2*g*b*s*tetta_b + b*b + g*g*c*c)/D;
+-
+- a0 = 1;
+- a1 = -4*c0*(a*a + c*c + a*s*tetta_b)/D;
+- a2 = 2*((a*a + c*c)*(1 + 2*c0*c0) - tetta_b*tetta_b)/D;
+- a3 = -4*c0*(a*a + c*c - a*s*tetta_b)/D;
+- a4 = (tetta_b*tetta_b - 2*a*s*tetta_b + a*a + c*c)/D;
+- }
++ chebyshev_type2_fo_section(eq_double_t a,
++ eq_double_t c, eq_double_t tetta_b,
++ eq_double_t g, eq_double_t s, eq_double_t b,
++ eq_double_t D, eq_double_t c0) {
++ b0 = (g*g*tetta_b*tetta_b + 2*g*b*s*tetta_b + b*b + g*g*c*c)/D;
++ b1 = -4*c0*(b*b + g*g*c*c + g*b*s*tetta_b)/D;
++ b2 = 2*((b*b + g*g*c*c)*(1 + 2*c0*c0) - g*g*tetta_b*tetta_b)/D;
++ b3 = -4*c0*(b*b + g*g*c*c - g*b*s*tetta_b)/D;
++ b4 = (g*g*tetta_b*tetta_b - 2*g*b*s*tetta_b + b*b + g*g*c*c)/D;
++
++ a0 = 1;
++ a1 = -4*c0*(a*a + c*c + a*s*tetta_b)/D;
++ a2 = 2*((a*a + c*c)*(1 + 2*c0*c0) - tetta_b*tetta_b)/D;
++ a3 = -4*c0*(a*a + c*c - a*s*tetta_b)/D;
++ a4 = (tetta_b*tetta_b - 2*a*s*tetta_b + a*a + c*c)/D;
++ }
+
+- fo_section get() {return *this;}
++ fo_section get() {return *this;}
+ };
+
+ //------------ Bandpass filters ------------
+ class bp_filter {
+ public:
+- bp_filter(){}
+- virtual ~bp_filter(){}
++ bp_filter(){}
++ virtual ~bp_filter(){}
+
+- virtual eq_single_t process(eq_single_t in) = 0;
++ virtual eq_single_t process(eq_single_t in) = 0;
+ };
+
+ class butterworth_bp_filter : public bp_filter {
+ private:
+- std::vector<fo_section> sections_;
++ std::vector<fo_section> sections_;
+
+- butterworth_bp_filter(){}
++ butterworth_bp_filter(){}
+ public:
+- butterworth_bp_filter(butterworth_bp_filter& f) {
+- this->sections_ = f.sections_;
+- }
+-
+- butterworth_bp_filter(unsigned int N,
+- eq_double_t w0, eq_double_t wb,
+- eq_double_t G, eq_double_t Gb, eq_double_t G0) {
+- //Case if G == 0 : allpass
+- if(G == 0 && G0 == 0) {
+- sections_.push_back(fo_section());
+- return;
+- }
+-
+- //Get number of analog sections
+- unsigned int r = N%2;
+- unsigned int L = (N - r)/2;
+-
+- //Convert gains to linear scale
+- G = conversions::db_2_lin(G);
+- Gb = conversions::db_2_lin(Gb);
+- G0 = conversions::db_2_lin(G0);
+-
+- eq_double_t epsilon = pow(((eq_double_t)(G*G - Gb*Gb))/
+- (Gb*Gb - G0*G0),0.5);
+- eq_double_t g = pow(((eq_double_t)G),1.0/((eq_double_t)N));
+- eq_double_t g0 = pow(((eq_double_t)G0),1.0/((eq_double_t)N));
+- eq_double_t beta = pow(((eq_double_t)epsilon), -1.0/((eq_double_t)N))*
+- tan(wb/2.0);
+-
+- eq_double_t c0 = cos(w0);
+- if (w0 == 0) c0 = 1;
+- if (w0 == pi/2) c0=0;
+- if (w0 == pi) c0 =- 1;
+-
+- //Calculate every section
+- for(unsigned int i = 1; i <= L; i++) {
+- eq_double_t ui = (2.0*i-1)/N;
+- eq_double_t si = sin(pi*ui/2.0);
+-
+- eq_double_t Di = beta*beta + 2*si*beta + 1;
+-
+- sections_.push_back
+- (butterworth_fo_section(beta, si, g, g0, Di, c0));
+- }
+- }
+-
+- ~butterworth_bp_filter(){}
+-
+- static eq_single_t compute_bw_gain_db(eq_single_t gain) {
+- eq_single_t bw_gain = 0;
+- if(gain <= -6)
+- bw_gain = gain + common_base_gain_db;
+- else if(gain > -6 && gain < 6)
+- bw_gain = gain*0.5;
+- else if(gain >= 6)
+- bw_gain = gain - common_base_gain_db;
+-
+- return bw_gain;
+- }
+-
+- virtual eq_single_t process(eq_single_t in) {
+- eq_single_t p0 = in;
+- eq_single_t p1 = 0;
+- //Process FO sections in serial connection
+- for(unsigned int i = 0; i < sections_.size(); i++) {
+- p1 = sections_[i].process(p0);
+- p0 = p1;
+- }
++ butterworth_bp_filter(butterworth_bp_filter& f) {
++ this->sections_ = f.sections_;
++ }
++
++ butterworth_bp_filter(unsigned int N,
++ eq_double_t w0, eq_double_t wb,
++ eq_double_t G, eq_double_t Gb, eq_double_t G0) {
++ //Case if G == 0 : allpass
++ if(G == 0 && G0 == 0) {
++ sections_.push_back(fo_section());
++ return;
++ }
++
++ //Get number of analog sections
++ unsigned int r = N%2;
++ unsigned int L = (N - r)/2;
++
++ //Convert gains to linear scale
++ G = conversions::db_2_lin(G);
++ Gb = conversions::db_2_lin(Gb);
++ G0 = conversions::db_2_lin(G0);
++
++ eq_double_t epsilon = pow(((eq_double_t)(G*G - Gb*Gb))/
++ (Gb*Gb - G0*G0),0.5);
++ eq_double_t g = pow(((eq_double_t)G),1.0/((eq_double_t)N));
++ eq_double_t g0 = pow(((eq_double_t)G0),1.0/((eq_double_t)N));
++ eq_double_t beta = pow(((eq_double_t)epsilon), -1.0/((eq_double_t)N))*
++ tan(wb/2.0);
++
++ eq_double_t c0 = cos(w0);
++ if (w0 == 0) c0 = 1;
++ if (w0 == pi/2) c0=0;
++ if (w0 == pi) c0 =- 1;
++
++ //Calculate every section
++ for(unsigned int i = 1; i <= L; i++) {
++ eq_double_t ui = (2.0*i-1)/N;
++ eq_double_t si = sin(pi*ui/2.0);
++
++ eq_double_t Di = beta*beta + 2*si*beta + 1;
++
++ sections_.push_back
++ (butterworth_fo_section(beta, si, g, g0, Di, c0));
++ }
++ }
++
++ ~butterworth_bp_filter(){}
++
++ static eq_single_t compute_bw_gain_db(eq_single_t gain) {
++ eq_single_t bw_gain = 0;
++ if(gain <= -6)
++ bw_gain = gain + common_base_gain_db;
++ else if(gain > -6 && gain < 6)
++ bw_gain = gain*0.5;
++ else if(gain >= 6)
++ bw_gain = gain - common_base_gain_db;
++
++ return bw_gain;
++ }
++
++ virtual eq_single_t process(eq_single_t in) {
++ eq_single_t p0 = in;
++ eq_single_t p1 = 0;
++ //Process FO sections in serial connection
++ for(unsigned int i = 0; i < sections_.size(); i++) {
++ p1 = sections_[i].process(p0);
++ p0 = p1;
++ }
+
+- return p1;
+- }
++ return p1;
++ }
+ };
+
+ class chebyshev_type1_bp_filter : public bp_filter {
+ private:
+- std::vector<fo_section> sections_;
++ std::vector<fo_section> sections_;
+
+- chebyshev_type1_bp_filter(){}
++ chebyshev_type1_bp_filter(){}
+ public:
+- chebyshev_type1_bp_filter(unsigned int N,
+- eq_double_t w0, eq_double_t wb,
+- eq_double_t G, eq_double_t Gb, eq_double_t G0) {
+- //Case if G == 0 : allpass
+- if(G == 0 && G0 == 0) {
+- sections_.push_back(fo_section());
+- return;
+- }
+-
+- //Get number of analog sections
+- unsigned int r = N%2;
+- unsigned int L = (N - r)/2;
+-
+- //Convert gains to linear scale
+- G = conversions::db_2_lin(G);
+- Gb = conversions::db_2_lin(Gb);
+- G0 = conversions::db_2_lin(G0);
+-
+- eq_double_t epsilon = pow((eq_double_t)(G*G - Gb*Gb)/
+- (Gb*Gb - G0*G0),0.5);
+- eq_double_t g0 = pow((eq_double_t)(G0),1.0/N);
+- eq_double_t alfa =
+- pow(1.0/epsilon + pow(1 + pow(epsilon,-2.0),0.5),1.0/N);
+- eq_double_t beta =
+- pow(G/epsilon + Gb*pow(1 + pow(epsilon,-2.0),0.5),1.0/N);
+- eq_double_t a = 0.5*(alfa - 1.0/alfa);
+- eq_double_t b = 0.5*(beta - g0*g0*(1/beta));
+- eq_double_t tetta_b = tan(wb/2);
+-
+- eq_double_t c0 = cos(w0);
+- if (w0 == 0) c0 = 1;
+- if (w0 == pi/2) c0=0;
+- if (w0 == pi) c0 =- 1;
+-
+- //Calculate every section
+- for(unsigned int i = 1; i <= L; i++) {
+- eq_double_t ui = (2.0*i-1.0)/N;
+- eq_double_t ci = cos(pi*ui/2.0);
+- eq_double_t si = sin(pi*ui/2.0);
+-
+- eq_double_t Di = (a*a + ci*ci)*tetta_b*tetta_b +
+- 2.0*a*si*tetta_b + 1;
+- sections_.push_back(
+- chebyshev_type1_fo_section(a, ci, tetta_b, g0, si, b, Di, c0));
+- }
+- }
+-
+-
+- ~chebyshev_type1_bp_filter(){}
+-
+- static eq_single_t compute_bw_gain_db(eq_single_t gain) {
+- eq_single_t bw_gain = 0;
+- if(gain <= -6)
+- bw_gain = gain + 1;
+- else if(gain > -6 && gain < 6)
+- bw_gain = gain*0.9;
+- else if(gain >= 6)
+- bw_gain = gain - 1;
+-
+- return bw_gain;
+- }
+-
+- eq_single_t process(eq_single_t in) {
+- eq_single_t p0 = in;
+- eq_single_t p1 = 0;
+- //Process FO sections in serial connection
+- for(unsigned int i = 0; i < sections_.size(); i++) {
+- p1 = sections_[i].process(p0);
+- p0 = p1;
+- }
++ chebyshev_type1_bp_filter(unsigned int N,
++ eq_double_t w0, eq_double_t wb,
++ eq_double_t G, eq_double_t Gb, eq_double_t G0) {
++ //Case if G == 0 : allpass
++ if(G == 0 && G0 == 0) {
++ sections_.push_back(fo_section());
++ return;
++ }
++
++ //Get number of analog sections
++ unsigned int r = N%2;
++ unsigned int L = (N - r)/2;
++
++ //Convert gains to linear scale
++ G = conversions::db_2_lin(G);
++ Gb = conversions::db_2_lin(Gb);
++ G0 = conversions::db_2_lin(G0);
++
++ eq_double_t epsilon = pow((eq_double_t)(G*G - Gb*Gb)/
++ (Gb*Gb - G0*G0),0.5);
++ eq_double_t g0 = pow((eq_double_t)(G0),1.0/N);
++ eq_double_t alfa =
++ pow(1.0/epsilon + pow(1 + pow(epsilon,-2.0),0.5),1.0/N);
++ eq_double_t beta =
++ pow(G/epsilon + Gb*pow(1 + pow(epsilon,-2.0),0.5),1.0/N);
++ eq_double_t a = 0.5*(alfa - 1.0/alfa);
++ eq_double_t b = 0.5*(beta - g0*g0*(1/beta));
++ eq_double_t tetta_b = tan(wb/2);
++
++ eq_double_t c0 = cos(w0);
++ if (w0 == 0) c0 = 1;
++ if (w0 == pi/2) c0=0;
++ if (w0 == pi) c0 =- 1;
++
++ //Calculate every section
++ for(unsigned int i = 1; i <= L; i++) {
++ eq_double_t ui = (2.0*i-1.0)/N;
++ eq_double_t ci = cos(pi*ui/2.0);
++ eq_double_t si = sin(pi*ui/2.0);
++
++ eq_double_t Di = (a*a + ci*ci)*tetta_b*tetta_b +
++ 2.0*a*si*tetta_b + 1;
++ sections_.push_back(
++ chebyshev_type1_fo_section(a, ci, tetta_b, g0, si, b, Di, c0));
++ }
++ }
++
++
++ ~chebyshev_type1_bp_filter(){}
++
++ static eq_single_t compute_bw_gain_db(eq_single_t gain) {
++ eq_single_t bw_gain = 0;
++ if(gain <= -6)
++ bw_gain = gain + 1;
++ else if(gain > -6 && gain < 6)
++ bw_gain = gain*0.9;
++ else if(gain >= 6)
++ bw_gain = gain - 1;
++
++ return bw_gain;
++ }
++
++ eq_single_t process(eq_single_t in) {
++ eq_single_t p0 = in;
++ eq_single_t p1 = 0;
++ //Process FO sections in serial connection
++ for(unsigned int i = 0; i < sections_.size(); i++) {
++ p1 = sections_[i].process(p0);
++ p0 = p1;
++ }
+
+- return p1;
+- }
++ return p1;
++ }
+ };
+
+ class chebyshev_type2_bp_filter : public bp_filter {
+ private:
+- std::vector<fo_section> sections_;
++ std::vector<fo_section> sections_;
+
+- chebyshev_type2_bp_filter(){}
++ chebyshev_type2_bp_filter(){}
+ public:
+- chebyshev_type2_bp_filter(unsigned int N,
+- eq_double_t w0, eq_double_t wb,
+- eq_double_t G, eq_double_t Gb, eq_double_t G0) {
+- //Case if G == 0 : allpass
+- if(G == 0 && G0 == 0) {
+- sections_.push_back(fo_section());
+- return;
+- }
+-
+- //Get number of analog sections
+- unsigned int r = N%2;
+- unsigned int L = (N - r)/2;
+-
+- //Convert gains to linear scale
+- G = conversions::db_2_lin(G);
+- Gb = conversions::db_2_lin(Gb);
+- G0 = conversions::db_2_lin(G0);
+-
+- eq_double_t epsilon = pow((eq_double_t)((G*G - Gb*Gb)/
+- (Gb*Gb - G0*G0)),0.5);
+- eq_double_t g = pow((eq_double_t)(G),1.0/N);
+- eq_double_t eu = pow(epsilon + sqrt(1 + epsilon*epsilon), 1.0/N);
+- eq_double_t ew = pow(G0*epsilon + Gb*sqrt(1 + epsilon*epsilon), 1.0/N);
+- eq_double_t a = (eu - 1.0/eu)/2.0;
+- eq_double_t b = (ew - g*g/ew)/2.0;
+- eq_double_t tetta_b = tan(wb/2);
+-
+- eq_double_t c0 = cos(w0);
+- if (w0 == 0) c0 = 1;
+- if (w0 == pi/2) c0=0;
+- if (w0 == pi) c0 =- 1;
+-
+- //Calculate every section
+- for(unsigned int i = 1; i <= L; i++) {
+- eq_double_t ui = (2.0*i-1.0)/N;
+- eq_double_t ci = cos(pi*ui/2.0);
+- eq_double_t si = sin(pi*ui/2.0);
+- eq_double_t Di = tetta_b*tetta_b + 2*a*si*tetta_b + a*a + ci*ci;
+-
+- sections_.push_back(
+- chebyshev_type2_fo_section(a, ci, tetta_b, g, si, b, Di, c0));
+- }
+- }
+-
+- ~chebyshev_type2_bp_filter(){}
+-
+- static eq_single_t compute_bw_gain_db(eq_single_t gain) {
+- eq_single_t bw_gain = 0;
+- if(gain <= -6)
+- bw_gain = -common_base_gain_db;
+- else if(gain > -6 && gain < 6)
+- bw_gain = gain*0.3;
+- else if(gain >= 6)
+- bw_gain = common_base_gain_db;
+-
+- return bw_gain;
+- }
+-
+- eq_single_t process(eq_single_t in) {
+- eq_single_t p0 = in;
+- eq_single_t p1 = 0;
+-
+- //Process FO sections in serial connection
+- for(unsigned int i = 0; i < sections_.size(); i++) {
+- p1 = sections_[i].process(p0);
+- p0 = p1;
+- }
++ chebyshev_type2_bp_filter(unsigned int N,
++ eq_double_t w0, eq_double_t wb,
++ eq_double_t G, eq_double_t Gb, eq_double_t G0) {
++ //Case if G == 0 : allpass
++ if(G == 0 && G0 == 0) {
++ sections_.push_back(fo_section());
++ return;
++ }
++
++ //Get number of analog sections
++ unsigned int r = N%2;
++ unsigned int L = (N - r)/2;
++
++ //Convert gains to linear scale
++ G = conversions::db_2_lin(G);
++ Gb = conversions::db_2_lin(Gb);
++ G0 = conversions::db_2_lin(G0);
++
++ eq_double_t epsilon = pow((eq_double_t)((G*G - Gb*Gb)/
++ (Gb*Gb - G0*G0)),0.5);
++ eq_double_t g = pow((eq_double_t)(G),1.0/N);
++ eq_double_t eu = pow(epsilon + sqrt(1 + epsilon*epsilon), 1.0/N);
++ eq_double_t ew = pow(G0*epsilon + Gb*sqrt(1 + epsilon*epsilon), 1.0/N);
++ eq_double_t a = (eu - 1.0/eu)/2.0;
++ eq_double_t b = (ew - g*g/ew)/2.0;
++ eq_double_t tetta_b = tan(wb/2);
++
++ eq_double_t c0 = cos(w0);
++ if (w0 == 0) c0 = 1;
++ if (w0 == pi/2) c0=0;
++ if (w0 == pi) c0 =- 1;
++
++ //Calculate every section
++ for(unsigned int i = 1; i <= L; i++) {
++ eq_double_t ui = (2.0*i-1.0)/N;
++ eq_double_t ci = cos(pi*ui/2.0);
++ eq_double_t si = sin(pi*ui/2.0);
++ eq_double_t Di = tetta_b*tetta_b + 2*a*si*tetta_b + a*a + ci*ci;
++
++ sections_.push_back(
++ chebyshev_type2_fo_section(a, ci, tetta_b, g, si, b, Di, c0));
++ }
++ }
+
+- return p1;
+- }
++ ~chebyshev_type2_bp_filter(){}
++
++ static eq_single_t compute_bw_gain_db(eq_single_t gain) {
++ eq_single_t bw_gain = 0;
++ if(gain <= -6)
++ bw_gain = -common_base_gain_db;
++ else if(gain > -6 && gain < 6)
++ bw_gain = gain*0.3;
++ else if(gain >= 6)
++ bw_gain = common_base_gain_db;
++
++ return bw_gain;
++ }
++
++ eq_single_t process(eq_single_t in) {
++ eq_single_t p0 = in;
++ eq_single_t p1 = 0;
++
++ //Process FO sections in serial connection
++ for(unsigned int i = 0; i < sections_.size(); i++) {
++ p1 = sections_[i].process(p0);
++ p0 = p1;
++ }
++
++ return p1;
++ }
+ };
+
+ // ------------ eq1 ------------
+ // Equalizer with single precomputed filter for every band
+ class eq1 {
+ private:
+- conversions conv_;
+- eq_double_t sampling_frequency_;
+- freq_grid freq_grid_;
+- std::vector<eq_single_t> band_gains_;
+- std::vector<bp_filter*> filters_;
+- filter_type current_eq_type_;
+-
+- eq1():conv_(eq_min_max_gain_db){}
+- eq1(const eq1&):conv_(eq_min_max_gain_db){}
+-
+- void cleanup_filters_array() {
+- for(unsigned int j = 0; j < filters_.size(); j++)
+- delete filters_[j];
+- }
++ conversions conv_;
++ eq_double_t sampling_frequency_;
++ freq_grid freq_grid_;
++ std::vector<eq_single_t> band_gains_;
++ std::vector<bp_filter*> filters_;
++ filter_type current_eq_type_;
++
++ eq1():conv_(eq_min_max_gain_db){}
++ eq1(const eq1&):conv_(eq_min_max_gain_db){}
++
++ void cleanup_filters_array() {
++ for(unsigned int j = 0; j < filters_.size(); j++)
++ delete filters_[j];
++ }
+
+ public:
+- eq1(const freq_grid &fg, filter_type eq_t) : conv_(eq_min_max_gain_db) {
+- sampling_frequency_ = default_sample_freq_hz;
+- freq_grid_ = fg;
+- current_eq_type_ = eq_t;
++ eq1(const freq_grid &fg, filter_type eq_t) : conv_(eq_min_max_gain_db) {
++ sampling_frequency_ = default_sample_freq_hz;
++ freq_grid_ = fg;
++ current_eq_type_ = eq_t;
+ set_eq(freq_grid_, eq_t);
+- }
+- ~eq1(){cleanup_filters_array();}
++ }
++ ~eq1(){cleanup_filters_array();}
++
++ eq_error_t set_eq(freq_grid& fg, filter_type eqt) {
++ band_gains_.clear();
++ cleanup_filters_array();
++ filters_.clear();
++ freq_grid_ = fg;
++
++ for(unsigned int i = 0; i < freq_grid_.get_number_of_bands(); i++) {
++
++ eq_double_t wb = conversions::hz_2_rad(
++ freq_grid_.get_freqs()[i].max_freq -
++ freq_grid_.get_freqs()[i].min_freq,
++ sampling_frequency_);
++
++ eq_double_t w0 = conversions::hz_2_rad(
++ freq_grid_.get_freqs()[i].center_freq,
++ sampling_frequency_);
++
++ switch(eqt) {
++ case (butterworth): {
++ butterworth_bp_filter* bf =
++ new butterworth_bp_filter(
++ default_eq_band_filters_order,
++ w0,
++ wb,
++ max_base_gain_db,
++ butterworth_band_gain_db,
++ min_base_gain_db
++ );
+
+- eq_error_t set_eq(freq_grid& fg, filter_type eqt) {
+- band_gains_.clear();
+- cleanup_filters_array();
+- filters_.clear();
+- freq_grid_ = fg;
+-
+- for(unsigned int i = 0; i < freq_grid_.get_number_of_bands(); i++) {
+-
+- eq_double_t wb = conversions::hz_2_rad(
+- freq_grid_.get_freqs()[i].max_freq -
+- freq_grid_.get_freqs()[i].min_freq,
+- sampling_frequency_);
+-
+- eq_double_t w0 = conversions::hz_2_rad(
+- freq_grid_.get_freqs()[i].center_freq,
+- sampling_frequency_);
+-
+- switch(eqt) {
+- case (butterworth): {
+- butterworth_bp_filter* bf =
+- new butterworth_bp_filter(
+- default_eq_band_filters_order,
+- w0,
+- wb,
+- max_base_gain_db,
+- butterworth_band_gain_db,
+- min_base_gain_db
+- );
+-
+- filters_.push_back(bf);
+- break;
+- }
+-
+- case (chebyshev1): {
+- chebyshev_type1_bp_filter* cf1 =
+- new chebyshev_type1_bp_filter(
+- default_eq_band_filters_order,
+- w0,
+- wb,
+- max_base_gain_db,
+- chebyshev1_band_base_gain_db,
+- min_base_gain_db
+- );
+-
+- filters_.push_back(cf1);
+- break;
+- }
+-
+- case (chebyshev2): {
+- chebyshev_type2_bp_filter* cf2 =
+- new chebyshev_type2_bp_filter(
+- default_eq_band_filters_order,
+- w0,
+- wb,
+- max_base_gain_db,
+- chebyshev2_band_base_gain_db,
+- min_base_gain_db
+- );
+-
+- filters_.push_back(cf2);
+- break;
+- }
+-
+- default:
+- current_eq_type_ = none;
+- return invalid_input_data_error;
+-
+- }
+- band_gains_.push_back(max_base_gain_db);
+- }
+-
+- current_eq_type_ = eqt;
+- return no_error;
+- }
+-
+- eq_error_t set_eq(filter_type eqt)
+- {
+- return set_eq(freq_grid_, eqt);
+- }
+-
+- eq_error_t set_sample_rate(eq_double_t sr) {
+- eq_error_t err = no_error;
+- sampling_frequency_ = sr;
+- err = set_eq(freq_grid_, current_eq_type_);
+-
+- return err;
+- }
+-
+- eq_error_t change_gains(std::vector<eq_single_t> band_gains) {
+- if(band_gains_.size() == band_gains.size())
+- band_gains_ = band_gains;
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
+-
+- eq_error_t change_gains_db(std::vector<eq_single_t> band_gains) {
+- if(band_gains_.size() == band_gains.size())
+- for(unsigned int j = 0; j < get_number_of_bands(); j++)
+- band_gains_[j] = conv_.fast_db_2_lin(band_gains[j]);
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
+-
+- eq_error_t change_band_gain(unsigned int band_number,
+- eq_single_t band_gain) {
+- if(band_number < get_number_of_bands())
+- band_gains_[band_number] = band_gain;
++ filters_.push_back(bf);
++ break;
++ }
++
++ case (chebyshev1): {
++ chebyshev_type1_bp_filter* cf1 =
++ new chebyshev_type1_bp_filter(
++ default_eq_band_filters_order,
++ w0,
++ wb,
++ max_base_gain_db,
++ chebyshev1_band_base_gain_db,
++ min_base_gain_db
++ );
++
++ filters_.push_back(cf1);
++ break;
++ }
++
++ case (chebyshev2): {
++ chebyshev_type2_bp_filter* cf2 =
++ new chebyshev_type2_bp_filter(
++ default_eq_band_filters_order,
++ w0,
++ wb,
++ max_base_gain_db,
++ chebyshev2_band_base_gain_db,
++ min_base_gain_db
++ );
++
++ filters_.push_back(cf2);
++ break;
++ }
++
++ default:
++ current_eq_type_ = none;
++ return invalid_input_data_error;
++
++ }
++ band_gains_.push_back(max_base_gain_db);
++ }
++
++ current_eq_type_ = eqt;
++ return no_error;
++ }
++
++ eq_error_t set_eq(filter_type eqt)
++ {
++ return set_eq(freq_grid_, eqt);
++ }
++
++ eq_error_t set_sample_rate(eq_double_t sr) {
++ eq_error_t err = no_error;
++ sampling_frequency_ = sr;
++ err = set_eq(freq_grid_, current_eq_type_);
++
++ return err;
++ }
++
++ eq_error_t change_gains(std::vector<eq_single_t> band_gains) {
++ if(band_gains_.size() == band_gains.size())
++ band_gains_ = band_gains;
++ else
++ return invalid_input_data_error;
++
++ return no_error;
++ }
++
++ eq_error_t change_gains_db(std::vector<eq_single_t> band_gains) {
++ if(band_gains_.size() == band_gains.size())
++ for(unsigned int j = 0; j < get_number_of_bands(); j++)
++ band_gains_[j] = conv_.fast_db_2_lin(band_gains[j]);
++ else
++ return invalid_input_data_error;
++
++ return no_error;
++ }
++
++ eq_error_t change_band_gain(unsigned int band_number,
++ eq_single_t band_gain) {
++ if(band_number < get_number_of_bands())
++ band_gains_[band_number] = band_gain;
+ else
+- return invalid_input_data_error;
++ return invalid_input_data_error;
+
+- return no_error;
+- }
++ return no_error;
++ }
++
++ eq_error_t change_band_gain_db(unsigned int band_number,
++ eq_single_t band_gain) {
++ if(band_number < get_number_of_bands())
++ band_gains_[band_number] = conv_.fast_db_2_lin(band_gain);
++ else
++ return invalid_input_data_error;
++
++ return no_error;
++ }
+
+- eq_error_t change_band_gain_db(unsigned int band_number,
+- eq_single_t band_gain) {
+- if(band_number < get_number_of_bands())
+- band_gains_[band_number] = conv_.fast_db_2_lin(band_gain);
++ eq_error_t sbs_process_band(unsigned int band_number,
++ eq_single_t *in, eq_single_t *out) {
++ if(band_number < get_number_of_bands())
++ *out = band_gains_[band_number]*
++ filters_[band_number]->process(*in);
+ else
+- return invalid_input_data_error;
++ return invalid_input_data_error;
+
+- return no_error;
+- }
++ return no_error;
++ }
+
+- eq_error_t sbs_process_band(unsigned int band_number,
+- eq_single_t *in, eq_single_t *out) {
+- if(band_number < get_number_of_bands())
+- *out = band_gains_[band_number]*
+- filters_[band_number]->process(*in);
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
+-
+- eq_error_t sbs_process(eq_single_t *in, eq_single_t *out) {
+- eq_error_t err = no_error;
+- eq_single_t acc_out = 0;
+- for(unsigned int j = 0; j < get_number_of_bands(); j++) {
+- eq_single_t band_out = 0;
+- err = sbs_process_band(j, in, &band_out);
+- acc_out += band_out;
+- }
+- *out = acc_out;
+-
+- return err;
+- }
+-
+- filter_type get_eq_type(){return current_eq_type_;}
+- const char* get_string_eq_type(){return get_eq_text(current_eq_type_);}
+- unsigned int get_number_of_bands() {
+- return freq_grid_.get_number_of_bands();
+- }
+- const char* get_version(){return eq_version;}
++ eq_error_t sbs_process(eq_single_t *in, eq_single_t *out) {
++ eq_error_t err = no_error;
++ eq_single_t acc_out = 0;
++ for(unsigned int j = 0; j < get_number_of_bands(); j++) {
++ eq_single_t band_out = 0;
++ err = sbs_process_band(j, in, &band_out);
++ acc_out += band_out;
++ }
++ *out = acc_out;
++
++ return err;
++ }
++
++ filter_type get_eq_type(){return current_eq_type_;}
++ const char* get_string_eq_type(){return get_eq_text(current_eq_type_);}
++ unsigned int get_number_of_bands() {
++ return freq_grid_.get_number_of_bands();
++ }
++ const char* get_version(){return eq_version;}
+ };
+
+ //!!! New functionality
+@@ -894,143 +894,143 @@
+ // consists of vector of filters for every gain value
+ class eq_channel
+ {
+- eq_single_t f0_;
+- eq_single_t fb_;
+- eq_single_t sampling_frequency_;
+- eq_single_t min_max_gain_db_;
+- eq_single_t gain_step_db_;
+-
+- unsigned int current_filter_index_;
+- eq_single_t current_gain_db_;
+-
+- std::vector<bp_filter*> filters_;
+- filter_type current_channel_type_;
+-
+- eq_channel(){}
+-
+- unsigned int get_flt_index(eq_single_t gain_db) {
+- unsigned int number_of_filters = filters_.size();
+- eq_single_t scale_coef = gain_db/min_max_gain_db_;
+- return (number_of_filters/2) + (number_of_filters/2)*scale_coef;
+- }
+-
+- void cleanup_filters_array() {
+- for(unsigned int j = 0; j < filters_.size(); j++)
+- delete filters_[j];
+- }
+-
++ eq_single_t f0_;
++ eq_single_t fb_;
++ eq_single_t sampling_frequency_;
++ eq_single_t min_max_gain_db_;
++ eq_single_t gain_step_db_;
++
++ unsigned int current_filter_index_;
++ eq_single_t current_gain_db_;
++
++ std::vector<bp_filter*> filters_;
++ filter_type current_channel_type_;
++
++ eq_channel(){}
++
++ unsigned int get_flt_index(eq_single_t gain_db) {
++ unsigned int number_of_filters = filters_.size();
++ eq_single_t scale_coef = gain_db/min_max_gain_db_;
++ return (number_of_filters/2) + (number_of_filters/2)*scale_coef;
++ }
++
++ void cleanup_filters_array() {
++ for(unsigned int j = 0; j < filters_.size(); j++)
++ delete filters_[j];
++ }
++
+ public:
+- eq_channel(filter_type ft,
+- eq_single_t fs, eq_single_t f0, eq_single_t fb,
+- eq_single_t min_max_gain_db = p_eq_min_max_gain_db,
+- eq_single_t step_db = p_eq_gain_step_db) {
+-
+- //Init data fields
+- sampling_frequency_ = fs;
+- f0_ = f0;
+- fb_ = fb;
+- min_max_gain_db_ = min_max_gain_db;
+- gain_step_db_ = step_db;
+-
+- current_gain_db_ = 0;
+- current_filter_index_ = 0;
+-
+- current_channel_type_ = ft;
+-
+- set_channel(current_channel_type_, sampling_frequency_);
+- }
+-
+- ~eq_channel(){cleanup_filters_array();}
+-
+- eq_error_t set_channel(filter_type ft, eq_single_t fs) {
+-
+- eq_double_t wb = conversions::hz_2_rad(fb_, sampling_frequency_);
++ eq_channel(filter_type ft,
++ eq_single_t fs, eq_single_t f0, eq_single_t fb,
++ eq_single_t min_max_gain_db = p_eq_min_max_gain_db,
++ eq_single_t step_db = p_eq_gain_step_db) {
++
++ //Init data fields
++ sampling_frequency_ = fs;
++ f0_ = f0;
++ fb_ = fb;
++ min_max_gain_db_ = min_max_gain_db;
++ gain_step_db_ = step_db;
++
++ current_gain_db_ = 0;
++ current_filter_index_ = 0;
++
++ current_channel_type_ = ft;
++
++ set_channel(current_channel_type_, sampling_frequency_);
++ }
++
++ ~eq_channel(){cleanup_filters_array();}
++
++ eq_error_t set_channel(filter_type ft, eq_single_t fs) {
++
++ eq_double_t wb = conversions::hz_2_rad(fb_, sampling_frequency_);
+ eq_double_t w0 = conversions::hz_2_rad(f0_, sampling_frequency_);
+-
+- for(eq_single_t gain = -min_max_gain_db_; gain <= min_max_gain_db_;
+- gain+= gain_step_db_) {
+-
+- switch(ft) {
+- case (butterworth): {
+- eq_single_t bw_gain =
+- butterworth_bp_filter::compute_bw_gain_db(gain);
+-
+- butterworth_bp_filter* bf =
+- new butterworth_bp_filter(
+- default_eq_band_filters_order,
+- w0,
+- wb,
+- gain,
+- bw_gain,
+- p_eq_default_gain_db
+- );
+-
+- filters_.push_back(bf);
+- break;
+- }
+- case (chebyshev1): {
+- eq_single_t bw_gain =
+- chebyshev_type1_bp_filter::compute_bw_gain_db(gain);
+-
+- chebyshev_type1_bp_filter* cf1 =
+- new chebyshev_type1_bp_filter(
+- default_eq_band_filters_order,
+- w0,
+- wb,
+- gain,
+- bw_gain,
+- p_eq_default_gain_db
+- );
+-
+- filters_.push_back(cf1);
+- break;
+- }
+- case (chebyshev2): {
+- eq_single_t bw_gain =
+- chebyshev_type2_bp_filter::compute_bw_gain_db(gain);
+-
+- chebyshev_type2_bp_filter* cf2 =
+- new chebyshev_type2_bp_filter(
+- default_eq_band_filters_order,
+- w0,
+- wb,
+- gain,
+- bw_gain,
+- p_eq_default_gain_db
+- );
+-
+- filters_.push_back(cf2);
+- break;
+- }
+- default: {
+- current_channel_type_ = none;
+- return invalid_input_data_error;
++
++ for(eq_single_t gain = -min_max_gain_db_; gain <= min_max_gain_db_;
++ gain+= gain_step_db_) {
++
++ switch(ft) {
++ case (butterworth): {
++ eq_single_t bw_gain =
++ butterworth_bp_filter::compute_bw_gain_db(gain);
++
++ butterworth_bp_filter* bf =
++ new butterworth_bp_filter(
++ default_eq_band_filters_order,
++ w0,
++ wb,
++ gain,
++ bw_gain,
++ p_eq_default_gain_db
++ );
++
++ filters_.push_back(bf);
++ break;
++ }
++ case (chebyshev1): {
++ eq_single_t bw_gain =
++ chebyshev_type1_bp_filter::compute_bw_gain_db(gain);
++
++ chebyshev_type1_bp_filter* cf1 =
++ new chebyshev_type1_bp_filter(
++ default_eq_band_filters_order,
++ w0,
++ wb,
++ gain,
++ bw_gain,
++ p_eq_default_gain_db
++ );
++
++ filters_.push_back(cf1);
++ break;
++ }
++ case (chebyshev2): {
++ eq_single_t bw_gain =
++ chebyshev_type2_bp_filter::compute_bw_gain_db(gain);
++
++ chebyshev_type2_bp_filter* cf2 =
++ new chebyshev_type2_bp_filter(
++ default_eq_band_filters_order,
++ w0,
++ wb,
++ gain,
++ bw_gain,
++ p_eq_default_gain_db
++ );
++
++ filters_.push_back(cf2);
++ break;
+ }
+- }
+- }
+-
+- //Get current filter index
+- current_gain_db_ = 0;
+- current_filter_index_ = get_flt_index(current_gain_db_);
+-
+- return no_error;
+- }
+-
+- eq_error_t set_gain_db(eq_single_t db) {
+- if (db > -min_max_gain_db_ && db < min_max_gain_db_) {
+- current_gain_db_ = db;
+- current_filter_index_ = get_flt_index(db);
+- }
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
+-
+- eq_error_t sbs_process(eq_single_t *in, eq_single_t *out) {
+- *out = filters_[current_filter_index_]->process(*in);
+- return no_error;
+- }
++ default: {
++ current_channel_type_ = none;
++ return invalid_input_data_error;
++ }
++ }
++ }
++
++ //Get current filter index
++ current_gain_db_ = 0;
++ current_filter_index_ = get_flt_index(current_gain_db_);
++
++ return no_error;
++ }
++
++ eq_error_t set_gain_db(eq_single_t db) {
++ if (db > -min_max_gain_db_ && db < min_max_gain_db_) {
++ current_gain_db_ = db;
++ current_filter_index_ = get_flt_index(db);
++ } else {
++ return invalid_input_data_error;
++ }
++
++ return no_error;
++ }
++
++ eq_error_t sbs_process(eq_single_t *in, eq_single_t *out) {
++ *out = filters_[current_filter_index_]->process(*in);
++ return no_error;
++ }
+ };
+
+ // ------------ eq2 ------------
+@@ -1038,123 +1038,123 @@
+
+ class eq2
+ {
+- conversions conv_;
+- eq_double_t sampling_frequency_;
+- freq_grid freq_grid_;
+- std::vector<eq_channel*> channels_;
+- filter_type current_eq_type_;
+-
+- void cleanup_channels_array() {
+- for(unsigned int j = 0; j < channels_.size(); j++)
+- delete channels_[j];
+- }
++ conversions conv_;
++ eq_double_t sampling_frequency_;
++ freq_grid freq_grid_;
++ std::vector<eq_channel*> channels_;
++ filter_type current_eq_type_;
++
++ void cleanup_channels_array() {
++ for(unsigned int j = 0; j < channels_.size(); j++)
++ delete channels_[j];
++ }
+
+ public:
+- eq2(freq_grid &fg, filter_type eq_t) : conv_(eq_min_max_gain_db) {
+- sampling_frequency_ = default_sample_freq_hz;
+- freq_grid_ = fg;
+- current_eq_type_ = eq_t;
++ eq2(freq_grid &fg, filter_type eq_t) : conv_(eq_min_max_gain_db) {
++ sampling_frequency_ = default_sample_freq_hz;
++ freq_grid_ = fg;
++ current_eq_type_ = eq_t;
+ set_eq(freq_grid_, eq_t);
+- }
+- ~eq2(){cleanup_channels_array();}
+-
+- eq_error_t set_eq(const freq_grid& fg, filter_type ft) {
+- cleanup_channels_array();
+- channels_.clear();
+- freq_grid_ = fg;
+-
+- for(unsigned int i = 0; i < freq_grid_.get_number_of_bands(); i++) {
+- band_freqs b_fres = freq_grid_.get_freqs()[i];
+-
+- eq_channel* eq_ch = new eq_channel(ft, sampling_frequency_,
+- b_fres.center_freq, b_fres.max_freq - b_fres.min_freq);
+-
+- channels_.push_back(eq_ch);
+- channels_[i]->set_gain_db(p_eq_default_gain_db);
+- }
+-
+- current_eq_type_ = ft;
+- return no_error;
+- }
+-
+- eq_error_t set_eq(filter_type ft) {
+- eq_error_t err = set_eq(freq_grid_, ft);
+- return err;
+- }
+-
+- eq_error_t set_sample_rate(eq_double_t sr) {
+- sampling_frequency_ = sr;
+- eq_error_t err = set_eq(current_eq_type_);
+- return err;
+- }
+-
+- eq_error_t change_gains(std::vector<eq_single_t> band_gains) {
+- if(channels_.size() == band_gains.size())
+- for(unsigned int j = 0; j < channels_.size(); j++)
+- channels_[j]->set_gain_db(conv_.fast_lin_2_db(band_gains[j]));
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
+-
+- eq_error_t change_gains_db(std::vector<eq_single_t> band_gains) {
+- if(channels_.size() == band_gains.size())
+- for(unsigned int j = 0; j < channels_.size(); j++)
+- channels_[j]->set_gain_db(band_gains[j]);
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
+-
+- eq_error_t change_band_gain(unsigned int band_number,
+- eq_single_t band_gain) {
+- if(band_number < channels_.size())
+- channels_[band_number]->set_gain_db(conv_.fast_lin_2_db(band_gain));
++ }
++ ~eq2(){cleanup_channels_array();}
++
++ eq_error_t set_eq(const freq_grid& fg, filter_type ft) {
++ cleanup_channels_array();
++ channels_.clear();
++ freq_grid_ = fg;
++
++ for(unsigned int i = 0; i < freq_grid_.get_number_of_bands(); i++) {
++ band_freqs b_fres = freq_grid_.get_freqs()[i];
++
++ eq_channel* eq_ch = new eq_channel(ft, sampling_frequency_,
++ b_fres.center_freq, b_fres.max_freq - b_fres.min_freq);
++
++ channels_.push_back(eq_ch);
++ channels_[i]->set_gain_db(p_eq_default_gain_db);
++ }
++
++ current_eq_type_ = ft;
++ return no_error;
++ }
++
++ eq_error_t set_eq(filter_type ft) {
++ eq_error_t err = set_eq(freq_grid_, ft);
++ return err;
++ }
++
++ eq_error_t set_sample_rate(eq_double_t sr) {
++ sampling_frequency_ = sr;
++ eq_error_t err = set_eq(current_eq_type_);
++ return err;
++ }
++
++ eq_error_t change_gains(std::vector<eq_single_t> band_gains) {
++ if(channels_.size() == band_gains.size())
++ for(unsigned int j = 0; j < channels_.size(); j++)
++ channels_[j]->set_gain_db(conv_.fast_lin_2_db(band_gains[j]));
+ else
+- return invalid_input_data_error;
++ return invalid_input_data_error;
++
++ return no_error;
++ }
++
++ eq_error_t change_gains_db(std::vector<eq_single_t> band_gains) {
++ if(channels_.size() == band_gains.size())
++ for(unsigned int j = 0; j < channels_.size(); j++)
++ channels_[j]->set_gain_db(band_gains[j]);
++ else
++ return invalid_input_data_error;
++
++ return no_error;
++ }
++
++ eq_error_t change_band_gain(unsigned int band_number,
++ eq_single_t band_gain) {
++ if(band_number < channels_.size())
++ channels_[band_number]->set_gain_db(conv_.fast_lin_2_db(band_gain));
++ else
++ return invalid_input_data_error;
+
+- return no_error;
++ return no_error;
+ }
+
+ eq_error_t change_band_gain_db(unsigned int band_number,
+- eq_single_t band_gain) {
+- if(band_number < channels_.size())
+- channels_[band_number]->set_gain_db(band_gain);
+- else
+- return invalid_input_data_error;
++ eq_single_t band_gain) {
++ if(band_number < channels_.size())
++ channels_[band_number]->set_gain_db(band_gain);
++ else
++ return invalid_input_data_error;
+
+- return no_error;
++ return no_error;
+ }
+
+ eq_error_t sbs_process_band(unsigned int band_number,
+- eq_single_t *in, eq_single_t *out) {
+- if(band_number < get_number_of_bands())
+- channels_[band_number]->sbs_process(in, out);
+- else
+- return invalid_input_data_error;
+-
+- return no_error;
+- }
++ eq_single_t *in, eq_single_t *out) {
++ if(band_number < get_number_of_bands())
++ channels_[band_number]->sbs_process(in, out);
++ else
++ return invalid_input_data_error;
++
++ return no_error;
++ }
+
+ eq_error_t sbs_process(eq_single_t *in, eq_single_t *out) {
+- eq_error_t err = no_error;
+- eq_single_t in_out = *in;
+- for(unsigned int i = 0; i < get_number_of_bands(); i++)
+- err = sbs_process_band(i,&in_out,&in_out);
+-
+- *out = in_out;
+-
+- return err;
+- }
+-
+- filter_type get_eq_type(){return current_eq_type_;}
+- const char* get_string_eq_type(){return get_eq_text(current_eq_type_);}
+- unsigned int get_number_of_bands() {
+- return freq_grid_.get_number_of_bands();
+- }
+- const char* get_version(){return eq_version;}
++ eq_error_t err = no_error;
++ eq_single_t in_out = *in;
++ for(unsigned int i = 0; i < get_number_of_bands(); i++)
++ err = sbs_process_band(i,&in_out,&in_out);
++
++ *out = in_out;
++
++ return err;
++ }
++
++ filter_type get_eq_type(){return current_eq_type_;}
++ const char* get_string_eq_type(){return get_eq_text(current_eq_type_);}
++ unsigned int get_number_of_bands() {
++ return freq_grid_.get_number_of_bands();
++ }
++ const char* get_version(){return eq_version;}
+ };
+
+ } //namespace orfanidis_eq
+--- a/src/gui_controls.cpp
++++ b/src/gui_controls.cpp
+@@ -1110,9 +1110,10 @@
+ g_signal_connect(GTK_OBJECT(widget), "file-set", G_CALLBACK(filechooser_value_changed), (gpointer)this);
+ if (attribs.count("width"))
+ gtk_widget_set_size_request (widget, get_int("width", 200), -1);
+- if (attribs.count("width_chars"))
+- gtk_file_chooser_button_set_width_chars (filechooser, get_int("width_chars"));
+- gtk_widget_set_name(GTK_WIDGET(widget), "Calf-FileButton");
++ if (attribs.count("width_chars")) {
++ gtk_file_chooser_button_set_width_chars (filechooser, get_int("width_chars"));
++ gtk_widget_set_name(GTK_WIDGET(widget), "Calf-FileButton");
++ }
+ return widget;
+ }
+
+--- a/src/host_session.cpp
++++ b/src/host_session.cpp
+@@ -143,10 +143,12 @@
+ void host_session::handle_jack_session_event(jack_session_event_t *event)
+ {
+ try {
+- asprintf(&event->command_line, "%s --load ${SESSION_DIR}" G_DIR_SEPARATOR_S "rack.xml --session-id %s" , calfjackhost_cmd.c_str(), event->client_uuid);
+- string fn = event->session_dir;
+- fn += "rack.xml";
+- save_file(fn.c_str());
++ int size = asprintf(&event->command_line, "%s --load ${SESSION_DIR}" G_DIR_SEPARATOR_S "rack.xml --session-id %s" , calfjackhost_cmd.c_str(), event->client_uuid);
++ if (size > -1) {
++ string fn = event->session_dir;
++ fn += "rack.xml";
++ save_file(fn.c_str());
++ }
+ }
+ catch(...)
+ {
+--- a/src/modules_delay.cpp
++++ b/src/modules_delay.cpp
+@@ -385,9 +385,10 @@
+ while(offset < end) {
+ outs[0][offset] = ins[0][offset];
+ buffer[w_ptr] = ins[0][offset];
+- if (stereo)
++ if (stereo) {
+ outs[1][offset] = ins[1][offset];
+ buffer[w_ptr + 1] = ins[1][offset];
++ }
+ w_ptr = (w_ptr + 2) & b_mask;
+ ++offset;
+ }
+--- a/src/modules_limit.cpp
++++ b/src/modules_limit.cpp
+@@ -429,7 +429,7 @@
+ }
+
+ // write multiband coefficient to buffer
+- buffer[pos] = std::min(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR)), 1.0f);
++ buffer[pos] = std::min((float)(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR))), 1.0f);
+
+ // step forward in multiband buffer
+ pos = (pos + channels) % buffer_size;
+@@ -811,7 +811,7 @@
+ }
+
+ // write multiband coefficient to buffer
+- buffer[pos] = std::min(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR)), 1.0f);
++ buffer[pos] = std::min((float)(*params[param_limit] / std::max(fabs(tmpL), fabs(tmpR))), 1.0f);
+
+ // step forward in multiband buffer
+ pos = (pos + channels) % buffer_size;
diff --git a/debian/patches/series b/debian/patches/series
index 183388d..faf326c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,5 +1,6 @@
020160503~413bd43.patch
+020160718~784c842.patch
+020161210~f392c59.patch
1001_use_autoconf_dirnames.patch
1002-lv2core_to_lv2.patch
2001_use_colorbox.patch
-3001_gcc6_transition_fixes.patch
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list