Mario Lang:

#include <jack.hpp>

#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>

template<typename... Features>
using AudioAccumulatorSet = boost::accumulators::accumulator_set<
  float, boost::accumulators::features<Features...>
>;

using Count = boost::accumulators::tag::count;
using Max = boost::accumulators::tag::max;
using Min = boost::accumulators::tag::min;
using Mean = boost::accumulators::tag::mean;
using Variance = boost::accumulators::tag::variance;

class Statistics final : public JACK::Client {
  JACK::AudioIn In;
  AudioAccumulatorSet<Count, Max, Mean, Min, Variance> Accumulator;

public:
  Statistics() : JACK::Client("Statistics"), In(createAudioIn("In")) {}
  int process(std::uint32_t FrameCount) override {
    for (auto &Value: In.buffer(FrameCount)) Accumulator(Value);
    return 0;
  }
  auto max() const { return boost::accumulators::max(Accumulator); }
  auto mean() const { return boost::accumulators::mean(Accumulator); }
  auto min() const { return boost::accumulators::min(Accumulator); }
  auto sampleCount() const { return boost::accumulators::count(Accumulator); }
  auto variance() const { return boost::accumulators::variance(Accumulator); }
};


Nice code. But I wonder about one small thing related to C++.
Couldn't these max/mean/etc. methods in the Statististics class
be written shorter like this?:

  auto max() const { return Max(Accumulator); }
  auto mean() const { return Mean(Accumulator); }
  auto min() const { return Min(Accumulator); }
  auto sampleCount() const { return Count(Accumulator); }
  auto variance() const { return Variance(Accumulator); }


Sorry if it's a stupid question, but I haven't used "using" in C++ yet. :-)

Also thanks for demonstrating these things from boost.