From 1539634cd4181d2f2cd7ea79ad173fd044f898f0 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Sat, 8 Aug 2020 17:48:36 +0100 Subject: [PATCH 1/4] add includes for timing and thread sleeping --- include/FluidCLIWrapper.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/FluidCLIWrapper.hpp b/include/FluidCLIWrapper.hpp index dc5e121..8bf20b2 100644 --- a/include/FluidCLIWrapper.hpp +++ b/include/FluidCLIWrapper.hpp @@ -18,10 +18,12 @@ under the European Union’s Horizon 2020 research and innovation programme #include #include #include +#include #include #include #include #include +#include #include #include From 943014be61f6a4822b5d11fbcbcd4b7da7fbefe4 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Sat, 8 Aug 2020 17:48:52 +0100 Subject: [PATCH 2/4] main loop for checking progress --- include/FluidCLIWrapper.hpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/include/FluidCLIWrapper.hpp b/include/FluidCLIWrapper.hpp index 8bf20b2..b1830f6 100644 --- a/include/FluidCLIWrapper.hpp +++ b/include/FluidCLIWrapper.hpp @@ -392,18 +392,34 @@ class CLIWrapper // Create client after all parameters are set FluidContext context; ClientType client(params); - auto result = client.process(context); + Result result; + using namespace std::chrono_literals; + + client.process(); + ProcessState state = client.checkProgress(result); + double progress = 0.0; // Variable to store progress + + while(true) + { + if (state == ProcessState::kDone || state == ProcessState::kDoneStillProcessing) { + break; + } + if (state != ProcessState::kDone) { + if (client.progress() - progress >=1) std::cout << client.progress() << "\n"; + progress = client.progress(); + std::this_thread::sleep_for(20ms); + continue; + } + } if (!result.ok()) { // Output error - std::cerr << result.message() << "\n"; } else { // Write files - bool allowCSV = true; params.template forEachParamType(allowCSV); } From 176c2c5293a9815ae944d47b6279b7ba37aa6463 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Sat, 8 Aug 2020 17:50:17 +0100 Subject: [PATCH 3/4] use the NRTThreaded wrapper --- src/fluid-ampgate/fluid-ampgate.cpp | 2 +- src/fluid-ampslice/fluid-ampslice.cpp | 2 +- src/fluid-hpss/fluid-hpss.cpp | 2 +- src/fluid-loudness/fluid-loudness.cpp | 2 +- src/fluid-melbands/fluid-melbands.cpp | 2 +- src/fluid-mfcc/fluid-mfcc.cpp | 2 +- src/fluid-nmf/fluid-nmf.cpp | 2 +- src/fluid-noveltyslice/fluid-noveltyslice.cpp | 2 +- src/fluid-onsetslice/fluid-onsetslice.cpp | 2 +- src/fluid-pitch/fluid-pitch.cpp | 2 +- src/fluid-sines/fluid-sines.cpp | 2 +- src/fluid-spectralshape/fluid-spectralshape.cpp | 2 +- src/fluid-stats/fluid-stats.cpp | 2 +- src/fluid-transients/fluid-transients.cpp | 2 +- src/fluid-transientslice/fluid-transientslice.cpp | 4 +++- 15 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/fluid-ampgate/fluid-ampgate.cpp b/src/fluid-ampgate/fluid-ampgate.cpp index 2f352fd..7038a51 100644 --- a/src/fluid-ampgate/fluid-ampgate.cpp +++ b/src/fluid-ampgate/fluid-ampgate.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-ampslice/fluid-ampslice.cpp b/src/fluid-ampslice/fluid-ampslice.cpp index 1ea36a6..4cb80e5 100644 --- a/src/fluid-ampslice/fluid-ampslice.cpp +++ b/src/fluid-ampslice/fluid-ampslice.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-hpss/fluid-hpss.cpp b/src/fluid-hpss/fluid-hpss.cpp index bcb222a..7948ac6 100644 --- a/src/fluid-hpss/fluid-hpss.cpp +++ b/src/fluid-hpss/fluid-hpss.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-loudness/fluid-loudness.cpp b/src/fluid-loudness/fluid-loudness.cpp index fb4e377..3613740 100644 --- a/src/fluid-loudness/fluid-loudness.cpp +++ b/src/fluid-loudness/fluid-loudness.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-melbands/fluid-melbands.cpp b/src/fluid-melbands/fluid-melbands.cpp index efee1ca..924cafc 100644 --- a/src/fluid-melbands/fluid-melbands.cpp +++ b/src/fluid-melbands/fluid-melbands.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-mfcc/fluid-mfcc.cpp b/src/fluid-mfcc/fluid-mfcc.cpp index 626a192..a3db83c 100644 --- a/src/fluid-mfcc/fluid-mfcc.cpp +++ b/src/fluid-mfcc/fluid-mfcc.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-nmf/fluid-nmf.cpp b/src/fluid-nmf/fluid-nmf.cpp index e4df212..46bdee4 100644 --- a/src/fluid-nmf/fluid-nmf.cpp +++ b/src/fluid-nmf/fluid-nmf.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-noveltyslice/fluid-noveltyslice.cpp b/src/fluid-noveltyslice/fluid-noveltyslice.cpp index f1fbe9c..ac230d6 100644 --- a/src/fluid-noveltyslice/fluid-noveltyslice.cpp +++ b/src/fluid-noveltyslice/fluid-noveltyslice.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-onsetslice/fluid-onsetslice.cpp b/src/fluid-onsetslice/fluid-onsetslice.cpp index ad48680..e86efe8 100644 --- a/src/fluid-onsetslice/fluid-onsetslice.cpp +++ b/src/fluid-onsetslice/fluid-onsetslice.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-pitch/fluid-pitch.cpp b/src/fluid-pitch/fluid-pitch.cpp index 48c3805..95e6238 100644 --- a/src/fluid-pitch/fluid-pitch.cpp +++ b/src/fluid-pitch/fluid-pitch.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-sines/fluid-sines.cpp b/src/fluid-sines/fluid-sines.cpp index 8b30ddb..9103db2 100644 --- a/src/fluid-sines/fluid-sines.cpp +++ b/src/fluid-sines/fluid-sines.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-spectralshape/fluid-spectralshape.cpp b/src/fluid-spectralshape/fluid-spectralshape.cpp index 29ef9e0..72ec0b5 100644 --- a/src/fluid-spectralshape/fluid-spectralshape.cpp +++ b/src/fluid-spectralshape/fluid-spectralshape.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-stats/fluid-stats.cpp b/src/fluid-stats/fluid-stats.cpp index 1ef2e61..a3df25a 100644 --- a/src/fluid-stats/fluid-stats.cpp +++ b/src/fluid-stats/fluid-stats.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-transients/fluid-transients.cpp b/src/fluid-transients/fluid-transients.cpp index 05f9529..b61d682 100644 --- a/src/fluid-transients/fluid-transients.cpp +++ b/src/fluid-transients/fluid-transients.cpp @@ -15,5 +15,5 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); } diff --git a/src/fluid-transientslice/fluid-transientslice.cpp b/src/fluid-transientslice/fluid-transientslice.cpp index 3d8f97a..b76019a 100644 --- a/src/fluid-transientslice/fluid-transientslice.cpp +++ b/src/fluid-transientslice/fluid-transientslice.cpp @@ -15,5 +15,7 @@ under the European Union’s Horizon 2020 research and innovation programme int main(int argc, const char* argv[]) { using namespace fluid::client; - return CLIWrapper::run(argc, argv); + // return CLIWrapper::run(argc, argv); + return CLIWrapper::run(argc, argv); + } From e5ea3e761266ca4ea1c82650d2f9e7b47f243ad6 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Wed, 26 Aug 2020 15:37:12 +0100 Subject: [PATCH 4/4] enqueue the job https://github.com/flucoma/flucoma-cli/issues/1#issuecomment-678764159 --- include/FluidCLIWrapper.hpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/include/FluidCLIWrapper.hpp b/include/FluidCLIWrapper.hpp index b1830f6..2becd8f 100644 --- a/include/FluidCLIWrapper.hpp +++ b/include/FluidCLIWrapper.hpp @@ -390,23 +390,32 @@ class CLIWrapper params.constrainParameterValues(); // Create client after all parameters are set - FluidContext context; + // Create client after all parameters are set ClientType client(params); Result result; - using namespace std::chrono_literals; - client.process(); - ProcessState state = client.checkProgress(result); + client.enqueue(params); + result = client.process(); + double progress = 0.0; // Variable to store progress - while(true) + while(result.ok()) { + ProcessState state = client.checkProgress(result); + if (state == ProcessState::kDone || state == ProcessState::kDoneStillProcessing) { + std::cout << '\n'; break; } if (state != ProcessState::kDone) { - if (client.progress() - progress >=1) std::cout << client.progress() << "\n"; - progress = client.progress(); + double newProgress = client.progress(); + if (newProgress - progress >=0.01) + { + std::cout << newProgress << '\r' << std::flush; + + progress = newProgress; + } + using namespace std::chrono_literals; std::this_thread::sleep_for(20ms); continue; } @@ -430,3 +439,5 @@ class CLIWrapper } // namespace client } // namespace fluid + +