From: Alexander Schmidt Date: Mon, 22 Feb 2021 17:15:45 +0000 (+0100) Subject: place plucks at random positions X-Git-Url: http://git.treefish.org/~alex/seamulator.git/commitdiff_plain/22a843aa7b0ca3d8f307ba5c0a27ea9d6da50c00?ds=inline place plucks at random positions --- diff --git a/src/synthesizer.cpp b/src/synthesizer.cpp index a4148ce..5943b06 100644 --- a/src/synthesizer.cpp +++ b/src/synthesizer.cpp @@ -55,17 +55,25 @@ Synthesizer::Synthesizer(ConstWaterSurfacePtr surface) : // m_dots.emplace_back( std::make_unique(m_surface->at(i, 0), 440.0) ); //} - m_dots.emplace_back( std::make_unique(m_surface->at(10, 50), 939.85) ); - m_dots.emplace_back( std::make_unique(m_surface->at(20, 40), 704.09) ); - m_dots.emplace_back( std::make_unique(m_surface->at(30, 30), 469.92) ); - m_dots.emplace_back( std::make_unique(m_surface->at(40, 20), 352.04) ); - m_dots.emplace_back( std::make_unique(m_surface->at(50, 10), 279.42) ); - - m_dots.emplace_back( std::make_unique(m_surface->at(50, 10), 1054.94) ); - m_dots.emplace_back( std::make_unique(m_surface->at(40, 20), 704.09) ); - m_dots.emplace_back( std::make_unique(m_surface->at(30, 30), 527.47) ); - m_dots.emplace_back( std::make_unique(m_surface->at(20, 40), 418.65) ); - m_dots.emplace_back( std::make_unique(m_surface->at(10, 50), 313.64) ); + srand (time(NULL)); + + const std::vector frequencies = {939.85, 704.09, 469.92, 352.04, 279.42, 1054.94, 704.09, 527.47, 418.65, 313.64}; + + for (const auto& frequency : frequencies) { + m_dots.emplace_back( std::make_unique(m_surface->at(rand() % m_surface->size(), rand() % m_surface->size()), frequency) ); + } + + // m_dots.emplace_back( std::make_unique(m_surface->at(10, 50), 939.85) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(20, 40), 704.09) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(30, 30), 469.92) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(40, 20), 352.04) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(50, 10), 279.42) ); + + // m_dots.emplace_back( std::make_unique(m_surface->at(50, 10), 1054.94) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(40, 20), 704.09) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(30, 30), 527.47) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(20, 40), 418.65) ); + // m_dots.emplace_back( std::make_unique(m_surface->at(10, 50), 313.64) ); m_audioThread = std::thread( [this]{audioLoop();} );