From a31e44b0ef21ac9fccbe9de9c6642a59d30963fd Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Fri, 10 Sep 2021 14:04:24 +0200 Subject: [PATCH] Formatting --- clients/jack_client.cpp | 71 +++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/clients/jack_client.cpp b/clients/jack_client.cpp index 7438e801..63d0da66 100644 --- a/clients/jack_client.cpp +++ b/clients/jack_client.cpp @@ -44,7 +44,6 @@ #include #include - sfz::Sfizz synth; static jack_port_t* midiInputPort; @@ -153,9 +152,9 @@ static void done(int sig) // exit(0); } - -bool load_instrument(const char *fpath) { - const char *importFormat = nullptr; +bool loadInstrument(const char* fpath) +{ + const char* importFormat = nullptr; if (!sfizz_load_or_import_file(synth.handle(), fpath, &importFormat)) { std::cout << "Could not load the instrument file: " << fpath << '\n'; return false; @@ -193,32 +192,35 @@ bool load_instrument(const char *fpath) { return true; } - -std::vector string_tokenize(const std::string& str) { +std::vector stringTokenize(const std::string& str) +{ std::vector tokens; std::string part = ""; - for (size_t i=0; i "; @@ -226,51 +228,45 @@ void cli_thread_proc() { std::getline(std::cin, command); std::size_t pos = command.find(" "); std::string kw = command.substr(0, pos); - std::string args = command.substr(pos+1); - std::vector tokens = string_tokenize(args); + std::string args = command.substr(pos + 1); + std::vector tokens = stringTokenize(args); - if (kw=="load_instrument") { + if (kw == "loadInstrument") { try { std::lock_guard lock { processMutex }; - load_instrument(tokens[0].c_str()); + loadInstrument(tokens[0].c_str()); } catch (...) { std::cout << "ERROR: Can't load instrument!\n"; } - } - else if (kw=="set_oversampling") { + } else if (kw == "set_oversampling") { try { std::lock_guard lock { processMutex }; synth.setOversamplingFactor(stoi(args)); } catch (...) { std::cout << "ERROR: Can't set oversampling!\n"; } - } - else if (kw=="set_preload_size") { + } else if (kw == "set_preload_size") { try { std::lock_guard lock { processMutex }; synth.setPreloadSize(stoi(args)); } catch (...) { std::cout << "ERROR: Can't set preload size!\n"; } - } - else if (kw=="set_voices") { + } else if (kw == "set_voices") { try { std::lock_guard lock { processMutex }; synth.setNumVoices(stoi(args)); } catch (...) { std::cout << "ERROR: Can't set num of voices!\n"; } - } - else if (kw=="quit") { + } else if (kw == "quit") { shouldClose = true; - } - else if (kw.size()>0){ - std::cout << "ERROR: Unknown command '" << kw <<"'!\n"; + } else if (kw.size() > 0) { + std::cout << "ERROR: Unknown command '" << kw << "'!\n"; } } } - ABSL_FLAG(std::string, client_name, "sfizz", "Jack client name"); ABSL_FLAG(std::string, oversampling, "1x", "Internal oversampling factor (value values are x1, x2, x4, x8)"); ABSL_FLAG(uint32_t, preload_size, 8192, "Preloaded size"); @@ -280,10 +276,8 @@ ABSL_FLAG(bool, state, false, "Output the synth state in the jack loop"); int main(int argc, char** argv) { - // std::ios::sync_with_stdio(false); auto arguments = absl::ParseCommandLine(argc, argv); - auto filesToParse = absl::MakeConstSpan(arguments).subspan(1); const std::string clientName = absl::GetFlag(FLAGS_client_name); const std::string oversampling = absl::GetFlag(FLAGS_oversampling); @@ -376,23 +370,22 @@ int main(int argc, char** argv) } if (filesToParse[0]) { - load_instrument(filesToParse[0]); + loadInstrument(filesToParse[0]); } - std::thread cli_thread(cli_thread_proc); + std::thread cli_thread(cliThreadProc); signal(SIGHUP, done); signal(SIGINT, done); signal(SIGTERM, done); signal(SIGQUIT, done); - - while (!shouldClose){ + while (!shouldClose) { if (verboseState) { std::cout << "Active voices: " << synth.getNumActiveVoices() << '\n'; #ifndef NDEBUG - std::cout << "Allocated buffers: " << synth.getAllocatedBuffers() << '\n'; - std::cout << "Total size: " << synth.getAllocatedBytes() << '\n'; + std::cout << "Allocated buffers: " << synth.getAllocatedBuffers() << '\n'; + std::cout << "Total size: " << synth.getAllocatedBytes() << '\n'; #endif } std::this_thread::sleep_for(std::chrono::seconds(1));