diff --git a/CHANGELOG b/CHANGELOG index af143090f7ce0ca5295c60e6ba7bcc5f52811c1f..75eda990f8975279a78982e23a40dd1437a2415e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,4 @@ TODO:: -- Add example with test of DSP::u::AdjustableDelay - + output difference between standard and cyclic buffer to check if both variants work the same - DSP::u::Zeroinserter => add variant with possibility to define number of inputs SOUND_support_t::get_wave_in_raw_buffer - zastÄ piÄ metodÄ zawierajÄ cÄ konwersjÄ typu, ew. rozbudowaÄ konwersjÄ w DSP::u::AudioInput @@ -12,8 +10,9 @@ TODO:: LAST DONE: CHANGES: -- ver. 0.20.030 <b>2023.11.10</b> Added: +- ver. 0.20.031 <b>2023.11.10</b> Added: - DSP::u::AdjustableDelay - delay block with programaticly controlable delay (betwee 0 and user defined max_delay). + - examples: echo.cpp - added adjustable delay block use. - ver. 0.20.029 <b>2023.11.10</b> Added: - DSP::Block::DefineStandardInputs - DSP::Component::DefineStandardOutputs diff --git a/examples/echo.cpp b/examples/echo.cpp index f4c6342077c620f03a4c8d46e26936580818917c..3f959a95e65c7fc79292950b54230a33f57cdb67 100644 --- a/examples/echo.cpp +++ b/examples/echo.cpp @@ -1,14 +1,14 @@ /*! Simple Digital Signal Processing Engine echo example. * \author Marek Blok * \date 2010.04.26 - * \date updated 2021.01.18 + * \date updated 2023.11.10 */ #include <DSP_lib.h> int main(void) { DSP::Clock_ptr MasterClock; - int temp; + int loop_counter, final_counter; long int Fp; DSP::log.SetLogState(DSP::e::LogState::console | DSP::e::LogState::file); @@ -24,8 +24,10 @@ int main(void) Fp = AudioIn.GetSamplingRate(); DSP::u::Addition Add(2U); - DSP::u::LoopDelay Delay(MasterClock, Fp/2); - Delay.SetName("0.5s"); + DSP::u::AdjustableDelay AdjustableDelay(1*Fp, 0); // delay up to 1 second starting from 0 seconds + AdjustableDelay.SetName("max 1 sec"); + DSP::u::LoopDelay Delay(MasterClock, Fp/80); // basic delay - block needed for digital feedback loop + Delay.SetName("1/80 sec"); DSP::u::Amplifier Scale(0.7); Scale.SetName("0.7"); @@ -33,7 +35,8 @@ int main(void) // Examples of connections AudioIn.Output("out") >> Add.Input("in1"); - Add.Output("out") >> Delay.Input("in"); + Add.Output("out") >> AdjustableDelay.Input("in"); + AdjustableDelay.Output("out") >> Delay.Input("in"); Delay.Output("out") >> Scale.Input("in"); Scale.Output("out") >> Add.Input("in2"); // Note the reversed connection below !!! @@ -42,17 +45,27 @@ int main(void) DSP::Component::CheckInputsOfAllComponents(); DSP::Clock::SchemeToDOTfile(MasterClock, "echo.dot"); - temp=0; + bool use_const_delay = false; // set to true for constant feedback lop delay + unsigned int actual_delay = 0; + loop_counter=0; + final_counter=0; do { - DSP::Clock::Execute(MasterClock, Fp/8); + DSP::Clock::Execute(MasterClock, Fp/16); + if (use_const_delay == true) { + actual_delay = AdjustableDelay.SetDelay(Fp/2); // set new delay - will not get larger then the max_delay setup on block construction + } + else { + actual_delay = AdjustableDelay.SetDelay(loop_counter*Fp/100); // set new delay - will not get larger then the max_delay setup on block construction + } - DSP::log << "MAIN" << DSP::e::LogMode::second << temp << std::endl; + DSP::log << "MAIN" << DSP::e::LogMode::second << final_counter << ": actual_delay=" << actual_delay << " samples." << std::endl; if (AudioIn.GetBytesRead() == 0) - temp++; + final_counter++; + loop_counter++; } - while (temp < 30); + while (final_counter < 30); DSP::Clock::FreeClocks(); DSP::log << "MAIN" << DSP::e::LogMode::second << "end" << std::endl << DSP::e::LogMode::Error << std::endl; diff --git a/src/cpp/DSP_modules.cpp b/src/cpp/DSP_modules.cpp index 08e097f7cd80fc596e5c6d0baa367088661ccfc8..46667728c297f673451c5c09d25a8fa09ff1419f 100644 --- a/src/cpp/DSP_modules.cpp +++ b/src/cpp/DSP_modules.cpp @@ -3631,9 +3631,9 @@ DSP::u::AdjustableDelay::AdjustableDelay(unsigned int max_delay_in, unsigned int std::vector<unsigned int> indexes; if (IsBufferCyclic == true) - SetName("Delay(cyclic)", false); + SetName("AdjustableDelay(cyclic)", false); else - SetName("Delay", false); + SetName("AdjustableDelay", false); if (InputsNo <= 0) InputsNo = 1; @@ -3877,7 +3877,7 @@ void DSP::u::AdjustableDelay::InputExecute_with_cyclic_buffer(INPUT_EXECUTE_ARGS THIS->OutputBlocks[0]->EXECUTE_PTR( THIS->OutputBlocks[0], THIS->OutputBlocks_InputNo[0], - THIS->State[0][THIS->index[current_index]], block); + THIS->State[0][current_index], block); } // update buffer diff --git a/src/include/DSP_lib.h b/src/include/DSP_lib.h index 572213c44dc879ec47c67784151774213cdaa6dc..52cf42b5273dda3c55adc98458d0a35cc67092b3 100644 --- a/src/include/DSP_lib.h +++ b/src/include/DSP_lib.h @@ -11,7 +11,7 @@ #define DSP_VER_MAJOR 0 #define DSP_VER_MINOR 20 -#define DSP_VER_BUILD 30 // !!! without zeroes before, else this will be treated as octal number +#define DSP_VER_BUILD 31 // !!! without zeroes before, else this will be treated as octal number #define DSP_VER_YEAR 2023 #define DSP_VER DSP_VER_MAJOR.DSP_VER_MINOR.DSP_VER_BUILD