summaryrefslogtreecommitdiffhomepage
path: root/ClockClick.cpp
blob: c9f6938eba9ba04ed7fab4e4b2a8e84549aa85a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "ClockClick.h"

ClockClick::ClockClick(): m_divider(24), m_count{}, m_detect(24)
{
  m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);});
}

// slots
void ClockClick::receive_clock()
{
  m_detect.receive_event();

  // guard by divider
  ++m_count;
  if (m_count < m_divider) {
    return;
  } else {
    m_count = 0;
  }

  signal_click();
}