Change the static silent wavetable into a functionThe previous form tripped the leak detector
This commit is contained in:
parent
fbf2785211
commit
9d8bfa5b82
2 changed files with 7 additions and 9 deletions
|
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
|
|
||||||
static WavetableMulti silenceMulti = WavetableMulti::createSilence();
|
|
||||||
|
|
||||||
void WavetableOscillator::init(double sampleRate)
|
void WavetableOscillator::init(double sampleRate)
|
||||||
{
|
{
|
||||||
_sampleInterval = 1.0 / sampleRate;
|
_sampleInterval = 1.0 / sampleRate;
|
||||||
_multi = &silenceMulti;
|
_multi = WavetableMulti::getSilenceWavetable();
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,7 +25,7 @@ void WavetableOscillator::clear()
|
||||||
|
|
||||||
void WavetableOscillator::setWavetable(const WavetableMulti* wave)
|
void WavetableOscillator::setWavetable(const WavetableMulti* wave)
|
||||||
{
|
{
|
||||||
_multi = wave ? wave : &silenceMulti;
|
_multi = wave ? wave : WavetableMulti::getSilenceWavetable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WavetableOscillator::setPhase(float phase)
|
void WavetableOscillator::setPhase(float phase)
|
||||||
|
|
@ -252,12 +250,12 @@ WavetableMulti WavetableMulti::createForHarmonicProfile(
|
||||||
return wm;
|
return wm;
|
||||||
}
|
}
|
||||||
|
|
||||||
WavetableMulti WavetableMulti::createSilence()
|
WavetableMulti* WavetableMulti::getSilenceWavetable()
|
||||||
{
|
{
|
||||||
WavetableMulti wm;
|
static WavetableMulti wm;
|
||||||
wm.allocateStorage(1);
|
wm.allocateStorage(1);
|
||||||
wm.fillExtra();
|
wm.fillExtra();
|
||||||
return wm;
|
return &wm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WavetableMulti::allocateStorage(unsigned tableSize)
|
void WavetableMulti::allocateStorage(unsigned tableSize)
|
||||||
|
|
|
||||||
|
|
@ -159,8 +159,8 @@ public:
|
||||||
static WavetableMulti createForHarmonicProfile(
|
static WavetableMulti createForHarmonicProfile(
|
||||||
const HarmonicProfile& hp, double amplitude, unsigned tableSize = config::tableSize, double refSampleRate = 44100.0);
|
const HarmonicProfile& hp, double amplitude, unsigned tableSize = config::tableSize, double refSampleRate = 44100.0);
|
||||||
|
|
||||||
// create the tiniest wavetable with null content for use with oscillators
|
// get a tiny silent wavetable with null content for use with oscillators
|
||||||
static WavetableMulti createSilence();
|
static WavetableMulti* getSilenceWavetable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// get a pointer to the beginning of the N-th table
|
// get a pointer to the beginning of the N-th table
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue