diff options
author | marwik15 <marwik15@gmail.com> | 2022-05-06 14:44:58 +0200 |
---|---|---|
committer | marwik15 <marwik15@gmail.com> | 2022-05-06 14:44:58 +0200 |
commit | 437058fc7b990ec5605c4efaa611cb585192a1de (patch) | |
tree | e8fe44b21f66fa52eb9f98b9c2575918ed9fee31 /examples | |
parent | fb6cc0ef009280d83dc9c13669f5a2788d91d4ce (diff) | |
download | hwd-437058fc7b990ec5605c4efaa611cb585192a1de.zip hwd-437058fc7b990ec5605c4efaa611cb585192a1de.tar.gz hwd-437058fc7b990ec5605c4efaa611cb585192a1de.tar.bz2 |
Fixed incorrect sample count generation
Diffstat (limited to 'examples')
-rw-r--r-- | examples/sinewave/sinewave_example.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/sinewave/sinewave_example.cpp b/examples/sinewave/sinewave_example.cpp index 10be073..1815222 100644 --- a/examples/sinewave/sinewave_example.cpp +++ b/examples/sinewave/sinewave_example.cpp @@ -14,13 +14,13 @@ using Clock = std::chrono::high_resolution_clock; int main(int argc, char* argv[]) { std::chrono::milliseconds interval{ 10ms }; - int samples, opt, i = 0; + int samples, opt, i = 1; bool end = false; const std::function infinite = []() {}; const std::function limited = [&end, &i, &samples]() { - if (i > samples) end = true; i++; + if (i > samples) end = true; }; auto generatorGuard = infinite; @@ -33,6 +33,7 @@ int main(int argc, char* argv[]) { break; case 'n': samples = std::stoi(optarg); + if (samples == 0) end = true; generatorGuard = limited; break; default: |