summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-05 22:32:01 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-05 22:32:01 +0100
commit03b28f03c38b35bcc1bbd1ec28a7be17affd3d28 (patch)
treeec70d62bb681b34b7afe50d292fd138e8bc0ff49 /config.cpp
parent88ab4cec9636a3e7b43906e5e7d0f67ac77eb2d6 (diff)
Automatically access click sound file
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/config.cpp b/config.cpp
index 7b5a50a..f8bf89c 100644
--- a/config.cpp
+++ b/config.cpp
@@ -2,9 +2,6 @@
#include "log.h"
-#include <filesystem>
-#include <string>
-
#include <libreichwein/file.h>
#include <libreichwein/stringhelper.h>
@@ -14,12 +11,21 @@
using namespace std::string_literals;
+namespace fs = std::filesystem;
+
const char *device = "default"; // playback device
std::string config_filename = "click.cfg";
-Config::Config()
+fs::path click_data_filename = "media/click.s16le";
+
+Config::Config(int argc, char** argv):
+ m_argv(argc)
{
+ for (int i = 0; i < argc; ++i) {
+ m_argv[i] = argv[i];
+ }
+
recover();
}
@@ -81,7 +87,7 @@ void Config::persist()
Reichwein::File::setFile(get_config_filename(), config);
}
-int Config::get_midi_channel()
+int Config::get_midi_channel() const
{
return m_midi_channel;
}
@@ -92,7 +98,7 @@ void Config::set_midi_channel(int channel)
signal_channel(channel);
}
-int Config::get_midi_note()
+int Config::get_midi_note() const
{
return m_midi_note;
}
@@ -103,7 +109,7 @@ void Config::set_midi_note(int note)
signal_note(note);
}
-int Config::get_bpm()
+int Config::get_bpm() const
{
return m_bpm;
}
@@ -114,7 +120,7 @@ void Config::set_bpm(int bpm)
signal_bpm(bpm);
}
-int Config::get_mode()
+int Config::get_mode() const
{
return m_mode;
}
@@ -125,7 +131,7 @@ void Config::set_mode(int mode)
signal_mode(mode);
}
-int Config::get_output()
+int Config::get_output() const
{
return m_output;
}
@@ -136,7 +142,7 @@ void Config::set_output(int output)
signal_output(output);
}
-std::string Config::get_config_filename()
+std::string Config::get_config_filename() const
{
char* envvar = getenv("HOME");
if (envvar == nullptr || !std::filesystem::exists(envvar)) {
@@ -145,3 +151,13 @@ std::string Config::get_config_filename()
return std::filesystem::path(getenv("HOME")) / ("."s + config_filename);
}
}
+
+std::string Config::get_argv(int i) const
+{
+ return m_argv[i];
+}
+
+std::filesystem::path Config::get_click_data_filename() const
+{
+ return fs::path{m_argv[0]}.parent_path() / click_data_filename;
+}