Skip to content

Commit

Permalink
unit generators: LagControl - dynamically allocate buffer for filter …
Browse files Browse the repository at this point in the history
…states

issue reported by James Harkins.

Signed-off-by: Tim Blechmann <tim@klingt.org>
  • Loading branch information
timblechmann committed Jan 2, 2011
1 parent 2af74a6 commit c1aa3c0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions common/Source/plugins/IOUGens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const int kMaxLags = 16;

struct LagControl : public IOUnit
{
float m_b1[kMaxLags];
float m_y1[kMaxLags];
float * m_b1;
float * m_y1;
};


Expand Down Expand Up @@ -354,6 +354,11 @@ void LagControl_Ctor(LagControl* unit)
{
int numChannels = unit->mNumInputs;
float **mapin = unit->mParent->mMapControls + unit->mSpecialIndex;

char * chunk = (char*)RTAlloc(unit->mWorld, numChannels * 2 * sizeof(float));
unit->m_y1 = (float*)chunk;
unit->m_b1 = unit->m_y1 + numChannels;

for (int i=0; i<numChannels; ++i, mapin++) {
unit->m_y1[i] = **mapin;
float lag = ZIN0(i);
Expand All @@ -369,6 +374,11 @@ void LagControl_Ctor(LagControl* unit)
}
}

void LagControl_Dtor(LagControl* unit)
{
RTFree(unit->mWorld, unit->m_y1);
}

//////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef NOVA_SIMD
Expand Down Expand Up @@ -1933,7 +1943,7 @@ PluginLoad(IO)
DefineDtorUnit(OffsetOut);
DefineDtorUnit(LocalIn);
DefineSimpleUnit(XOut);
DefineSimpleUnit(LagControl);
DefineDtorUnit(LagControl);
DefineDtorUnit(AudioControl);
DefineUnit("Control", sizeof(Unit), (UnitCtorFunc)&Control_Ctor, 0, 0);
DefineUnit("TrigControl", sizeof(Unit), (UnitCtorFunc)&TrigControl_Ctor, 0, 0);
Expand Down

0 comments on commit c1aa3c0

Please sign in to comment.