From 25210264dd2e3bf14f49f2c8948f3935ffe28931 Mon Sep 17 00:00:00 2001 From: Marek Blok <Marek.Blok@pg.edu.pl> Date: Thu, 18 Nov 2021 22:41:29 +0100 Subject: [PATCH] sound_input example upgrade --- examples/DSPE_examples.h | 2 +- examples/sound_input.cpp | 18 +++++++++++++----- src/Main.cpp | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/DSPE_examples.h b/examples/DSPE_examples.h index 5bd1f3c..bbaa0df 100644 --- a/examples/DSPE_examples.h +++ b/examples/DSPE_examples.h @@ -9,7 +9,7 @@ #define EXAMPLES_DSPE_EXAMPLES_H_ int test_hello(void); -int test_sound_input(void); +int test_sound_input(bool use_audio_output = true); #endif /* EXAMPLES_DSPE_EXAMPLES_H_ */ diff --git a/examples/sound_input.cpp b/examples/sound_input.cpp index d25e396..da1364f 100644 --- a/examples/sound_input.cpp +++ b/examples/sound_input.cpp @@ -7,11 +7,14 @@ #ifndef INCLUDE_DSPE_EXAMPLES int main(void) +{ + bool use_audio_output = true; #else #include "DSPE_examples.h" -int test_sound_input(void) -#endif // INCLUDE_DSPE_EXAMPLES +int test_sound_input(bool use_audio_output) { +#endif // INCLUDE_DSPE_EXAMPLES + DSP::Clock_ptr MasterClock, AudioInClock; string tekst; int temp; @@ -33,9 +36,13 @@ int test_sound_input(void) Fp = WaveIn.GetSamplingRate(); - DSP::u::AudioOutput AudioOut(Fp); + std::shared_ptr<DSP::Block> AudioOut = nullptr; + if (use_audio_output == true) + AudioOut.reset(new DSP::u::AudioOutput(Fp)); + else + AudioOut.reset(new DSP::u::Vacuum(1U)); - WaveIn.Output("out") >> AudioOut.Input("in"); + WaveIn.Output("out") >> AudioOut->Input("in"); Fp2 = 8000; long Fp_gcd = DSP::f::gcd(Fp, Fp2); @@ -56,8 +63,9 @@ int test_sound_input(void) DSP::log << "MAIN" << DSP::e::LogMode::second << temp << endl; temp++; } - while (WaveIn.GetBytesRead() != 0); + while ((temp <= 8) || (WaveIn.GetBytesRead() != 0)); + AudioOut.reset(); DSP::Clock::FreeClocks(); DSP::log << DSP::e::LogMode::Error << "MAIN" << DSP::e::LogMode::second << "end" << endl; diff --git a/src/Main.cpp b/src/Main.cpp index eb68ee8..333f240 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2977,7 +2977,8 @@ int main(int argc, char*argv[]) DSP::log << DSP::e::LogMode::Error << "Finished test_hello" << endl; DSP::log << "Starting test_sound_input" << endl; - test_sound_input(); + bool use_audio_output = false; + test_sound_input(use_audio_output); DSP::log << DSP::e::LogMode::Error << "Finished test_sound_input" << endl; #endif // INCLUDE_DSPE_EXAMPLES -- GitLab