{
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;
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++) {
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
_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;