Skip to content

Commit

Permalink
Merge pull request #2 from jamesb93/progress-output
Browse files Browse the repository at this point in the history
Progress output
  • Loading branch information
weefuzzy authored Sep 5, 2020
2 parents 5b49c0a + e5ea3e7 commit 15739cd
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 19 deletions.
37 changes: 33 additions & 4 deletions include/FluidCLIWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ under the European Union’s Horizon 2020 research and innovation programme
#include <clients/common/ParameterTypes.hpp>
#include <FluidVersion.hpp>
#include <cctype>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <regex>
#include <string>
#include <thread>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -388,20 +390,45 @@ class CLIWrapper
params.constrainParameterValues();

// Create client after all parameters are set
FluidContext context;
// Create client after all parameters are set
ClientType client(params);
auto result = client.process(context);
Result result;

client.enqueue(params);
result = client.process();

double progress = 0.0; // Variable to store progress

while(result.ok())
{
ProcessState state = client.checkProgress(result);

if (state == ProcessState::kDone || state == ProcessState::kDoneStillProcessing) {
std::cout << '\n';
break;
}
if (state != ProcessState::kDone) {
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;
}
}

if (!result.ok())
{
// Output error

std::cerr << result.message() << "\n";
}
else
{
// Write files

bool allowCSV = true;
params.template forEachParamType<BufferT, WriteFiles>(allowCSV);
}
Expand All @@ -412,3 +439,5 @@ class CLIWrapper

} // namespace client
} // namespace fluid


2 changes: 1 addition & 1 deletion src/fluid-ampgate/fluid-ampgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTAmpGateClient>::run(argc, argv);
return CLIWrapper<NRTThreadedAmpGateClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-ampslice/fluid-ampslice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTAmpSliceClient>::run(argc, argv);
return CLIWrapper<NRTThreadedAmpSliceClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-hpss/fluid-hpss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTHPSSClient>::run(argc, argv);
return CLIWrapper<NRTThreadedHPSSClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-loudness/fluid-loudness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTLoudnessClient>::run(argc, argv);
return CLIWrapper<NRTThreadedLoudnessClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-melbands/fluid-melbands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTMelBandsClient>::run(argc, argv);
return CLIWrapper<NRTThreadedMelBandsClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-mfcc/fluid-mfcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTMFCCClient>::run(argc, argv);
return CLIWrapper<NRTThreadedMFCCClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-nmf/fluid-nmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NMFClient>::run(argc, argv);
return CLIWrapper<NRTThreadedNMFClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-noveltyslice/fluid-noveltyslice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTNoveltySliceClient>::run(argc, argv);
return CLIWrapper<NRTThreadingNoveltySliceClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-onsetslice/fluid-onsetslice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTOnsetSliceClient>::run(argc, argv);
return CLIWrapper<NRTThreadingOnsetSliceClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-pitch/fluid-pitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTPitchClient>::run(argc, argv);
return CLIWrapper<NRTThreadedPitchClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-sines/fluid-sines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTSinesClient>::run(argc, argv);
return CLIWrapper<NRTThreadedSinesClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-spectralshape/fluid-spectralshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTSpectralShapeClient>::run(argc, argv);
return CLIWrapper<NRTThreadedSpectralShapeClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-stats/fluid-stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BufStatsClient>::run(argc, argv);
return CLIWrapper<NRTThreadedBufStatsClient>::run(argc, argv);
}
2 changes: 1 addition & 1 deletion src/fluid-transients/fluid-transients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTTransientsClient>::run(argc, argv);
return CLIWrapper<NRTThreadedTransientsClient>::run(argc, argv);
}
4 changes: 3 additions & 1 deletion src/fluid-transientslice/fluid-transientslice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NRTTransientSliceClient>::run(argc, argv);
// return CLIWrapper<NRTTransientSliceClient>::run(argc, argv);
return CLIWrapper<NRTThreadedTransientSliceClient>::run(argc, argv);

}

0 comments on commit 15739cd

Please sign in to comment.