2020-06-13 10:56:20 +02:00
|
|
|
//
|
|
|
|
// Created by versustune on 08.06.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "WaveTableGenerator.h"
|
|
|
|
#include "../../Core/AudioConfig.h"
|
|
|
|
#include "WavesInlcuder.h"
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void WaveTableGenerator::init ()
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
//if the sampleRate changed... the WaveTables are not harmonic Save anymore and are needed to rebuild... pls stay save later!
|
2020-06-13 16:52:16 +02:00
|
|
|
if (AudioConfig::getInstance ()->isNeedToReInit ())
|
|
|
|
{
|
|
|
|
cleanTables ();
|
|
|
|
AudioConfig::getInstance ()->setNeedToReInit (false);
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
if (m_isInit)
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
m_waveTables[WaveForms::SAW] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::SINE] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::SQUARE] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::TRIANGLE] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::wSaw] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::wSQUARE] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::SYNTHONE] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::SYNTHTWO] = new WaveTableGroup ();
|
|
|
|
m_waveTables[WaveForms::VENOX] = new WaveTableGroup ();
|
|
|
|
generateSaw (m_waveTables[WaveForms::SAW]);
|
2020-06-13 10:56:20 +02:00
|
|
|
m_isInit = true;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
WaveTableGroup* WaveTableGenerator::getGroup (int id)
|
|
|
|
{
|
|
|
|
if (!m_isInit)
|
|
|
|
{
|
|
|
|
init ();
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
if (id < 40)
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
return m_waveTables[id];
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void WaveTableGenerator::cleanTables ()
|
|
|
|
{
|
|
|
|
for (auto& m_waveTable : m_waveTables)
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
delete m_waveTable;
|
|
|
|
}
|
|
|
|
m_isInit = false;
|
|
|
|
}
|