Cleaned up the random generation in Synth
This commit is contained in:
parent
c151edaedf
commit
b167625416
1 changed files with 4 additions and 12 deletions
|
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
void noteOn(int delay, int channel, int noteNumber, uint8_t velocity)
|
void noteOn(int delay, int channel, int noteNumber, uint8_t velocity)
|
||||||
{
|
{
|
||||||
auto randValue = getUniform();
|
auto randValue = randNoteDistribution(Random::randomGenerator);
|
||||||
|
|
||||||
for (auto& region : regions) {
|
for (auto& region : regions) {
|
||||||
if (region->registerNoteOn(channel, noteNumber, velocity, randValue)) {
|
if (region->registerNoteOn(channel, noteNumber, velocity, randValue)) {
|
||||||
|
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
void noteOff(int delay, int channel, int noteNumber, uint8_t velocity)
|
void noteOff(int delay, int channel, int noteNumber, uint8_t velocity)
|
||||||
{
|
{
|
||||||
auto randValue = getUniform();
|
auto randValue = randNoteDistribution(Random::randomGenerator);
|
||||||
for (auto& voice : voices)
|
for (auto& voice : voices)
|
||||||
voice->registerNoteOff(delay, channel, noteNumber, velocity);
|
voice->registerNoteOff(delay, channel, noteNumber, velocity);
|
||||||
|
|
||||||
|
|
@ -187,16 +187,8 @@ private:
|
||||||
float sampleRate { config::defaultSampleRate };
|
float sampleRate { config::defaultSampleRate };
|
||||||
std::random_device rd {};
|
std::random_device rd {};
|
||||||
std::mt19937 randomGenerator { rd() };
|
std::mt19937 randomGenerator { rd() };
|
||||||
std::uniform_real_distribution<float> randomDistribution { 0, 1 };
|
std::uniform_real_distribution<float> randNoteDistribution { 0, 1 };
|
||||||
|
|
||||||
bool threadsShouldQuit { false };
|
|
||||||
std::thread garbageCollectionThread;
|
|
||||||
|
|
||||||
float getUniform()
|
|
||||||
{
|
|
||||||
return randomDistribution(randomGenerator);
|
|
||||||
}
|
|
||||||
|
|
||||||
LEAK_DETECTOR(Synth);
|
LEAK_DETECTOR(Synth);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue