diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-05 13:22:34 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-05 13:22:34 +0100 |
commit | 1f8da4902761fc6f6eaf39b8711107c6b48a9c9a (patch) | |
tree | a0a4f0a1c164080fc313fe37cbb5a91f6ce883d1 | |
parent | 770540693fd4a5f9b64c1b2bc8183be3f72ab314 (diff) |
Debian build, colors, config filename
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | UI.cpp | 9 | ||||
-rw-r--r-- | config.cpp | 18 | ||||
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | debian/README.Debian | 5 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/compat | 1 | ||||
-rw-r--r-- | debian/control | 25 | ||||
-rw-r--r-- | debian/copyright | 4 | ||||
-rwxr-xr-x | debian/rules | 4 | ||||
-rw-r--r-- | debian/source/format | 1 |
11 files changed, 80 insertions, 8 deletions
@@ -25,11 +25,23 @@ OBJS=$(SRCS:.cpp=.o) CXXLIBS=$(shell pkg-config --libs alsa) -lreichwein -lfmt CXX=clang++ +ifeq ($(CXXFLAGS),) +CXXFLAGS=-O2 -g +endif + +CXXFLAGS+=-std=c++20 -Wall -Wpedantic +# workaround for Debian dh_dwz: +CXXFLAGS+=-gdwarf-4 + $(TARGET): $(OBJS) $(CXX) $^ -o $@ $(CXXLIBS) %.o: %.cpp - $(CXX) $(CXXFLAGS) -std=c++20 -O2 -g -Wall -Wpedantic -o $@ -c $< + $(CXX) $(CXXFLAGS) -o $@ -c $< + +install: + mkdir -p $(DESTDIR)/usr/bin + cp $(TARGET) $(DESTDIR)/usr/bin clean: rm -f $(TARGET) $(OBJS) @@ -115,13 +115,14 @@ void UI::draw() fmt::text_style editable_color{fg(fmt::color::crimson) | fmt::emphasis::bold}; fmt::text_style value_color{fg(fmt::color::blue) | fmt::emphasis::bold}; + fmt::text_style input_color{fg(fmt::color::green) | fmt::emphasis::bold}; // clear screen std::cout << "\x1B[2J\x1B[H"; //std::cout << std::endl; - std::cout << "- " << fmt::format(editable_color, "{:3}", bpm) << " BPM +" << std::endl; - std::cout << "Mode: "; + std::cout << fmt::format(editable_color, "{:3}", bpm) << " BPM " << fmt::format(input_color, "(+/-)") << std::endl; + std::cout << "Mode " << fmt::format(input_color, "(m)") << ": "; for (int i = 0; i < mode_names.size(); ++i) { if (i == mode) { std::cout << fmt::format(editable_color, " {}", mode_names[i]); @@ -130,9 +131,9 @@ void UI::draw() } } std::cout << std::endl; - std::cout << "MIDI Note: " << fmt::format(editable_color, "{}/{}", channel, note); + std::cout << "MIDI Note " << fmt::format(input_color, "(n)") << ": " << fmt::format(editable_color, "{}/{}", channel, note); std::cout << std::endl; - std::cout << "Audio Output: " << fmt::format(editable_color, "{}", output_names[output]); + std::cout << "Audio Output " << fmt::format(input_color, "(o)") << ": " << fmt::format(editable_color, "{}", output_names[output]); std::cout << std::endl; std::cout << std::endl; std::cout << "Status:" << std::endl; @@ -2,6 +2,9 @@ #include "log.h" +#include <filesystem> +#include <string> + #include <libreichwein/file.h> #include <libreichwein/stringhelper.h> @@ -9,6 +12,8 @@ #include <string> +using namespace std::string_literals; + const char *device = "default"; // playback device std::string config_filename = "click.cfg"; @@ -33,7 +38,7 @@ void Config::recover() m_mode = default_mode; m_output = default_output; - std::string config = Reichwein::File::getFile(config_filename); + std::string config = Reichwein::File::getFile(get_config_filename()); std::vector<std::string> lines = Reichwein::Stringhelper::split(config, "\n"); @@ -73,7 +78,7 @@ void Config::persist() fmt::format("mode={}\n", m_mode) + fmt::format("output={}\n", m_output); - Reichwein::File::setFile(config_filename, config); + Reichwein::File::setFile(get_config_filename(), config); } int Config::get_midi_channel() @@ -131,3 +136,12 @@ void Config::set_output(int output) signal_output(output); } +std::string Config::get_config_filename() +{ + char* envvar = getenv("HOME"); + if (envvar == nullptr || !std::filesystem::exists(envvar)) { + return config_filename; + } else { + return std::filesystem::path(getenv("HOME")) / ("."s + config_filename); + } +} @@ -48,6 +48,8 @@ public: void persist(); private: + std::string get_config_filename(); + int m_midi_channel; int m_midi_note; int m_bpm; diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..311608a --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,5 @@ +Click in Debian +=============== + +Debian package of click - a hardware-software solution for MIDI source - +ALSA PCM click output diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..b5aae84 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +click (1.0) unstable; urgency=medium + + * Initial release. + + -- Roland Reichwein <mail@reichwein.it> Sun, 05 Jan 2025 12:18:45 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +12 diff --git a/debian/control b/debian/control index 92bb565..dd6e5f8 100644 --- a/debian/control +++ b/debian/control @@ -1 +1,24 @@ -Build-Depends: libreichwein-dev, asound-dev, fmt-dev, boost-dev +Source: click +Section: sound +Priority: optional +Maintainer: Roland Reichwein <mail@reichwein.it> +Build-Depends: debhelper, clang, libc++-dev, libreichwein-dev, libasound2-dev, libfmt-dev, libboost-all-dev +Standards-Version: 4.5.0 +Homepage: http://www.reichwein.it/click/ + +Package: click +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Homepage: http://www.reichwein.it/click/ +Description: Software system for MIDI Click + MIDI Click is a combined hardware-software solution to generate an audio + click from MIDI or stand alone. + . + Features: + - Output to ALSA 44.1kHz + - Generation from certain MIDI note + - Generation from MIDI clock + - Internally generated BPM + . + Supported Hardware platforms: + - Raspberry Pi 3 B+ diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..689d2b3 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,4 @@ +Author: Roland Reichwein <mail@reichwein.it>, 2020-2023 + +Both upstream source code and Debian packaging is available +under the conditions of CC0 1.0 Universal diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..2d33f6a --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) |