Remove naked new[] in: effects framework
This commit is contained in:
parent
692a033968
commit
a4c7d37d3e
|
@ -114,11 +114,6 @@ Effect::Effect()
|
|||
mNumAudioIn = 0;
|
||||
mNumAudioOut = 0;
|
||||
|
||||
mInBuffer = NULL;
|
||||
mOutBuffer = NULL;
|
||||
mInBufPos = NULL;
|
||||
mOutBufPos = NULL;
|
||||
|
||||
mBufferSize = 0;
|
||||
mBlockSize = 0;
|
||||
mNumChannels = 0;
|
||||
|
@ -1290,8 +1285,8 @@ bool Effect::ProcessPass()
|
|||
bool editClipCanMove;
|
||||
gPrefs->Read(wxT("/GUI/EditClipCanMove"), &editClipCanMove, true);
|
||||
|
||||
mInBuffer = NULL;
|
||||
mOutBuffer = NULL;
|
||||
mInBuffer.reset();
|
||||
mOutBuffer.reset();
|
||||
|
||||
ChannelName map[3];
|
||||
|
||||
|
@ -1391,28 +1386,10 @@ bool Effect::ProcessPass()
|
|||
// If the buffer size has changed, then (re)allocate the buffers
|
||||
if (prevBufferSize != mBufferSize)
|
||||
{
|
||||
// Get rid of any previous buffers
|
||||
if (mInBuffer)
|
||||
{
|
||||
for (size_t i = 0; i < mNumAudioIn; i++)
|
||||
{
|
||||
if (mInBuffer[i])
|
||||
{
|
||||
delete [] mInBuffer[i];
|
||||
}
|
||||
}
|
||||
delete [] mInBuffer;
|
||||
delete [] mInBufPos;
|
||||
}
|
||||
|
||||
// Always create the number of input buffers the client expects even if we don't have
|
||||
// the same number of channels.
|
||||
mInBufPos = new float *[mNumAudioIn];
|
||||
mInBuffer = new float *[mNumAudioIn];
|
||||
for (size_t i = 0; i < mNumAudioIn; i++)
|
||||
{
|
||||
mInBuffer[i] = new float[mBufferSize];
|
||||
}
|
||||
mInBufPos.reinit( mNumAudioIn );
|
||||
mInBuffer.reinit( mNumAudioIn, mBufferSize );
|
||||
|
||||
// We won't be using more than the first 2 buffers, so clear the rest (if any)
|
||||
for (size_t i = 2; i < mNumAudioIn; i++)
|
||||
|
@ -1423,42 +1400,24 @@ bool Effect::ProcessPass()
|
|||
}
|
||||
}
|
||||
|
||||
// Get rid of any previous buffers
|
||||
if (mOutBuffer)
|
||||
{
|
||||
for (size_t i = 0; i < mNumAudioOut; i++)
|
||||
{
|
||||
if (mOutBuffer[i])
|
||||
{
|
||||
delete [] mOutBuffer[i];
|
||||
}
|
||||
}
|
||||
delete [] mOutBuffer;
|
||||
delete [] mOutBufPos;
|
||||
}
|
||||
|
||||
// Always create the number of output buffers the client expects even if we don't have
|
||||
// the same number of channels.
|
||||
mOutBufPos = new float *[mNumAudioOut];
|
||||
mOutBuffer = new float *[mNumAudioOut];
|
||||
for (size_t i = 0; i < mNumAudioOut; i++)
|
||||
{
|
||||
// Output buffers get an extra mBlockSize worth to give extra room if
|
||||
// the plugin adds latency
|
||||
mOutBuffer[i] = new float[mBufferSize + mBlockSize];
|
||||
}
|
||||
mOutBufPos.reinit( mNumAudioOut );
|
||||
// Output buffers get an extra mBlockSize worth to give extra room if
|
||||
// the plugin adds latency
|
||||
mOutBuffer.reinit( mNumAudioOut, mBufferSize + mBlockSize );
|
||||
}
|
||||
|
||||
// (Re)Set the input buffer positions
|
||||
for (size_t i = 0; i < mNumAudioIn; i++)
|
||||
{
|
||||
mInBufPos[i] = mInBuffer[i];
|
||||
mInBufPos[i] = mInBuffer[i].get();
|
||||
}
|
||||
|
||||
// (Re)Set the output buffer positions
|
||||
for (size_t i = 0; i < mNumAudioOut; i++)
|
||||
{
|
||||
mOutBufPos[i] = mOutBuffer[i];
|
||||
mOutBufPos[i] = mOutBuffer[i].get();
|
||||
}
|
||||
|
||||
// Clear unused input buffers
|
||||
|
@ -1481,29 +1440,10 @@ bool Effect::ProcessPass()
|
|||
count++;
|
||||
}
|
||||
|
||||
if (mOutBuffer)
|
||||
{
|
||||
for (size_t i = 0; i < mNumAudioOut; i++)
|
||||
{
|
||||
delete [] mOutBuffer[i];
|
||||
}
|
||||
delete [] mOutBuffer;
|
||||
delete [] mOutBufPos;
|
||||
mOutBuffer = NULL;
|
||||
mOutBufPos = NULL;
|
||||
}
|
||||
|
||||
if (mInBuffer)
|
||||
{
|
||||
for (size_t i = 0; i < mNumAudioIn; i++)
|
||||
{
|
||||
delete [] mInBuffer[i];
|
||||
}
|
||||
delete [] mInBuffer;
|
||||
delete [] mInBufPos;
|
||||
mInBuffer = NULL;
|
||||
mInBufPos = NULL;
|
||||
}
|
||||
mOutBuffer.reset();
|
||||
mOutBufPos.reset();
|
||||
mInBuffer.reset();
|
||||
mInBufPos.reset();
|
||||
|
||||
if (bGoodResult && GetType() == EffectTypeGenerate)
|
||||
{
|
||||
|
@ -1598,16 +1538,16 @@ bool Effect::ProcessTrack(int count,
|
|||
limitSampleBufferSize( mBufferSize, inputRemaining );
|
||||
|
||||
// Fill the input buffers
|
||||
left->Get((samplePtr) mInBuffer[0], floatSample, inLeftPos, inputBufferCnt);
|
||||
left->Get((samplePtr) mInBuffer[0].get(), floatSample, inLeftPos, inputBufferCnt);
|
||||
if (right)
|
||||
{
|
||||
right->Get((samplePtr) mInBuffer[1], floatSample, inRightPos, inputBufferCnt);
|
||||
right->Get((samplePtr) mInBuffer[1].get(), floatSample, inRightPos, inputBufferCnt);
|
||||
}
|
||||
|
||||
// Reset the input buffer positions
|
||||
for (size_t i = 0; i < mNumChannels; i++)
|
||||
{
|
||||
mInBufPos[i] = mInBuffer[i];
|
||||
mInBufPos[i] = mInBuffer[i].get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1654,7 +1594,7 @@ bool Effect::ProcessTrack(int count,
|
|||
// Reset the input buffer positions
|
||||
for (size_t i = 0; i < mNumChannels; i++)
|
||||
{
|
||||
mInBufPos[i] = mInBuffer[i];
|
||||
mInBufPos[i] = mInBuffer[i].get();
|
||||
|
||||
// And clear
|
||||
for (size_t j = 0; j < mBlockSize; j++)
|
||||
|
@ -1670,7 +1610,7 @@ bool Effect::ProcessTrack(int count,
|
|||
decltype(curBlockSize) processed;
|
||||
try
|
||||
{
|
||||
processed = ProcessBlock(mInBufPos, mOutBufPos, curBlockSize);
|
||||
processed = ProcessBlock(mInBufPos.get(), mOutBufPos.get(), curBlockSize);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -1745,32 +1685,32 @@ bool Effect::ProcessTrack(int count,
|
|||
if (isProcessor)
|
||||
{
|
||||
// Write them out
|
||||
left->Set((samplePtr) mOutBuffer[0], floatSample, outLeftPos, outputBufferCnt);
|
||||
left->Set((samplePtr) mOutBuffer[0].get(), floatSample, outLeftPos, outputBufferCnt);
|
||||
if (right)
|
||||
{
|
||||
if (chans >= 2)
|
||||
{
|
||||
right->Set((samplePtr) mOutBuffer[1], floatSample, outRightPos, outputBufferCnt);
|
||||
right->Set((samplePtr) mOutBuffer[1].get(), floatSample, outRightPos, outputBufferCnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
right->Set((samplePtr) mOutBuffer[0], floatSample, outRightPos, outputBufferCnt);
|
||||
right->Set((samplePtr) mOutBuffer[0].get(), floatSample, outRightPos, outputBufferCnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isGenerator)
|
||||
{
|
||||
genLeft->Append((samplePtr) mOutBuffer[0], floatSample, outputBufferCnt);
|
||||
genLeft->Append((samplePtr) mOutBuffer[0].get(), floatSample, outputBufferCnt);
|
||||
if (genRight)
|
||||
{
|
||||
genRight->Append((samplePtr) mOutBuffer[1], floatSample, outputBufferCnt);
|
||||
genRight->Append((samplePtr) mOutBuffer[1].get(), floatSample, outputBufferCnt);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the output buffer positions
|
||||
for (size_t i = 0; i < chans; i++)
|
||||
{
|
||||
mOutBufPos[i] = mOutBuffer[i];
|
||||
mOutBufPos[i] = mOutBuffer[i].get();
|
||||
}
|
||||
|
||||
// Bump to the next track position
|
||||
|
@ -1806,25 +1746,25 @@ bool Effect::ProcessTrack(int count,
|
|||
{
|
||||
if (isProcessor)
|
||||
{
|
||||
left->Set((samplePtr) mOutBuffer[0], floatSample, outLeftPos, outputBufferCnt);
|
||||
left->Set((samplePtr) mOutBuffer[0].get(), floatSample, outLeftPos, outputBufferCnt);
|
||||
if (right)
|
||||
{
|
||||
if (chans >= 2)
|
||||
{
|
||||
right->Set((samplePtr) mOutBuffer[1], floatSample, outRightPos, outputBufferCnt);
|
||||
right->Set((samplePtr) mOutBuffer[1].get(), floatSample, outRightPos, outputBufferCnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
right->Set((samplePtr) mOutBuffer[0], floatSample, outRightPos, outputBufferCnt);
|
||||
right->Set((samplePtr) mOutBuffer[0].get(), floatSample, outRightPos, outputBufferCnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isGenerator)
|
||||
{
|
||||
genLeft->Append((samplePtr) mOutBuffer[0], floatSample, outputBufferCnt);
|
||||
genLeft->Append((samplePtr) mOutBuffer[0].get(), floatSample, outputBufferCnt);
|
||||
if (genRight)
|
||||
{
|
||||
genRight->Append((samplePtr) mOutBuffer[1], floatSample, outputBufferCnt);
|
||||
genRight->Append((samplePtr) mOutBuffer[1].get(), floatSample, outputBufferCnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ class wxWindow;
|
|||
#include "audacity/EffectInterface.h"
|
||||
|
||||
#include "../Experimental.h"
|
||||
#include "../SampleFormat.h"
|
||||
#include "../SelectedRegion.h"
|
||||
#include "../Shuttle.h"
|
||||
#include "../Internat.h"
|
||||
|
@ -504,10 +505,10 @@ private:
|
|||
size_t mNumAudioIn;
|
||||
size_t mNumAudioOut;
|
||||
|
||||
float **mInBuffer;
|
||||
float **mOutBuffer;
|
||||
float **mInBufPos;
|
||||
float **mOutBufPos;
|
||||
FloatBuffers mInBuffer, mOutBuffer;
|
||||
|
||||
using Positions = ArrayOf < float* > ; // Array of non-owning pointers into the above
|
||||
Positions mInBufPos, mOutBufPos;
|
||||
|
||||
size_t mBufferSize;
|
||||
size_t mBlockSize;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "../Audacity.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/stopwatch.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
@ -397,6 +398,7 @@ void EffectManager::RealtimeSetEffects(const EffectArray & effects)
|
|||
}
|
||||
}
|
||||
|
||||
// Get rid of the old chain
|
||||
// And install the NEW one
|
||||
mRealtimeEffects = effects;
|
||||
|
||||
|
@ -407,7 +409,7 @@ void EffectManager::RealtimeSetEffects(const EffectArray & effects)
|
|||
|
||||
bool EffectManager::RealtimeIsActive()
|
||||
{
|
||||
return mRealtimeEffects.GetCount() != 0;
|
||||
return mRealtimeEffects.size() != 0;
|
||||
}
|
||||
|
||||
bool EffectManager::RealtimeIsSuspended()
|
||||
|
@ -434,7 +436,7 @@ void EffectManager::RealtimeAddEffect(Effect *effect)
|
|||
}
|
||||
|
||||
// Add to list of active effects
|
||||
mRealtimeEffects.Add(effect);
|
||||
mRealtimeEffects.push_back(effect);
|
||||
|
||||
// Allow RealtimeProcess() to, well, process
|
||||
RealtimeResume();
|
||||
|
@ -452,7 +454,10 @@ void EffectManager::RealtimeRemoveEffect(Effect *effect)
|
|||
}
|
||||
|
||||
// Remove from list of active effects
|
||||
mRealtimeEffects.Remove(effect);
|
||||
auto end = mRealtimeEffects.end();
|
||||
auto found = std::find(mRealtimeEffects.begin(), end, effect);
|
||||
if (found != end)
|
||||
mRealtimeEffects.erase(found);
|
||||
|
||||
// Allow RealtimeProcess() to, well, process
|
||||
RealtimeResume();
|
||||
|
@ -472,10 +477,8 @@ void EffectManager::RealtimeInitialize()
|
|||
mRealtimeActive = true;
|
||||
|
||||
// Tell each effect to get ready for action
|
||||
for (int i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeInitialize();
|
||||
}
|
||||
for (auto e : mRealtimeEffects)
|
||||
e->RealtimeInitialize();
|
||||
|
||||
// Get things moving
|
||||
RealtimeResume();
|
||||
|
@ -483,10 +486,8 @@ void EffectManager::RealtimeInitialize()
|
|||
|
||||
void EffectManager::RealtimeAddProcessor(int group, unsigned chans, float rate)
|
||||
{
|
||||
for (size_t i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeAddProcessor(group, chans, rate);
|
||||
}
|
||||
for (auto e : mRealtimeEffects)
|
||||
e->RealtimeAddProcessor(group, chans, rate);
|
||||
|
||||
mRealtimeChans.push_back(chans);
|
||||
mRealtimeRates.Add(rate);
|
||||
|
@ -501,10 +502,8 @@ void EffectManager::RealtimeFinalize()
|
|||
mRealtimeLatency = 0;
|
||||
|
||||
// Tell each effect to clean up as well
|
||||
for (int i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeFinalize();
|
||||
}
|
||||
for (auto e : mRealtimeEffects)
|
||||
e->RealtimeFinalize();
|
||||
|
||||
// Reset processor parameters
|
||||
mRealtimeChans.clear();
|
||||
|
@ -529,10 +528,8 @@ void EffectManager::RealtimeSuspend()
|
|||
mRealtimeSuspended = true;
|
||||
|
||||
// And make sure the effects don't either
|
||||
for (int i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeSuspend();
|
||||
}
|
||||
for (auto e : mRealtimeEffects)
|
||||
e->RealtimeSuspend();
|
||||
|
||||
mRealtimeLock.Leave();
|
||||
}
|
||||
|
@ -549,10 +546,8 @@ void EffectManager::RealtimeResume()
|
|||
}
|
||||
|
||||
// Tell the effects to get ready for more action
|
||||
for (int i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeResume();
|
||||
}
|
||||
for (auto e : mRealtimeEffects)
|
||||
e->RealtimeResume();
|
||||
|
||||
// And we should too
|
||||
mRealtimeSuspended = false;
|
||||
|
@ -572,12 +567,10 @@ void EffectManager::RealtimeProcessStart()
|
|||
// have been suspended.
|
||||
if (!mRealtimeSuspended)
|
||||
{
|
||||
for (size_t i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
for (auto e : mRealtimeEffects)
|
||||
{
|
||||
if (mRealtimeEffects[i]->IsRealtimeActive())
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeProcessStart();
|
||||
}
|
||||
if (e->IsRealtimeActive())
|
||||
e->RealtimeProcessStart();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,7 +587,7 @@ size_t EffectManager::RealtimeProcess(int group, unsigned chans, float **buffers
|
|||
|
||||
// Can be suspended because of the audio stream being paused or because effects
|
||||
// have been suspended, so allow the samples to pass as-is.
|
||||
if (mRealtimeSuspended || mRealtimeEffects.IsEmpty())
|
||||
if (mRealtimeSuspended || mRealtimeEffects.empty())
|
||||
{
|
||||
mRealtimeLock.Leave();
|
||||
return numSamples;
|
||||
|
@ -619,11 +612,11 @@ size_t EffectManager::RealtimeProcess(int group, unsigned chans, float **buffers
|
|||
// Now call each effect in the chain while swapping buffer pointers to feed the
|
||||
// output of one effect as the input to the next effect
|
||||
size_t called = 0;
|
||||
for (size_t i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
for (auto e : mRealtimeEffects)
|
||||
{
|
||||
if (mRealtimeEffects[i]->IsRealtimeActive())
|
||||
if (e->IsRealtimeActive())
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeProcess(group, chans, ibuf, obuf, numSamples);
|
||||
e->RealtimeProcess(group, chans, ibuf, obuf, numSamples);
|
||||
called++;
|
||||
}
|
||||
|
||||
|
@ -671,12 +664,10 @@ void EffectManager::RealtimeProcessEnd()
|
|||
// have been suspended.
|
||||
if (!mRealtimeSuspended)
|
||||
{
|
||||
for (size_t i = 0, cnt = mRealtimeEffects.GetCount(); i < cnt; i++)
|
||||
for (auto e : mRealtimeEffects)
|
||||
{
|
||||
if (mRealtimeEffects[i]->IsRealtimeActive())
|
||||
{
|
||||
mRealtimeEffects[i]->RealtimeProcessEnd();
|
||||
}
|
||||
if (e->IsRealtimeActive())
|
||||
e->RealtimeProcessEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ effects.
|
|||
|
||||
#include "../Experimental.h"
|
||||
|
||||
#include <vector>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/event.h>
|
||||
|
@ -33,7 +34,7 @@ effects.
|
|||
#include "../PluginManager.h"
|
||||
#include "Effect.h"
|
||||
|
||||
WX_DEFINE_USER_EXPORTED_ARRAY(Effect *, EffectArray, class AUDACITY_DLL_API);
|
||||
using EffectArray = std::vector <Effect*> ;
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(Effect *, EffectMap, class AUDACITY_DLL_API);
|
||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(std::shared_ptr<Effect>, EffectOwnerMap, class AUDACITY_DLL_API);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <wx/access.h>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
|
@ -162,7 +163,7 @@ EffectRack::~EffectRack()
|
|||
{
|
||||
gPrefs->DeleteGroup(wxT("/EffectsRack"));
|
||||
|
||||
for (size_t i = 0, cnt = mEffects.GetCount(); i < cnt; i++)
|
||||
for (size_t i = 0, cnt = mEffects.size(); i < cnt; i++)
|
||||
{
|
||||
if (mFavState[i])
|
||||
{
|
||||
|
@ -177,7 +178,7 @@ EffectRack::~EffectRack()
|
|||
|
||||
void EffectRack::Add(Effect *effect, bool active, bool favorite)
|
||||
{
|
||||
if (mEffects.Index(effect) != wxNOT_FOUND)
|
||||
if (mEffects.end() != std::find(mEffects.begin(), mEffects.end(), effect))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -254,7 +255,7 @@ void EffectRack::Add(Effect *effect, bool active, bool favorite)
|
|||
Fit();
|
||||
Update();
|
||||
|
||||
mEffects.Add(effect);
|
||||
mEffects.push_back(effect);
|
||||
mNumEffects++;
|
||||
|
||||
if (!mTimer.IsRunning())
|
||||
|
@ -289,7 +290,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
|
|||
{
|
||||
AudacityProject *project = GetActiveProject();
|
||||
|
||||
for (size_t i = 0, cnt = mEffects.GetCount(); i < cnt; i++)
|
||||
for (size_t i = 0, cnt = mEffects.size(); i < cnt; i++)
|
||||
{
|
||||
if (mPowerState[i])
|
||||
{
|
||||
|
@ -408,11 +409,11 @@ void EffectRack::OnRemove(wxCommandEvent & evt)
|
|||
return;
|
||||
}
|
||||
|
||||
mEffects.RemoveAt(index);
|
||||
mEffects.erase(mEffects.begin() + index);
|
||||
mPowerState.RemoveAt(index);
|
||||
mFavState.RemoveAt(index);
|
||||
|
||||
if (mEffects.GetCount() == 0)
|
||||
if (mEffects.size() == 0)
|
||||
{
|
||||
if (mTimer.IsRunning())
|
||||
{
|
||||
|
@ -489,8 +490,8 @@ int EffectRack::GetEffectIndex(wxWindow *win)
|
|||
void EffectRack::MoveRowUp(int row)
|
||||
{
|
||||
Effect *effect = mEffects[row];
|
||||
mEffects.RemoveAt(row);
|
||||
mEffects.Insert(effect, row - 1);
|
||||
mEffects.erase(mEffects.begin() + row);
|
||||
mEffects.insert(mEffects.begin() + row - 1, effect);
|
||||
|
||||
int state = mPowerState[row];
|
||||
mPowerState.RemoveAt(row);
|
||||
|
@ -525,11 +526,11 @@ void EffectRack::UpdateActive()
|
|||
|
||||
if (!mBypassing)
|
||||
{
|
||||
for (size_t i = 0, cnt = mEffects.GetCount(); i < cnt; i++)
|
||||
for (size_t i = 0, cnt = mEffects.size(); i < cnt; i++)
|
||||
{
|
||||
if (mPowerState[i])
|
||||
{
|
||||
mActive.Add(mEffects[i]);
|
||||
mActive.push_back(mEffects[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,16 +121,16 @@ bool BlockGenerator::GenerateTrack(WaveTrack *tmp,
|
|||
bool bGoodResult = true;
|
||||
numSamples = track.TimeToLongSamples(GetDuration());
|
||||
decltype(numSamples) i = 0;
|
||||
float *data = new float[tmp->GetMaxBlockSize()];
|
||||
Floats data{ tmp->GetMaxBlockSize() };
|
||||
|
||||
while ((i < numSamples) && bGoodResult) {
|
||||
const auto block =
|
||||
limitSampleBufferSize( tmp->GetBestBlockSize(i), numSamples - i );
|
||||
|
||||
GenerateBlock(data, track, block);
|
||||
GenerateBlock(data.get(), track, block);
|
||||
|
||||
// Add the generated data to the temporary track
|
||||
tmp->Append((samplePtr)data, floatSample, block);
|
||||
tmp->Append((samplePtr)data.get(), floatSample, block);
|
||||
i += block;
|
||||
|
||||
// Update the progress meter
|
||||
|
@ -139,6 +139,5 @@ bool BlockGenerator::GenerateTrack(WaveTrack *tmp,
|
|||
numSamples.as_double()))
|
||||
bGoodResult = false;
|
||||
}
|
||||
delete[] data;
|
||||
return bGoodResult;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue