summaryrefslogtreecommitdiffhomepage
path: root/config.h
blob: 062989d3d4c2719e6b90c7c070d22d80fa6356da (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

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

#include <filesystem>
#include <string>
#include <vector>

// Defaults
static const int CLICK_NOTE = 37;
static const int CLICK_CHANNEL = 4;
extern const char *device;    // playback device
const snd_pcm_sframes_t nframes = 1024;   // ~1/44th sec buffer size
const unsigned int f_sample = 44100;
const int log_lines = 10;
const int default_bpm = 120;
const int pcm_latency_us = 100000;
const int click_latency_frames = 10000;
const int default_mode = 0; // 0 = note, 1 = clock, 2 = internal
const int default_output = 1; // 0 = off, 1 = on
extern std::filesystem::path click_data_filename;

class Config
{
public:
  Config(int argc, char** argv);
  ~Config();

  // signals
  boost::signals2::signal<void(int)> signal_mode;
  boost::signals2::signal<void(int)> signal_channel;
  boost::signals2::signal<void(int)> signal_note;
  boost::signals2::signal<void(int)> signal_bpm;
  boost::signals2::signal<void(int)> signal_output;

  int get_midi_channel() const;
  void set_midi_channel(int channel);

  int get_midi_note() const;
  void set_midi_note(int note);

  int get_bpm() const;
  void set_bpm(int bpm);

  int get_mode() const;
  void set_mode(int mode);

  int get_output() const;
  void set_output(int output);

  void recover();
  void persist();

  std::string get_argv(int i) const;

  std::filesystem::path get_click_data_filename() const;

private:
  std::string get_config_filename() const;

  std::vector<std::string> m_argv;

  int m_midi_channel;
  int m_midi_note;
  int m_bpm;
  int m_mode;
  int m_output;
};