Different static ways

This commit is contained in:
Paul Fd 2020-03-16 00:28:57 +01:00
parent d27b7373fc
commit 67451024a5
2 changed files with 35 additions and 18 deletions

View file

@ -275,11 +275,36 @@ void WavetableMulti::fillExtra()
WavetablePool::WavetablePool() WavetablePool::WavetablePool()
: waveSin(WavetableMulti::createForHarmonicProfile(HarmonicProfile::getSine(), config::amplitudeSine)) {
, waveTriangle(WavetableMulti::createForHarmonicProfile(HarmonicProfile::getTriangle(), config::amplitudeTriangle)) getWaveSin();
, waveSaw(WavetableMulti::createForHarmonicProfile(HarmonicProfile::getSaw(), config::amplitudeSaw)) getWaveTriangle();
, waveSquare(WavetableMulti::createForHarmonicProfile(HarmonicProfile::getSquare(), config::amplitudeSquare)) getWaveSaw();
{ } getWaveSquare();
}
const WavetableMulti* WavetablePool::getWaveSin()
{
static auto wave = WavetableMulti::createForHarmonicProfile(
HarmonicProfile::getSine(), config::amplitudeSine);
return &wave;
}
const WavetableMulti* WavetablePool::getWaveTriangle()
{
static auto wave = WavetableMulti::createForHarmonicProfile(
HarmonicProfile::getTriangle(), config::amplitudeTriangle);
return &wave;
}
const WavetableMulti* WavetablePool::getWaveSaw()
{
static auto wave = WavetableMulti::createForHarmonicProfile(
HarmonicProfile::getSaw(), config::amplitudeSaw);
return &wave;
}
const WavetableMulti* WavetablePool::getWaveSquare()
{
static auto wave = WavetableMulti::createForHarmonicProfile(
HarmonicProfile::getSquare(), config::amplitudeSquare);
return &wave;
}
} // namespace sfz } // namespace sfz

View file

@ -183,20 +183,12 @@ private:
* @brief Holds predefined wavetables. * @brief Holds predefined wavetables.
* *
*/ */
class WavetablePool { struct WavetablePool {
public:
WavetablePool(); WavetablePool();
const WavetableMulti* getWaveSin() const { return &waveSin; } static const WavetableMulti* getWaveSin();
const WavetableMulti* getWaveTriangle() const { return &waveTriangle; } static const WavetableMulti* getWaveTriangle();
const WavetableMulti* getWaveSaw() const { return &waveSaw; } static const WavetableMulti* getWaveSaw();
const WavetableMulti* getWaveSquare() const { return &waveSquare; }; static const WavetableMulti* getWaveSquare();
private:
const WavetableMulti waveSin;
const WavetableMulti waveTriangle;
const WavetableMulti waveSaw;
const WavetableMulti waveSquare;
LEAK_DETECTOR(WavetablePool);
}; };
} // namespace sfz } // namespace sfz