soundboard/include/config.h

60 lines
991 B
C
Raw Normal View History

2021-12-13 14:48:43 +01:00
#pragma once
#include <cstdint>
#include <string>
#include <vector>
class Config {
public:
Config(const std::string binaryArgument);
2021-12-13 14:48:43 +01:00
~Config();
void load();
2021-12-20 21:59:20 +01:00
void save();
2021-12-13 14:48:43 +01:00
2021-12-14 10:12:24 +01:00
struct AudioConfig {
std::vector<std::string> devices;
2022-04-02 14:45:54 +02:00
float volume;
2021-12-14 10:12:24 +01:00
};
2021-12-19 15:53:57 +01:00
struct SampleConfig {
2021-12-14 10:12:24 +01:00
std::string file;
uint64_t offset;
uint64_t length;
float volume;
2021-12-19 15:53:57 +01:00
bool isValid() const;
};
struct ButtonConfig {
std::string name;
std::string key;
2021-12-22 02:53:03 +01:00
uint8_t width = DEFAULTWIDTH; // default is 6
2021-12-14 10:12:24 +01:00
2021-12-19 15:53:57 +01:00
std::vector<SampleConfig> samples;
2021-12-14 10:12:24 +01:00
bool isValid() const;
2022-02-26 16:00:02 +01:00
const static uint8_t DEFAULTWIDTH;
2021-12-14 10:12:24 +01:00
};
2022-02-26 16:37:01 +01:00
struct ShortcutConfig {
std::string up;
std::string down;
std::string left;
std::string right;
std::string play;
std::string stop;
};
2021-12-13 14:48:43 +01:00
struct RootConfig {
2021-12-14 10:12:24 +01:00
AudioConfig audio;
std::vector<std::vector<ButtonConfig>> buttons;
2021-12-13 14:48:43 +01:00
std::string audioPath;
2022-02-26 16:37:01 +01:00
ShortcutConfig shortcuts;
2021-12-13 14:48:43 +01:00
} rootConfig;
private:
std::string binaryPath;
const std::string file = "soundboard.json";
2021-12-13 14:48:43 +01:00
};