#include "magnitude.hpp"

namespace hr::plugins
{
  magnitude::magnitude(const setup& st) : plugin{ st } 
  { 
  }

  void magnitude::process(fvec_t& base, real_time timestamp)
  {
  }

  void magnitude::process(cvec_t& fft, fvec_t& base, real_time timestamp)
  {
    std::size_t frames = fft.size(); 
    base_t m = 0.f;
    for (std::size_t i = 0; i < frames; ++i) m += fft.m_norm[i];
    m /= frames;

    result::bit b;
    b.m_value.push_back(m);
    b.m_duration = timestamp;

    m_result.set_bit(b);
  }

  result magnitude::get_result()
  {
    return m_result;     
  }
}
