Corrected the segfault upon launching
This commit is contained in:
parent
ee42a8925c
commit
7091d997b3
2 changed files with 21 additions and 17 deletions
|
|
@ -22,6 +22,7 @@ public:
|
||||||
{
|
{
|
||||||
for (int i = 0; i < config::numVoices; ++i)
|
for (int i = 0; i < config::numVoices; ++i)
|
||||||
voices.push_back(std::make_unique<Voice>(ccState));
|
voices.push_back(std::make_unique<Voice>(ccState));
|
||||||
|
garbageCollectionThread = std::thread(&Synth::garbageCollection, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Synth()
|
~Synth()
|
||||||
|
|
@ -142,6 +143,20 @@ private:
|
||||||
return freeVoice->get();
|
return freeVoice->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCollection()
|
||||||
|
{
|
||||||
|
while (!threadsShouldQuit) {
|
||||||
|
auto activeVoices { 0 };
|
||||||
|
for (auto& voice : voices) {
|
||||||
|
voice->garbageCollect();
|
||||||
|
if (!voice->isFree())
|
||||||
|
activeVoices++;
|
||||||
|
}
|
||||||
|
DBG("Active voices:" << activeVoices << " | Stray buffers: " << FilePool::getFileBuffers());
|
||||||
|
std::this_thread::sleep_for(1s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool hasGlobal { false };
|
bool hasGlobal { false };
|
||||||
bool hasControl { false };
|
bool hasControl { false };
|
||||||
int numGroups { 0 };
|
int numGroups { 0 };
|
||||||
|
|
@ -174,18 +189,7 @@ private:
|
||||||
std::uniform_real_distribution<float> randomDistribution { 0, 1 };
|
std::uniform_real_distribution<float> randomDistribution { 0, 1 };
|
||||||
|
|
||||||
bool threadsShouldQuit { false };
|
bool threadsShouldQuit { false };
|
||||||
std::thread garbageCollectionThread { [&]() {
|
std::thread garbageCollectionThread;
|
||||||
while (!threadsShouldQuit) {
|
|
||||||
auto activeVoices { 0 };
|
|
||||||
for (auto& voice : voices) {
|
|
||||||
voice->garbageCollect();
|
|
||||||
if (!voice->isFree())
|
|
||||||
activeVoices++;
|
|
||||||
}
|
|
||||||
DBG("Active voices:" << activeVoices << " | Stray buffers: " << FilePool::getFileBuffers());
|
|
||||||
std::this_thread::sleep_for(1s);
|
|
||||||
}
|
|
||||||
} };
|
|
||||||
|
|
||||||
float getUniform()
|
float getUniform()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -217,14 +217,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Region* region;
|
Region* region { nullptr };
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
idle,
|
idle,
|
||||||
playing,
|
playing,
|
||||||
release
|
release
|
||||||
};
|
};
|
||||||
State state;
|
State state { State::idle };
|
||||||
bool noteIsOff { false };
|
bool noteIsOff { false };
|
||||||
|
|
||||||
TriggerType triggerType;
|
TriggerType triggerType;
|
||||||
|
|
@ -237,11 +237,11 @@ private:
|
||||||
float baseGain { 1.0 };
|
float baseGain { 1.0 };
|
||||||
float baseFrequency { 440.0 };
|
float baseFrequency { 440.0 };
|
||||||
|
|
||||||
uint32_t sourcePosition;
|
uint32_t sourcePosition { 0 };
|
||||||
uint32_t initialDelay;
|
uint32_t initialDelay { 0 };
|
||||||
|
|
||||||
std::atomic<bool> dataReady { false };
|
std::atomic<bool> dataReady { false };
|
||||||
std::unique_ptr<StereoBuffer<float>, std::function<void(StereoBuffer<float>*)>> fileData;
|
std::unique_ptr<StereoBuffer<float>, std::function<void(StereoBuffer<float>*)>> fileData { nullptr };
|
||||||
|
|
||||||
Buffer<float> tempBuffer1;
|
Buffer<float> tempBuffer1;
|
||||||
Buffer<float> tempBuffer2;
|
Buffer<float> tempBuffer2;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue