Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
|
|
@ -1,6 +1,4 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <random>
|
|
||||||
#include "common.h"
|
|
||||||
#include "generators.h"
|
#include "generators.h"
|
||||||
#include "wave.h"
|
#include "wave.h"
|
||||||
|
|
||||||
|
|
@ -86,18 +84,3 @@ sample_table_t gen_isaw()
|
||||||
|
|
||||||
return isaw_vals;
|
return isaw_vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
sample_table_t gen_noise()
|
|
||||||
{
|
|
||||||
// setup RNG for floats in [-1, 1]
|
|
||||||
std::default_random_engine generator;
|
|
||||||
std::uniform_real_distribution<float_t> distribution(-1, 1);
|
|
||||||
sample_table_t noise_vals = {};
|
|
||||||
// Set first and last value to 0
|
|
||||||
noise_vals[0] = 0;
|
|
||||||
noise_vals[DEFAULT_N_SAMPLES - 1] = 0;
|
|
||||||
for (uint16_t i = 1; i < DEFAULT_N_SAMPLES - 1; i++) {
|
|
||||||
noise_vals[i] = distribution(generator);
|
|
||||||
}
|
|
||||||
return noise_vals;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,4 @@ sample_table_t gen_isaw();
|
||||||
*/
|
*/
|
||||||
sample_table_t gen_tri();
|
sample_table_t gen_tri();
|
||||||
|
|
||||||
/*! Generate noise wave data
|
|
||||||
@return a table of values
|
|
||||||
*/
|
|
||||||
sample_table_t gen_noise();
|
|
||||||
|
|
||||||
#endif // GENERATORS_H_
|
#endif // GENERATORS_H_
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,3 @@ TEST(Generator, InverseSawWave) {
|
||||||
// Starts at 1
|
// Starts at 1
|
||||||
EXPECT_EQ(t[0], 1);
|
EXPECT_EQ(t[0], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Generator, NoiseWave)
|
|
||||||
{
|
|
||||||
sample_table_t t = gen_noise();
|
|
||||||
// Always start and end at 0
|
|
||||||
EXPECT_EQ(t[0], 0);
|
|
||||||
EXPECT_EQ(t[DEFAULT_N_SAMPLES - 1], 0);
|
|
||||||
// Check second value, probably not equal to 0
|
|
||||||
EXPECT_NE(t[1], 0);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue