Remove _nch member variable.
authorCarl Hetherington <cth@carlh.net>
Sun, 1 Oct 2023 21:51:33 +0000 (23:51 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 1 Oct 2023 21:52:42 +0000 (23:52 +0200)
src/leqm_nrt.cc

index dc630a34935a0daf7b7cbe63e2c76ce897227d78..357d1c98ea1db0add8f4a2a12b0145ee36ca7468 100644 (file)
@@ -58,12 +58,11 @@ class Worker
 {
 public:
        Worker(std::vector<double> buffer, int nsamples, int nch, std::vector<double> const& ir, Sum* sum, std::vector<double> chconf)
-               : _nch(nch)
-               , _ir(ir)
+               : _ir(ir)
                , _sum(sum)
                , _chconf(chconf)
        {
-               _thread = std::thread(std::bind(&Worker::process, this, buffer, nsamples));
+               _thread = std::thread(std::bind(&Worker::process, this, buffer, nsamples, nch));
        }
 
        Worker(Worker& other) = delete;
@@ -82,7 +81,7 @@ public:
 
 
 private:
-       void process(std::vector<double>& buffer, int nsamples)
+       void process(std::vector<double>& buffer, int nsamples, int nch)
        {
                auto accumulate_ch = [](std::vector<double>& ch_accumulator, std::vector<double> const& input_channel, int nsamples) {
                        for (auto i = 0; i < nsamples; i++) {
@@ -115,17 +114,17 @@ private:
                        return squared;
                };
 
-               /* Round-up in case nsamples is not a multiple of _nch */
-               int const frames = (nsamples + _nch - 1) / _nch;
+               /* Round-up in case nsamples is not a multiple of nch */
+               int const frames = (nsamples + nch - 1) / nch;
 
                std::vector<double> ch_sum_accumulator_norm(frames);
                std::vector<double> ch_sum_accumulator_conv(frames);
 
-               for (int ch = 0; ch < _nch; ch++) {
+               for (int ch = 0; ch < nch; ch++) {
 
                        std::vector<double> normalized_buffer(frames);
 
-                       for (int n = ch, m = 0; n < nsamples; n += _nch, m++) {
+                       for (int n = ch, m = 0; n < nsamples; n += nch, m++) {
                                // use this for calibration depending on channel config for ex. chconf[6] = {1.0, 1.0, 1.0, 1.0, 0.707945784, 0.707945784} could be the default for 5.1 soundtracks
                                //so not normalized but calibrated
                                normalized_buffer[m] = buffer[n] * _chconf[ch]; //this scale amplitude according to specified calibration
@@ -139,7 +138,6 @@ private:
                _sum->sum_samples(ch_sum_accumulator_norm, ch_sum_accumulator_conv, frames);
        }
 
-       int _nch;
        std::vector<double> const& _ir;
        Sum* _sum;
        std::vector<double> _chconf;