Removed the garbage collection thread from the synth
This commit is contained in:
parent
4452b2c5f5
commit
c151edaedf
2 changed files with 16 additions and 18 deletions
|
|
@ -23,13 +23,11 @@ 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()
|
||||||
{
|
{
|
||||||
threadsShouldQuit = true;
|
|
||||||
garbageCollectionThread.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadSfzFile(const std::filesystem::path& file) final;
|
bool loadSfzFile(const std::filesystem::path& file) final;
|
||||||
|
|
@ -131,7 +129,21 @@ public:
|
||||||
void pitchWheel(int delay, int channel, int pitch);
|
void pitchWheel(int delay, int channel, int pitch);
|
||||||
void aftertouch(int delay, int channel, uint8_t aftertouch);
|
void aftertouch(int delay, int channel, uint8_t aftertouch);
|
||||||
void tempo(int delay, float secondsPerQuarter);
|
void tempo(int delay, float secondsPerQuarter);
|
||||||
|
void getNumActiveVoices() const
|
||||||
|
{
|
||||||
|
auto activeVoices { 0 };
|
||||||
|
for (const auto& voice : voices) {
|
||||||
|
if (!voice->isFree())
|
||||||
|
activeVoices++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void garbageCollect()
|
||||||
|
{
|
||||||
|
for (auto& voice : voices) {
|
||||||
|
voice->garbageCollect();
|
||||||
|
}
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
void callback(std::string_view header, const std::vector<Opcode>& members) final;
|
void callback(std::string_view header, const std::vector<Opcode>& members) final;
|
||||||
|
|
||||||
|
|
@ -146,20 +158,6 @@ 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(200ms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasGlobal { false };
|
bool hasGlobal { false };
|
||||||
bool hasControl { false };
|
bool hasControl { false };
|
||||||
int numGroups { 0 };
|
int numGroups { 0 };
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
dataReady.store(true);
|
dataReady.store(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFree()
|
bool isFree() const
|
||||||
{
|
{
|
||||||
return (region == nullptr);
|
return (region == nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue