2020-06-08 21:27:17 +02:00
|
|
|
//
|
|
|
|
// Created by versustune on 22.03.20.
|
|
|
|
//
|
|
|
|
#include "AudioConfig.h"
|
2020-06-13 10:56:20 +02:00
|
|
|
#include "../Audio/WaveTable/WaveTableGenerator.h"
|
2020-06-08 21:27:17 +02:00
|
|
|
|
2020-06-13 10:56:20 +02:00
|
|
|
std::shared_ptr<AudioConfig> AudioConfig::m_instance;
|
2020-06-13 16:52:16 +02:00
|
|
|
|
|
|
|
float AudioConfig::getSampleRate ()
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_sampleRate;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void AudioConfig::setSampleRate (float _sampleRate)
|
|
|
|
{
|
|
|
|
if (m_sampleRate != _sampleRate)
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
m_sampleRate = _sampleRate;
|
|
|
|
m_needToReInit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
float AudioConfig::getBufferSize ()
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_bufferSize;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void AudioConfig::setBufferSize (float _bufferSize)
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
m_bufferSize = _bufferSize;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
bool AudioConfig::isNeedToReInit () const
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_needToReInit;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void AudioConfig::setNeedToReInit (bool _needToReInit)
|
|
|
|
{
|
2020-06-08 21:27:17 +02:00
|
|
|
m_needToReInit = _needToReInit;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
std::shared_ptr<AudioConfig> AudioConfig::getInstance ()
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
if (AudioConfig::m_instance == nullptr)
|
2020-06-13 16:52:16 +02:00
|
|
|
AudioConfig::m_instance = std::make_shared<AudioConfig> ();
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_instance;
|
|
|
|
}
|
2020-06-13 10:56:20 +02:00
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void AudioConfig::initWaveTables ()
|
|
|
|
{
|
|
|
|
WaveTableGenerator::getInstance ().init ();
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
AudioConfig::~AudioConfig ()
|
|
|
|
{
|
|
|
|
WaveTableGenerator::getInstance ().cleanTables ();
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|