summaryrefslogtreecommitdiffhomepage
path: root/BPMDetect.h
blob: 7cd926e4d1d4f3a17eaf8bce39de6205cc3e9cc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include <boost/signals2.hpp>

#include <chrono>
#include <deque>

class BPMDetect
{
public:
  BPMDetect(int divider);
  void receive_event();

  // signal
  boost::signals2::signal<void(int)> signal_bpm;

private:
  using clock_type = std::chrono::high_resolution_clock;
  using time_point = std::chrono::time_point<clock_type>;

  const int m_divider;

  int m_count;

  std::deque<time_point> m_timestamps;
};