2020-06-13 10:56:20 +02:00
|
|
|
//
|
|
|
|
// Created by versustune on 08.06.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "WaveTableGenerator.h"
|
|
|
|
#include "../../Utils/Logger.h"
|
|
|
|
#include "TableHelper.h"
|
|
|
|
|
2020-06-13 16:52:16 +02:00
|
|
|
void generateSaw (WaveTableGroup* group)
|
|
|
|
{
|
|
|
|
if (group == nullptr)
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
int tableLen = findTableLen ();
|
2020-06-13 10:56:20 +02:00
|
|
|
int idx;
|
2020-06-13 16:52:16 +02:00
|
|
|
auto* freqWaveRe = new double[tableLen];
|
|
|
|
auto* freqWaveIm = new double[tableLen];
|
|
|
|
for (idx = 0; idx < tableLen; idx++)
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
freqWaveIm[idx] = 0.0;
|
|
|
|
}
|
|
|
|
freqWaveRe[0] = freqWaveRe[tableLen >> 1] = 0.0;
|
2020-06-13 16:52:16 +02:00
|
|
|
for (idx = 1; idx < (tableLen >> 1); idx++)
|
|
|
|
{
|
2020-06-13 10:56:20 +02:00
|
|
|
freqWaveRe[idx] = 1.0 / idx; // sawtooth spectrum
|
|
|
|
freqWaveRe[tableLen - idx] = -freqWaveRe[idx]; // mirror
|
|
|
|
}
|
2020-06-13 16:52:16 +02:00
|
|
|
fillTables (group, freqWaveRe, freqWaveIm, tableLen);
|
|
|
|
VeNo::Logger::infoDebugMessage ("Generated clean Saw Wave");
|
2020-06-13 10:56:20 +02:00
|
|
|
}
|