31  py::class_<Fft> fft(m, 
"Fft");
 
   32  fft.def(py::init<us>());
 
   34    if (dat.ndim() == 1) {
 
   35      return ColToNpy<c>(f.fft(NpyToCol<d, false>(dat)));
 
   36    } 
else if (dat.ndim() == 2) {
 
   37      return MatToNpy<c>(f.fft(NpyToMat<d, false>(dat)));
 
   39      throw rte(
"Invalid dimensions of array");
 
   43    if (dat.ndim() == 1) {
 
   44      return ColToNpy<d>(f.ifft(NpyToCol<c, false>(dat)));
 
   45    } 
else if (dat.ndim() == 2) {
 
   46      return MatToNpy<d>(f.ifft(NpyToMat<c, false>(dat)));
 
   48      throw rte(
"Invalid dimensions of array");
 
   56  py::class_<Window> w(m, 
"Window");
 
   58  py::enum_<Window::WindowType>(w, 
"WindowType")
 
   67  py::class_<Filter, std::shared_ptr<Filter>> filter(m, 
"Filter");
 
   70  py::class_<SeriesBiquad, std::shared_ptr<SeriesBiquad>> sbq(m, 
"SeriesBiquad",
 
   72  sbq.def(py::init([](
dpyarray filter) {
 
   73    return std::make_shared<SeriesBiquad>(NpyToCol<d, false>(filter));
 
   76    vd res = NpyToCol<d, true>(input);
 
   78    return ColToNpy<d>(res);
 
   82  py::class_<BiquadBank, Filter, std::shared_ptr<BiquadBank>> bqb(m,
 
   84  bqb.def(py::init([](
dpyarray coefs) {
 
   85    return std::make_shared<BiquadBank>(NpyToMat<d, false>(coefs));
 
   88    vd gains_arma = NpyToMat<d, false>(gains);
 
   89    return std::make_shared<BiquadBank>(NpyToMat<d, false>(coefs), &gains_arma);
 
   96    vd inout = NpyToCol<d, true>(input);
 
  102  py::class_<PowerSpectra> ps(m, 
"PowerSpectra");
 
  103  ps.def(py::init<const us, const Window::WindowType>());
 
  105    return CubeToNpy<c>(ps.compute(NpyToMat<d, false>(input)));
 
  109  py::class_<AvPowerSpectra> aps(m, 
"AvPowerSpectra");
 
  110  aps.def(py::init<const us, const Window::WindowType, const d, const d>(),
 
  111          py::arg(
"nfft") = 2048,
 
  113          py::arg(
"overlap_percentage") = 50.0, py::arg(
"time_constant") = -1);
 
  116    std::optional<ccube> res;
 
  118      py::gil_scoped_release release;
 
  119      res = aps.compute(NpyToMat<d, false>(timedata));
 
  122    return CubeToNpy<c>(res.value_or(
ccube(0, 0, 0)));
 
  125    ccube est = ps.get_est();
 
  126    return CubeToNpy<c>(est);
 
  129  py::class_<SLM> slm(m, 
"cppSLM");
 
  131  slm.def_static(
"fromBiquads", [](
const d fs, 
const d Lref, 
const us ds,
 
  136  slm.def_static(
"fromBiquads", [](
const d fs, 
const d Lref, 
const us ds,
 
  138                                   py::array_t<d> bandpass) {
 
  140                            NpyToMat<d, false>(bandpass));
 
  144    return MatToNpy<d>(slm.run(NpyToCol<d, false>(in)));
 
  146  slm.def(
"Pm", [](
const SLM &slm) { 
return ColToNpy<d>(slm.Pm); });
 
  147  slm.def(
"Pmax", [](
const SLM &slm) { 
return ColToNpy<d>(slm.Pmax); });
 
  148  slm.def(
"Ppeak", [](
const SLM &slm) { 
return ColToNpy<d>(slm.Ppeak); });
 
  150  slm.def(
"Leq", [](
const SLM &slm) { 
return ColToNpy<d>(slm.Leq()); });
 
  151  slm.def(
"Lmax", [](
const SLM &slm) { 
return ColToNpy<d>(slm.Lmax()); });
 
  152  slm.def(
"Lpeak", [](
const SLM &slm) { 
return ColToNpy<d>(slm.Lpeak()); });
 
 
static SLM fromBiquads(const d fs, const d Lref, const us downsampling_fac, const d tau, const vd &pre_filter_coefs, const dmat &bandpass_coefs)
Convenience function to create a Sound Level meter from Biquad filters only.