diff --git a/scripts/add-user-to-audio-group.sh b/scripts/add-user-to-audio-group.sh new file mode 100755 index 0000000..59ccb2a --- /dev/null +++ b/scripts/add-user-to-audio-group.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +set -eux + +usermod -a -G audio $(whoami) \ No newline at end of file diff --git a/src/code.cpp b/src/code.cpp index f0b6749..3133893 100644 --- a/src/code.cpp +++ b/src/code.cpp @@ -3,7 +3,6 @@ #include #include #include -#include namespace SELCAL { diff --git a/src/main.cpp b/src/main.cpp index 6de93f9..3c0eea7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,8 @@ #include #include "midi.h" #include +#include +#include #include #include @@ -14,6 +16,7 @@ constexpr int ALL_CHANNELS = -1; constexpr double DEFAULT_TONE_DURATION = 1.0; constexpr double DEFAULT_SILENCE_DURATION = 0.2; +static auto logger = log4cxx::Logger::getLogger("tone-generator"); /** * The MIDI format only has a fixed number of notes it can play - 128 individual frequencies. @@ -42,6 +45,9 @@ Tuning getSelcalTunings() { int main(int argc, char** argv) { + // Required to be up front before any logging occurs. + log4cxx::BasicConfigurator::configure(); + double toneDuration = DEFAULT_TONE_DURATION; double silenceDuration = DEFAULT_SILENCE_DURATION; bool listInstruments = false; @@ -88,13 +94,13 @@ int main(int argc, char** argv) { auto tunings = getSelcalTunings(); if (!synth.setTuning(tunings)) { - std::cerr << "Failed to set SELCAL tuning on synth" << std::endl; + LOG4CXX_ERROR(logger, "Failed to set SELCAL tuning on synth"); return 1; } auto files = parser.get>("--soundfont"); for (auto file : files) { - std::cout << "Loading soundfont from " << file << std::endl; + LOG4CXX_INFO(logger, "Loading soundfont from " << file); synth.loadSoundfont(file); } @@ -108,7 +114,7 @@ int main(int argc, char** argv) { else { for (const Synth::Program& program : synth.getPrograms()) { if (program.name == parser.get("--instrument")) { - std::cout << "Loading program " << program.name << std::endl; + LOG4CXX_INFO(logger, "Loading program " << program.name); synth.loadProgram(program); break; }