Created
February 28, 2023 18:54
-
-
Save Xenakios/7eabd9580a571a6d1a1b75df11d6c1f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void test_noise_generation() | |
{ | |
std::default_random_engine rng; | |
std::uniform_real_distribution<float> distrib{-1.0f,1.0f}; | |
/* | |
auto gener = [&rng,&distrib]() | |
{ | |
return distrib(rng); | |
}; | |
*/ | |
std::function<float()> gener = [&rng,&distrib]() | |
{ | |
return distrib(rng); | |
}; | |
int lensamples = 60*60*44100; | |
juce::AudioBuffer<float> buf(1,lensamples); | |
auto bufptrs = buf.getArrayOfWritePointers(); | |
double bench_t0 = juce::Time::getMillisecondCounterHiRes(); | |
for (int i=0;i<lensamples;++i) | |
{ | |
bufptrs[0][i] = distrib(rng); | |
} | |
double bench_t1 = juce::Time::getMillisecondCounterHiRes(); | |
std::cout << "bench took " << (bench_t1-bench_t0)/1000.0 << " seconds\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment