~alex-marin89/mixxx/fastrewind

« back to all changes in this revision

Viewing changes to mixxx/src/engine/enginefilterblock.cpp

  • Committer: RJ Ryan
  • Date: 2011-04-04 05:35:15 UTC
  • Revision ID: rryan@mit.edu-20110404053515-t2hvnkwa1xdkplft
Fix EnginePregain and EngineFilterBlock to delete all their COs on destruction.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "engine/enginefilterbutterworth8.h"
25
25
#include "sampleutil.h"
26
26
 
 
27
ControlPotmeter* EngineFilterBlock::s_loEqFreq = NULL;
 
28
ControlPotmeter* EngineFilterBlock::s_hiEqFreq = NULL;
 
29
ControlPushButton* EngineFilterBlock::s_lofiEq = NULL;
 
30
 
27
31
EngineFilterBlock::EngineFilterBlock(const char * group)
28
32
{
29
33
    ilowFreq = 0;
38
42
#else
39
43
 
40
44
    //Setup Filter Controls
41
 
    if(ControlObject::getControl(ConfigKey("[Mixer Profile]", "LoEQFrequency")) == NULL)
42
 
    {
43
 
        m_loEqFreq = new ControlPotmeter(ConfigKey("[Mixer Profile]", "LoEQFrequency"), 0., 22040);
44
 
        m_hiEqFreq = new ControlPotmeter(ConfigKey("[Mixer Profile]", "HiEQFrequency"), 0., 22040);
45
 
        m_lofiEq = new ControlPushButton(ConfigKey("[Mixer Profile]", "LoFiEQs"));
46
 
    }
47
 
    else
48
 
    {
49
 
        m_loEqFreq = (ControlPotmeter*) ControlObject::getControl(ConfigKey("[Mixer Profile]", "LoEQFrequency"));
50
 
        m_hiEqFreq = (ControlPotmeter*) ControlObject::getControl(ConfigKey("[Mixer Profile]", "HiEQFrequency"));
51
 
        m_lofiEq = (ControlPushButton*) ControlObject::getControl(ConfigKey("[Mixer Profile]", "LoFiEQs"));
 
45
 
 
46
    if (s_loEqFreq == NULL) {
 
47
        s_loEqFreq = new ControlPotmeter(ConfigKey("[Mixer Profile]", "LoEQFrequency"), 0., 22040);
 
48
        s_hiEqFreq = new ControlPotmeter(ConfigKey("[Mixer Profile]", "HiEQFrequency"), 0., 22040);
 
49
        s_lofiEq = new ControlPushButton(ConfigKey("[Mixer Profile]", "LoFiEQs"));
52
50
    }
53
51
 
54
52
    high = band = low = NULL;
106
104
    delete filterKillMid;
107
105
    delete filterpotHigh;
108
106
    delete filterKillHigh;
 
107
 
 
108
    // Delete and clear these static controls. We need to clear them so that
 
109
    // other instances of EngineFilterBlock won't delete them as well.
 
110
    delete s_loEqFreq;
 
111
    s_loEqFreq = NULL;
 
112
    delete s_hiEqFreq;
 
113
    s_hiEqFreq = NULL;
 
114
    delete s_lofiEq;
 
115
    s_lofiEq = NULL;
109
116
}
110
117
 
111
118
void EngineFilterBlock::setFilters(bool forceSetting)
112
119
{
113
 
    if((ilowFreq != m_loEqFreq->get()) || (ihighFreq != m_hiEqFreq->get()) || (blofi != m_lofiEq->get()) || forceSetting)
 
120
    if((ilowFreq != s_loEqFreq->get()) ||
 
121
       (ihighFreq != s_hiEqFreq->get()) ||
 
122
       (blofi != s_lofiEq->get()) || forceSetting)
114
123
    {
115
124
        delete low;
116
125
        delete band;
117
126
        delete high;
118
 
        ilowFreq = m_loEqFreq->get();
119
 
        ihighFreq = m_hiEqFreq->get();
120
 
        blofi = m_lofiEq->get();
 
127
        ilowFreq = s_loEqFreq->get();
 
128
        ihighFreq = s_hiEqFreq->get();
 
129
        blofi = s_lofiEq->get();
121
130
        if(blofi)
122
131
        {
123
132
            // why is this DJM800 at line ~34 (LOFI ifdef) and just
128
137
        }
129
138
        else
130
139
        {
131
 
            low = new EngineFilterButterworth8(FILTER_LOWPASS, 44100, m_loEqFreq->get());
132
 
            band = new EngineFilterButterworth8(FILTER_BANDPASS, 44100, m_loEqFreq->get(), m_hiEqFreq->get());
133
 
            high = new EngineFilterButterworth8(FILTER_HIGHPASS, 44100, m_hiEqFreq->get());
 
140
            low = new EngineFilterButterworth8(FILTER_LOWPASS, 44100, s_loEqFreq->get());
 
141
            band = new EngineFilterButterworth8(FILTER_BANDPASS, 44100, s_loEqFreq->get(), s_hiEqFreq->get());
 
142
            high = new EngineFilterButterworth8(FILTER_HIGHPASS, 44100, s_hiEqFreq->get());
134
143
        }
135
144
 
136
145
    }