summaryrefslogtreecommitdiffhomepage
path: root/MIDI.h
blob: 177fd59a3403ddee1f4e781762caac85c7cd325b (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include "config.h"
#include "debug.h"
#include "log.h"

#include <boost/signals2.hpp>

#include <fmt/format.h>

#include <iostream>

class MIDI
{
public:
  MIDI();
  ~MIDI();

  boost::signals2::signal<void(int, int, uint64_t)> signal_note;
  boost::signals2::signal<void()> signal_active_sensing;
  boost::signals2::signal<void()> signal_clock;

  int fd();

  bool event_ready();

  snd_seq_event_t *read(void);

  // returns if click starts
  void process(snd_seq_event_t *ev);

  void flush();

  void wait_for_event();

private:
  snd_seq_t *seq_handle;
  int in_port;
  int npfd;
  struct pollfd* pfd;
};