summaryrefslogtreecommitdiffhomepage
path: root/MIDIPlayer.h
blob: 2b3e99441726cb52b65faf2b1fbe8f45b61f7ded (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
43
44
45
46
47
48
49
#pragma once

#include "AudioPlayer.h"

#include <string>
#include <vector>

#include <boost/process.hpp>
#include <alsa/asoundlib.h>

#include "config.h"

#include <filesystem>

class MIDIPlayer
{
public:
  MIDIPlayer(Config& config);

  void start();

  void stop();

  bool is_playing();

  void set_file(const std::string& filename);

  std::string get_file();

  std::vector<std::string> get_filelist();

  int get_midi_port();

private:
  void init_seq(void);
  void close_seq(void);
  void iterate_ports(void);

  Config& m_config;
  boost::process::child m_child_midiplayer;
  std::filesystem::path m_dir;
  std::string m_file;

  snd_seq_t* m_seq;
  int m_client;

  AudioPlayer m_audio_player;
};