2020-06-13 10:56:20 +02:00
|
|
|
//
|
|
|
|
// Created by versustune on 09.06.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "VenoInstance.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "Utils/Logger.h"
|
|
|
|
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<VenoInstance>> VenoInstance::instances;
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
VenoInstance::VenoInstance (std::string id)
|
|
|
|
{
|
|
|
|
m_id = std::move (id);
|
|
|
|
m_synthInstance = std::make_shared<SynthInstance> (id);
|
|
|
|
audioBuffer = std::make_shared<VenoBuffer> ();
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
VenoInstance::~VenoInstance ()
|
|
|
|
{
|
|
|
|
m_synthInstance.reset ();
|
|
|
|
audioBuffer.reset ();
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
std::shared_ptr<VenoInstance> VenoInstance::createInstance (const std::string& id)
|
|
|
|
{
|
|
|
|
auto instance = std::make_shared<VenoInstance> (id);
|
|
|
|
instances.insert (std::pair<std::string, std::shared_ptr<VenoInstance>> (id, instance));
|
|
|
|
VeNo::Logger::debugMessage ("Created VenoInstance with id: " + id);
|
2020-06-13 10:56:20 +02:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
// will return the instance or a empty new on... can find out because the id is fucked!
|
2020-06-13 16:52:16 +02:00
|
|
|
std::shared_ptr<VenoInstance> VenoInstance::getInstance (const std::string& id)
|
|
|
|
{
|
|
|
|
if (instances.find (id) != instances.end ())
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
return instances[id];
|
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
return createInstance (id);
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
const std::shared_ptr<SynthInstance>& VenoInstance::getSynthInstance () const
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
return m_synthInstance;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void VenoInstance::deleteInstance (const std::string& processId)
|
|
|
|
{
|
|
|
|
if (instances.find (processId) != instances.end ())
|
|
|
|
{
|
|
|
|
instances[processId].reset ();
|
|
|
|
instances.erase (processId);
|
|
|
|
VeNo::Logger::debugMessage ("Removed VenoInstance with id: " + processId);
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
|
|
|
}
|