Move the initialization of BandLimitedWaves into engine.cpp

Since we now provide the wavetables as pre-generated files, there's no delay caused by their initialization
so we can move it to the startup of the software. I thought engine.cpp is the best place for this, it makes
conceptually more sense than main.cpp IMO.
This way each instrument that wants to use them in the future won't have to call the initialization function
separately, making things a bit easier.
This commit is contained in:
Vesa
2014-05-17 23:32:34 +03:00
parent fd89e4c5e6
commit bf54852062
4 changed files with 51 additions and 42 deletions

View File

@@ -30,6 +30,34 @@ WaveMipMap BandLimitedWave::s_waveforms[4] = { };
bool BandLimitedWave::s_wavesGenerated = false;
QString BandLimitedWave::s_wavetableDir = "";
QDataStream& operator<< ( QDataStream &out, WaveMipMap &waveMipMap )
{
for( int tbl = 0; tbl <= MAXTBL; tbl++ )
{
for( int i = 0; i < TLENS[tbl]; i++ )
{
out << waveMipMap.sampleAt( tbl, i );
}
}
return out;
}
QDataStream& operator>> ( QDataStream &in, WaveMipMap &waveMipMap )
{
sample_t sample;
for( int tbl = 0; tbl <= MAXTBL; tbl++ )
{
for( int i = 0; i < TLENS[tbl]; i++ )
{
in >> sample;
waveMipMap.setSampleAt( tbl, i, sample );
}
}
return in;
}
void BandLimitedWave::generateWaves()
{
// don't generate if they already exist

View File

@@ -43,6 +43,7 @@
#include "Plugin.h"
#include "SongEditor.h"
#include "song.h"
#include "BandLimitedWave.h"
bool engine::s_hasGUI = true;
@@ -72,6 +73,9 @@ void engine::init( const bool _has_gui )
{
s_hasGUI = _has_gui;
// generate (load from file) bandlimited wavetables
BandLimitedWave::generateWaves();
initPluginFileHandling();
s_projectJournal = new ProjectJournal;