Remove some naked new amd delete in: Built-in Effects
This commit is contained in:
parent
52d12c6913
commit
6fec00149b
|
@ -6246,7 +6246,10 @@ void AudacityProject::OnScoreAlign()
|
|||
// that it can be delted by CloseScoreAlignDialog() either here or
|
||||
// if the program is quit by the user while the dialog is up.
|
||||
ScoreAlignParams params;
|
||||
ScoreAlignDialog *dlog = new ScoreAlignDialog(NULL, params);
|
||||
|
||||
// safe because the class maintains a global resource pointer
|
||||
safenew ScoreAlignDialog(params);
|
||||
|
||||
CloseScoreAlignDialog();
|
||||
|
||||
if (params.mStatus != wxID_OK) return;
|
||||
|
|
|
@ -629,8 +629,6 @@ EffectAutoDuckPanel::EffectAutoDuckPanel(wxWindow *parent, EffectAutoDuck *effec
|
|||
|
||||
EffectAutoDuckPanel::~EffectAutoDuckPanel()
|
||||
{
|
||||
if (mBackgroundBitmap)
|
||||
delete mBackgroundBitmap;
|
||||
if(HasCapture())
|
||||
ReleaseMouse();
|
||||
}
|
||||
|
@ -652,9 +650,7 @@ void EffectAutoDuckPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||
if (!mBackgroundBitmap || mBackgroundBitmap->GetWidth() != clientWidth ||
|
||||
mBackgroundBitmap->GetHeight() != clientHeight)
|
||||
{
|
||||
if (mBackgroundBitmap)
|
||||
delete mBackgroundBitmap;
|
||||
mBackgroundBitmap = new wxBitmap(clientWidth, clientHeight);
|
||||
mBackgroundBitmap = std::make_unique<wxBitmap>(clientWidth, clientHeight);
|
||||
}
|
||||
|
||||
wxMemoryDC dc;
|
||||
|
|
|
@ -125,7 +125,7 @@ private:
|
|||
private:
|
||||
wxWindow *mParent;
|
||||
EffectAutoDuck *mEffect;
|
||||
wxBitmap *mBackgroundBitmap;
|
||||
std::unique_ptr<wxBitmap> mBackgroundBitmap;
|
||||
EControlPoint mCurrentControlPoint;
|
||||
wxPoint mControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
|
||||
wxPoint mMoveStartControlPoints[AUTO_DUCK_PANEL_NUM_CONTROL_POINTS];
|
||||
|
|
|
@ -154,14 +154,14 @@ bool EffectChangePitch::LoadFactoryDefaults()
|
|||
|
||||
bool EffectChangePitch::Init()
|
||||
{
|
||||
mSoundTouch = NULL;
|
||||
mSoundTouch.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EffectChangePitch::Process()
|
||||
{
|
||||
mSoundTouch = new SoundTouch();
|
||||
SetTimeWarper(new IdentityTimeWarper());
|
||||
mSoundTouch = std::make_unique<SoundTouch>();
|
||||
SetTimeWarper(std::make_unique<IdentityTimeWarper>());
|
||||
mSoundTouch->setPitchSemiTones((float)(m_dSemitonesChange));
|
||||
#ifdef USE_MIDI
|
||||
// Note: m_dSemitonesChange is private to ChangePitch because it only
|
||||
|
|
|
@ -455,8 +455,8 @@ bool EffectChangeSpeed::TransferDataFromWindow()
|
|||
// the region are shifted along according to how the region size changed.
|
||||
bool EffectChangeSpeed::ProcessLabelTrack(Track *t)
|
||||
{
|
||||
SetTimeWarper(new RegionTimeWarper(mT0, mT1,
|
||||
new LinearTimeWarper(mT0, mT0,
|
||||
SetTimeWarper(std::make_unique<RegionTimeWarper>(mT0, mT1,
|
||||
std::make_unique<LinearTimeWarper>(mT0, mT0,
|
||||
mT1, mT0 + (mT1-mT0)*mFactor)));
|
||||
LabelTrack *lt = (LabelTrack*)t;
|
||||
if (lt == NULL) return false;
|
||||
|
@ -551,7 +551,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
|
|||
double newLength = outputTrack->GetEndTime();
|
||||
if (bResult)
|
||||
{
|
||||
SetTimeWarper(new LinearTimeWarper(mCurT0, mCurT0, mCurT1, mCurT0 + newLength));
|
||||
SetTimeWarper(std::make_unique<LinearTimeWarper>(mCurT0, mCurT0, mCurT1, mCurT0 + newLength));
|
||||
bResult = track->ClearAndPaste(mCurT0, mCurT1, outputTrack.get(), true, false, GetTimeWarper());
|
||||
}
|
||||
|
||||
|
|
|
@ -139,18 +139,18 @@ bool EffectChangeTempo::Init()
|
|||
m_FromLength = mT1 - mT0;
|
||||
m_ToLength = (m_FromLength * 100.0) / (100.0 + m_PercentChange);
|
||||
|
||||
mSoundTouch = NULL;
|
||||
mSoundTouch.reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EffectChangeTempo::Process()
|
||||
{
|
||||
mSoundTouch = new SoundTouch();
|
||||
mSoundTouch = std::make_unique<SoundTouch>();
|
||||
mSoundTouch->setTempoChange(m_PercentChange);
|
||||
double mT1Dashed = mT0 + (mT1 - mT0)/(m_PercentChange/100.0 + 1.0);
|
||||
SetTimeWarper(new RegionTimeWarper(mT0, mT1,
|
||||
new LinearTimeWarper(mT0, mT0, mT1, mT1Dashed )));
|
||||
SetTimeWarper(std::make_unique<RegionTimeWarper>(mT0, mT1,
|
||||
std::make_unique<LinearTimeWarper>(mT0, mT0, mT1, mT1Dashed )));
|
||||
bool success = EffectSoundTouch::Process();
|
||||
if( success )
|
||||
mT1 = mT0 + (mT1 - mT0)/(m_PercentChange/100 + 1.);
|
||||
|
|
|
@ -141,11 +141,6 @@ Effect::~Effect()
|
|||
delete mOutputTracks;
|
||||
}
|
||||
|
||||
if (mWarper != NULL)
|
||||
{
|
||||
delete mWarper;
|
||||
}
|
||||
|
||||
if (mUIDialog)
|
||||
{
|
||||
mUIDialog->Close();
|
||||
|
@ -2055,22 +2050,16 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len)
|
|||
}
|
||||
}
|
||||
|
||||
void Effect::SetTimeWarper(TimeWarper *warper)
|
||||
void Effect::SetTimeWarper(std::unique_ptr<TimeWarper> &&warper)
|
||||
{
|
||||
if (mWarper != NULL)
|
||||
{
|
||||
delete mWarper;
|
||||
mWarper = NULL;
|
||||
}
|
||||
|
||||
wxASSERT(warper != NULL);
|
||||
mWarper = warper;
|
||||
wxASSERT(warper);
|
||||
mWarper = std::move(warper);
|
||||
}
|
||||
|
||||
TimeWarper *Effect::GetTimeWarper()
|
||||
{
|
||||
wxASSERT(mWarper != NULL);
|
||||
return mWarper;
|
||||
wxASSERT(mWarper);
|
||||
return mWarper.get();
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -330,7 +330,7 @@ protected:
|
|||
// Calculates the start time and selection length in samples
|
||||
void GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len);
|
||||
|
||||
void SetTimeWarper(TimeWarper *warper);
|
||||
void SetTimeWarper(std::unique_ptr<TimeWarper> &&warper);
|
||||
TimeWarper *GetTimeWarper();
|
||||
|
||||
// Previewing linear effect can be optimised by pre-mixing. However this
|
||||
|
@ -446,7 +446,7 @@ protected:
|
|||
double mF0;
|
||||
double mF1;
|
||||
#endif
|
||||
TimeWarper *mWarper;
|
||||
std::unique_ptr<TimeWarper> mWarper;
|
||||
wxArrayString mPresetNames;
|
||||
wxArrayString mPresetValues;
|
||||
int mPass;
|
||||
|
|
|
@ -423,9 +423,8 @@ void EffectRack::OnRemove(wxCommandEvent & evt)
|
|||
|
||||
for (int i = 0; i < NUMCOLS; i++)
|
||||
{
|
||||
wxWindow *w = mMainSizer->GetItem(index)->GetWindow();
|
||||
std::unique_ptr<wxWindow> w {mMainSizer->GetItem(index)->GetWindow()};
|
||||
mMainSizer->Detach(index);
|
||||
delete w;
|
||||
}
|
||||
|
||||
mMainSizer->Layout();
|
||||
|
|
|
@ -224,10 +224,6 @@ EffectEqualization::EffectEqualization()
|
|||
|
||||
SetLinearEffectFlag(true);
|
||||
|
||||
#ifdef EXPERIMENTAL_EQ_SSE_THREADED
|
||||
mEffectEqualization48x=NULL;
|
||||
#endif
|
||||
|
||||
mM = DEF_FilterLength;
|
||||
mLin = DEF_InterpLin;
|
||||
mInterp = DEF_InterpMeth;
|
||||
|
@ -243,17 +239,17 @@ EffectEqualization::EffectEqualization()
|
|||
mInterpolations.Add(wxGetTranslation(kInterpStrings[i]));
|
||||
}
|
||||
|
||||
mLogEnvelope = new Envelope();
|
||||
mLogEnvelope = std::make_unique<Envelope>();
|
||||
mLogEnvelope->SetInterpolateDB(false);
|
||||
mLogEnvelope->Mirror(false);
|
||||
mLogEnvelope->SetRange(MIN_dBMin, MAX_dBMax); // MB: this is the highest possible range
|
||||
|
||||
mLinEnvelope = new Envelope();
|
||||
mLinEnvelope = std::make_unique<Envelope>();
|
||||
mLinEnvelope->SetInterpolateDB(false);
|
||||
mLinEnvelope->Mirror(false);
|
||||
mLinEnvelope->SetRange(MIN_dBMin, MAX_dBMax); // MB: this is the highest possible range
|
||||
|
||||
mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope);
|
||||
mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope).get();
|
||||
|
||||
mWindowSize = windowSize;
|
||||
|
||||
|
@ -278,12 +274,9 @@ EffectEqualization::EffectEqualization()
|
|||
bool useSSE;
|
||||
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("/SSE/GUI"), useSSE, false);
|
||||
if(useSSE && !mEffectEqualization48x)
|
||||
mEffectEqualization48x=new EffectEqualization48x;
|
||||
else
|
||||
if(!useSSE && mEffectEqualization48x) {
|
||||
delete mEffectEqualization48x;
|
||||
mEffectEqualization48x=NULL;
|
||||
}
|
||||
mEffectEqualization48x = std::make_unique<EffectEqualization48x>();
|
||||
else if(!useSSE)
|
||||
mEffectEqualization48x.reset();
|
||||
mBench=false;
|
||||
#endif
|
||||
}
|
||||
|
@ -291,13 +284,6 @@ EffectEqualization::EffectEqualization()
|
|||
|
||||
EffectEqualization::~EffectEqualization()
|
||||
{
|
||||
if(mLogEnvelope)
|
||||
delete mLogEnvelope;
|
||||
mLogEnvelope = NULL;
|
||||
if(mLinEnvelope)
|
||||
delete mLinEnvelope;
|
||||
mLinEnvelope = NULL;
|
||||
|
||||
if(hFFT)
|
||||
EndFFT(hFFT);
|
||||
hFFT = NULL;
|
||||
|
@ -310,10 +296,6 @@ EffectEqualization::~EffectEqualization()
|
|||
delete[] mFilterFuncI;
|
||||
mFilterFuncR = NULL;
|
||||
mFilterFuncI = NULL;
|
||||
#ifdef EXPERIMENTAL_EQ_SSE_THREADED
|
||||
if(mEffectEqualization48x)
|
||||
delete mEffectEqualization48x;
|
||||
#endif
|
||||
}
|
||||
|
||||
// IdentInterface implementation
|
||||
|
@ -372,7 +354,7 @@ bool EffectEqualization::SetAutomationParameters(EffectAutomationParameters & pa
|
|||
InterpMeth -= kNumInterpolations;
|
||||
}
|
||||
|
||||
mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope);
|
||||
mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope).get();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -534,7 +516,7 @@ bool EffectEqualization::Init()
|
|||
break;
|
||||
}
|
||||
|
||||
mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope);
|
||||
mEnvelope = (mLin ? mLinEnvelope : mLogEnvelope).get();
|
||||
|
||||
setCurve(mCurveName);
|
||||
|
||||
|
@ -1669,10 +1651,10 @@ void EffectEqualization::setCurve(int currentCurve)
|
|||
int numPoints = (int) mCurves[currentCurve].points.GetCount();
|
||||
|
||||
if (mLin) { // linear freq mode
|
||||
env = mLinEnvelope;
|
||||
env = mLinEnvelope.get();
|
||||
}
|
||||
else { // log freq mode
|
||||
env = mLogEnvelope;
|
||||
env = mLogEnvelope.get();
|
||||
}
|
||||
env->Flatten(0.);
|
||||
env->SetTrackLen(1.0);
|
||||
|
@ -1856,11 +1838,11 @@ void EffectEqualization::EnvelopeUpdated()
|
|||
{
|
||||
if (IsLinear())
|
||||
{
|
||||
EnvelopeUpdated(mLinEnvelope, true);
|
||||
EnvelopeUpdated(mLinEnvelope.get(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnvelopeUpdated(mLogEnvelope, false);
|
||||
EnvelopeUpdated(mLogEnvelope.get(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2205,7 +2187,7 @@ void EffectEqualization::UpdateDraw()
|
|||
if(mLin) // do not use IsLinear() here
|
||||
{
|
||||
EnvLogToLin();
|
||||
mEnvelope = mLinEnvelope;
|
||||
mEnvelope = mLinEnvelope.get();
|
||||
mFreqRuler->ruler.SetLog(false);
|
||||
mFreqRuler->ruler.SetRange(0, mHiFreq);
|
||||
}
|
||||
|
@ -2237,7 +2219,7 @@ void EffectEqualization::UpdateGraphic()
|
|||
}
|
||||
|
||||
EnvLinToLog();
|
||||
mEnvelope = mLogEnvelope;
|
||||
mEnvelope = mLogEnvelope.get();
|
||||
mFreqRuler->ruler.SetLog(true);
|
||||
mFreqRuler->ruler.SetRange(mLoFreq, mHiFreq);
|
||||
}
|
||||
|
@ -2287,7 +2269,7 @@ void EffectEqualization::UpdateGraphic()
|
|||
mUIParent->Fit();
|
||||
}
|
||||
#endif
|
||||
GraphicEQ(mLogEnvelope);
|
||||
GraphicEQ(mLogEnvelope.get());
|
||||
mDrawMode = false;
|
||||
}
|
||||
|
||||
|
@ -2360,7 +2342,7 @@ void EffectEqualization::EnvLinToLog(void)
|
|||
delete [] value;
|
||||
|
||||
if(changed)
|
||||
EnvelopeUpdated(mLogEnvelope, false);
|
||||
EnvelopeUpdated(mLogEnvelope.get(), false);
|
||||
}
|
||||
|
||||
void EffectEqualization::ErrMin(void)
|
||||
|
@ -2379,7 +2361,7 @@ void EffectEqualization::ErrMin(void)
|
|||
testEnvelope.SetRange(-120.0, 60.0);
|
||||
testEnvelope.Flatten(0.);
|
||||
testEnvelope.SetTrackLen(1.0);
|
||||
testEnvelope.CopyFrom(mLogEnvelope, 0.0, 1.0);
|
||||
testEnvelope.CopyFrom(mLogEnvelope.get(), 0.0, 1.0);
|
||||
|
||||
for(i=0; i < NUM_PTS; i++)
|
||||
vals[i] = testEnvelope.GetValue(mWhens[i]);
|
||||
|
@ -2675,7 +2657,7 @@ void EffectEqualization::OnSlider(wxCommandEvent & event)
|
|||
break;
|
||||
}
|
||||
}
|
||||
GraphicEQ(mLogEnvelope);
|
||||
GraphicEQ(mLogEnvelope.get());
|
||||
EnvelopeUpdated();
|
||||
}
|
||||
|
||||
|
@ -2683,7 +2665,7 @@ void EffectEqualization::OnInterp(wxCommandEvent & WXUNUSED(event))
|
|||
{
|
||||
if (mGraphic->GetValue())
|
||||
{
|
||||
GraphicEQ(mLogEnvelope);
|
||||
GraphicEQ(mLogEnvelope.get());
|
||||
EnvelopeUpdated();
|
||||
}
|
||||
mInterp = mInterpChoice->GetSelection();
|
||||
|
@ -2768,7 +2750,7 @@ void EffectEqualization::OnInvert(wxCommandEvent & WXUNUSED(event)) // Inverts a
|
|||
tip.Printf( wxT("%gkHz\n%.1fdB"), kThirdOct[i]/1000., mEQVals[i] );
|
||||
mSliders[i]->SetToolTip(tip);
|
||||
}
|
||||
GraphicEQ(mLogEnvelope);
|
||||
GraphicEQ(mLogEnvelope.get());
|
||||
}
|
||||
else // Draw mode. Invert the points.
|
||||
{
|
||||
|
@ -2835,7 +2817,7 @@ void EffectEqualization::OnLinFreq(wxCommandEvent & WXUNUSED(event))
|
|||
mFreqRuler->ruler.SetLog(false);
|
||||
mFreqRuler->ruler.SetRange(0, mHiFreq);
|
||||
EnvLogToLin();
|
||||
mEnvelope = mLinEnvelope;
|
||||
mEnvelope = mLinEnvelope.get();
|
||||
mLin = true;
|
||||
}
|
||||
else //going from lin to log freq scale
|
||||
|
@ -2843,7 +2825,7 @@ void EffectEqualization::OnLinFreq(wxCommandEvent & WXUNUSED(event))
|
|||
mFreqRuler->ruler.SetLog(true);
|
||||
mFreqRuler->ruler.SetRange(mLoFreq, mHiFreq);
|
||||
EnvLinToLog();
|
||||
mEnvelope = mLogEnvelope;
|
||||
mEnvelope = mLogEnvelope.get();
|
||||
mLin = false;
|
||||
}
|
||||
mFreqRuler->Refresh(false);
|
||||
|
@ -2912,8 +2894,6 @@ EqualizationPanel::EqualizationPanel(EffectEqualization *effect, wxWindow *paren
|
|||
|
||||
EqualizationPanel::~EqualizationPanel()
|
||||
{
|
||||
if (mBitmap)
|
||||
delete mBitmap;
|
||||
if (mOuti)
|
||||
delete [] mOuti;
|
||||
if (mOutr)
|
||||
|
@ -2960,12 +2940,9 @@ void EqualizationPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
|
|||
|
||||
if (!mBitmap || mWidth!=width || mHeight!=height)
|
||||
{
|
||||
if (mBitmap)
|
||||
delete mBitmap;
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mBitmap = new wxBitmap(mWidth, mHeight);
|
||||
mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight);
|
||||
}
|
||||
|
||||
wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
|
|
|
@ -219,13 +219,12 @@ private:
|
|||
|
||||
EQCurveArray mCurves;
|
||||
|
||||
Envelope *mLogEnvelope;
|
||||
Envelope *mLinEnvelope;
|
||||
std::unique_ptr<Envelope> mLogEnvelope, mLinEnvelope;
|
||||
Envelope *mEnvelope;
|
||||
|
||||
#ifdef EXPERIMENTAL_EQ_SSE_THREADED
|
||||
bool mBench;
|
||||
EffectEqualization48x *mEffectEqualization48x;
|
||||
std::unique_ptr<EffectEqualization48x> mEffectEqualization48x;
|
||||
friend class EffectEqualization48x;
|
||||
#endif
|
||||
|
||||
|
@ -312,7 +311,7 @@ private:
|
|||
|
||||
bool mRecalcRequired;
|
||||
|
||||
wxBitmap *mBitmap;
|
||||
std::unique_ptr<wxBitmap> mBitmap;
|
||||
wxRect mEnvRect;
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
|
|
@ -78,7 +78,7 @@ bool Generator::Process()
|
|||
else {
|
||||
// Transfer the data from the temporary track to the actual one
|
||||
tmp->Flush();
|
||||
SetTimeWarper(new StepTimeWarper(mT0+GetDuration(), GetDuration()-(mT1-mT0)));
|
||||
SetTimeWarper(std::make_unique<StepTimeWarper>(mT0+GetDuration(), GetDuration()-(mT1-mT0)));
|
||||
bGoodResult = track->ClearAndPaste(p->GetSel0(), p->GetSel1(), &*tmp, true,
|
||||
false, GetTimeWarper());
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ private:
|
|||
FloatVector mRealFFTs;
|
||||
FloatVector mImagFFTs;
|
||||
};
|
||||
std::vector<Record*> mQueue;
|
||||
std::vector<movable_ptr<Record>> mQueue;
|
||||
};
|
||||
|
||||
/****************************************************************//**
|
||||
|
@ -641,8 +641,6 @@ bool EffectNoiseReduction::Process()
|
|||
EffectNoiseReduction::Worker::~Worker()
|
||||
{
|
||||
EndFFT(hFFT);
|
||||
for(int ii = 0, nn = mQueue.size(); ii < nn; ++ii)
|
||||
delete mQueue[ii];
|
||||
}
|
||||
|
||||
bool EffectNoiseReduction::Worker::Process
|
||||
|
@ -797,7 +795,7 @@ EffectNoiseReduction::Worker::Worker
|
|||
|
||||
mQueue.resize(mHistoryLen);
|
||||
for (int ii = 0; ii < mHistoryLen; ++ii)
|
||||
mQueue[ii] = new Record(mSpectrumSize);
|
||||
mQueue[ii] = make_movable<Record>(mSpectrumSize);
|
||||
|
||||
// Create windows
|
||||
|
||||
|
@ -986,9 +984,7 @@ void EffectNoiseReduction::Worker::FillFirstHistoryWindow()
|
|||
|
||||
void EffectNoiseReduction::Worker::RotateHistoryWindows()
|
||||
{
|
||||
Record *save = mQueue[mHistoryLen - 1];
|
||||
mQueue.pop_back();
|
||||
mQueue.insert(mQueue.begin(), save);
|
||||
std::rotate(mQueue.begin(), mQueue.end() - 1, mQueue.end());
|
||||
}
|
||||
|
||||
void EffectNoiseReduction::Worker::FinishTrackStatistics(Statistics &statistics)
|
||||
|
|
|
@ -36,11 +36,7 @@ public:
|
|||
buf = NULL;
|
||||
leftBuffer = NULL;
|
||||
rightBuffer = NULL;
|
||||
quality = NULL;
|
||||
iface = NULL;
|
||||
sbsms = NULL;
|
||||
|
||||
resampler = NULL;
|
||||
SBSMSBuf = NULL;
|
||||
outputLeftTrack = NULL;
|
||||
outputRightTrack = NULL;
|
||||
|
@ -52,10 +48,6 @@ public:
|
|||
if(leftBuffer) free(leftBuffer);
|
||||
if(rightBuffer) free(rightBuffer);
|
||||
if(SBSMSBuf) free(SBSMSBuf);
|
||||
if(quality) delete quality;
|
||||
if(sbsms) delete sbsms;
|
||||
if(iface) delete iface;
|
||||
if(resampler) delete resampler;
|
||||
}
|
||||
|
||||
bool bPitch;
|
||||
|
@ -70,13 +62,13 @@ public:
|
|||
float *rightBuffer;
|
||||
WaveTrack *leftTrack;
|
||||
WaveTrack *rightTrack;
|
||||
SBSMS *sbsms;
|
||||
SBSMSInterface *iface;
|
||||
std::unique_ptr<SBSMS> sbsms;
|
||||
std::unique_ptr<SBSMSInterface> iface;
|
||||
audio *SBSMSBuf;
|
||||
|
||||
// Not required by callbacks, but makes for easier cleanup
|
||||
Resampler *resampler;
|
||||
SBSMSQuality *quality;
|
||||
std::unique_ptr<Resampler> resampler;
|
||||
std::unique_ptr<SBSMSQuality> quality;
|
||||
std::unique_ptr<WaveTrack> outputLeftTrack;
|
||||
std::unique_ptr<WaveTrack> outputRightTrack;
|
||||
};
|
||||
|
@ -141,7 +133,7 @@ long resampleCB(void *cb_data, SBSMSFrame *data)
|
|||
long postResampleCB(void *cb_data, SBSMSFrame *data)
|
||||
{
|
||||
ResampleBuf *r = (ResampleBuf*) cb_data;
|
||||
long sampleCount = r->sbsms->read(r->iface, r->SBSMSBuf, r->SBSMSBlockSize);
|
||||
long sampleCount = r->sbsms->read(r->iface.get(), r->SBSMSBuf, r->SBSMSBlockSize);
|
||||
data->buf = r->SBSMSBuf;
|
||||
data->size = sampleCount;
|
||||
data->ratio0 = 1.0 / r->ratio;
|
||||
|
@ -164,24 +156,24 @@ void EffectSBSMS :: setParameters(double rateStart, double rateEnd, double pitch
|
|||
this->bPitchReferenceInput = bPitchReferenceInput;
|
||||
}
|
||||
|
||||
TimeWarper *createTimeWarper(double t0, double t1, double duration,
|
||||
std::unique_ptr<TimeWarper> createTimeWarper(double t0, double t1, double duration,
|
||||
double rateStart, double rateEnd, SlideType rateSlideType)
|
||||
{
|
||||
TimeWarper *warper = NULL;
|
||||
std::unique_ptr<TimeWarper> warper;
|
||||
if (rateStart == rateEnd || rateSlideType == SlideConstant) {
|
||||
warper = new LinearTimeWarper(t0, t0, t1, t0+duration);
|
||||
warper = std::make_unique<LinearTimeWarper>(t0, t0, t1, t0+duration);
|
||||
} else if(rateSlideType == SlideLinearInputRate) {
|
||||
warper = new LinearInputRateTimeWarper(t0, t1, rateStart, rateEnd);
|
||||
warper = std::make_unique<LinearInputRateTimeWarper>(t0, t1, rateStart, rateEnd);
|
||||
} else if(rateSlideType == SlideLinearOutputRate) {
|
||||
warper = new LinearOutputRateTimeWarper(t0, t1, rateStart, rateEnd);
|
||||
warper = std::make_unique<LinearOutputRateTimeWarper>(t0, t1, rateStart, rateEnd);
|
||||
} else if(rateSlideType == SlideLinearInputStretch) {
|
||||
warper = new LinearInputStretchTimeWarper(t0, t1, rateStart, rateEnd);
|
||||
warper = std::make_unique<LinearInputStretchTimeWarper>(t0, t1, rateStart, rateEnd);
|
||||
} else if(rateSlideType == SlideLinearOutputStretch) {
|
||||
warper = new LinearOutputStretchTimeWarper(t0, t1, rateStart, rateEnd);
|
||||
warper = std::make_unique<LinearOutputStretchTimeWarper>(t0, t1, rateStart, rateEnd);
|
||||
} else if(rateSlideType == SlideGeometricInput) {
|
||||
warper = new GeometricInputTimeWarper(t0, t1, rateStart, rateEnd);
|
||||
warper = std::make_unique<GeometricInputTimeWarper>(t0, t1, rateStart, rateEnd);
|
||||
} else if(rateSlideType == SlideGeometricOutput) {
|
||||
warper = new GeometricOutputTimeWarper(t0, t1, rateStart, rateEnd);
|
||||
warper = std::make_unique<GeometricOutputTimeWarper>(t0, t1, rateStart, rateEnd);
|
||||
}
|
||||
return warper;
|
||||
}
|
||||
|
@ -190,8 +182,8 @@ TimeWarper *createTimeWarper(double t0, double t1, double duration,
|
|||
// it are shifted along appropriately.
|
||||
bool EffectSBSMS::ProcessLabelTrack(Track *t)
|
||||
{
|
||||
TimeWarper *warper = createTimeWarper(mT0,mT1,(mT1-mT0)*mTotalStretch,rateStart,rateEnd,rateSlideType);
|
||||
SetTimeWarper(new RegionTimeWarper(mT0, mT1, warper));
|
||||
auto warper = createTimeWarper(mT0,mT1,(mT1-mT0)*mTotalStretch,rateStart,rateEnd,rateSlideType);
|
||||
SetTimeWarper(std::make_unique<RegionTimeWarper>(mT0, mT1, std::move(warper)));
|
||||
LabelTrack *lt = (LabelTrack*)t;
|
||||
if (lt == NULL) return false;
|
||||
lt->WarpLabels(*GetTimeWarper());
|
||||
|
@ -313,10 +305,10 @@ bool EffectSBSMS::Process()
|
|||
outResampleCB = resampleCB;
|
||||
rb.offset = start;
|
||||
rb.end = end;
|
||||
rb.iface = new SBSMSInterfaceSliding(&rateSlide,&pitchSlide,
|
||||
rb.iface = std::make_unique<SBSMSInterfaceSliding>(&rateSlide,&pitchSlide,
|
||||
bPitchReferenceInput,
|
||||
samplesToProcess,0,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
|
||||
} else {
|
||||
|
@ -324,9 +316,9 @@ bool EffectSBSMS::Process()
|
|||
outSlideType = (srProcess==srTrack?SlideIdentity:SlideConstant);
|
||||
outResampleCB = postResampleCB;
|
||||
rb.ratio = srProcess/srTrack;
|
||||
rb.quality = new SBSMSQuality(&SBSMSQualityStandard);
|
||||
rb.resampler = new Resampler(resampleCB, &rb, srProcess==srTrack?SlideIdentity:SlideConstant);
|
||||
rb.sbsms = new SBSMS(rightTrack?2:1,rb.quality,true);
|
||||
rb.quality = std::make_unique<SBSMSQuality>(&SBSMSQualityStandard);
|
||||
rb.resampler = std::make_unique<Resampler>(resampleCB, &rb, srProcess==srTrack?SlideIdentity:SlideConstant);
|
||||
rb.sbsms = std::make_unique<SBSMS>(rightTrack ? 2 : 1, rb.quality.get(), true);
|
||||
rb.SBSMSBlockSize = rb.sbsms->getInputFrameSize();
|
||||
rb.SBSMSBuf = (audio*)calloc(rb.SBSMSBlockSize,sizeof(audio));
|
||||
|
||||
|
@ -336,11 +328,11 @@ bool EffectSBSMS::Process()
|
|||
(long)((float)(processPresamples)*(srTrack/srProcess)));
|
||||
rb.offset = start - trackPresamples;
|
||||
rb.end = trackEnd;
|
||||
rb.iface = new SBSMSEffectInterface(rb.resampler,
|
||||
rb.iface = std::make_unique<SBSMSEffectInterface>(rb.resampler.get(),
|
||||
&rateSlide,&pitchSlide,
|
||||
bPitchReferenceInput,
|
||||
samplesToProcess,processPresamples,
|
||||
rb.quality);
|
||||
rb.quality.get());
|
||||
}
|
||||
|
||||
Resampler resampler(outResampleCB,&rb,outSlideType);
|
||||
|
@ -361,8 +353,8 @@ bool EffectSBSMS::Process()
|
|||
if(duration > maxDuration)
|
||||
maxDuration = duration;
|
||||
|
||||
TimeWarper *warper = createTimeWarper(mCurT0,mCurT1,maxDuration,rateStart,rateEnd,rateSlideType);
|
||||
SetTimeWarper(warper);
|
||||
auto warper = createTimeWarper(mCurT0,mCurT1,maxDuration,rateStart,rateEnd,rateSlideType);
|
||||
SetTimeWarper(std::move(warper));
|
||||
|
||||
rb.outputLeftTrack = mFactory->NewWaveTrack(leftTrack->GetSampleFormat(),
|
||||
leftTrack->GetRate());
|
||||
|
|
|
@ -1030,10 +1030,6 @@ EffectScienFilterPanel::EffectScienFilterPanel(EffectScienFilter *effect, wxWind
|
|||
|
||||
EffectScienFilterPanel::~EffectScienFilterPanel()
|
||||
{
|
||||
if (mBitmap)
|
||||
{
|
||||
delete mBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
void EffectScienFilterPanel::SetFreqRange(double lo, double hi)
|
||||
|
@ -1073,14 +1069,9 @@ void EffectScienFilterPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||
|
||||
if (!mBitmap || mWidth != width || mHeight != height)
|
||||
{
|
||||
if (mBitmap)
|
||||
{
|
||||
delete mBitmap;
|
||||
}
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mBitmap = new wxBitmap(mWidth, mHeight);
|
||||
mBitmap = std::make_unique<wxBitmap>(mWidth, mHeight);
|
||||
}
|
||||
|
||||
wxBrush bkgndBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
|
|
|
@ -163,7 +163,7 @@ private:
|
|||
double mDbMin;
|
||||
double mDbMax;
|
||||
|
||||
wxBitmap *mBitmap;
|
||||
std::unique_ptr<wxBitmap> mBitmap;
|
||||
wxRect mEnvRect;
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
|
|
@ -53,16 +53,16 @@ It \TODO: description
|
|||
#include "scorealign-glue.h"
|
||||
#include "ScoreAlignDialog.h"
|
||||
|
||||
static ScoreAlignDialog *gScoreAlignDialog = NULL;
|
||||
static std::unique_ptr<ScoreAlignDialog> gScoreAlignDialog{};
|
||||
|
||||
//IMPLEMENT_CLASS(ScoreAlignDialog, wxDialogWrapper)
|
||||
|
||||
ScoreAlignDialog::ScoreAlignDialog(wxWindow *parent, ScoreAlignParams ¶ms)
|
||||
: wxDialogWrapper(parent, -1, _("Align MIDI to Audio"),
|
||||
ScoreAlignDialog::ScoreAlignDialog(ScoreAlignParams ¶ms)
|
||||
: wxDialogWrapper(NULL, -1, _("Align MIDI to Audio"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE)
|
||||
{
|
||||
gScoreAlignDialog = this; // Allows anyone to close dialog by calling
|
||||
gScoreAlignDialog.reset(this); // Allows anyone to close dialog by calling
|
||||
// CloseScoreAlignDialog()
|
||||
gPrefs->Read(wxT("/Tracks/Synchronize/FramePeriod"), &p.mFramePeriod,
|
||||
float(SA_DFT_FRAME_PERIOD));
|
||||
|
@ -277,10 +277,7 @@ bool ScoreAlignDialog::TransferDataFromWindow()
|
|||
|
||||
void CloseScoreAlignDialog()
|
||||
{
|
||||
if (gScoreAlignDialog) {
|
||||
delete gScoreAlignDialog;
|
||||
gScoreAlignDialog = NULL;
|
||||
}
|
||||
gScoreAlignDialog.reset();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
wxButton *mDefaultButton;
|
||||
|
||||
// constructors and destructors
|
||||
ScoreAlignDialog(wxWindow * parent, ScoreAlignParams ¶ms);
|
||||
ScoreAlignDialog(ScoreAlignParams ¶ms);
|
||||
~ScoreAlignDialog();
|
||||
|
||||
bool TransferDataFromWindow();
|
||||
|
|
|
@ -28,7 +28,7 @@ effect that uses SoundTouch to do its processing (ChangeTempo
|
|||
bool EffectSoundTouch::ProcessLabelTrack(Track *track)
|
||||
{
|
||||
// SetTimeWarper(new RegionTimeWarper(mCurT0, mCurT1,
|
||||
// new LinearTimeWarper(mCurT0, mCurT0,
|
||||
// std::make_unique<LinearTimeWarper>(mCurT0, mCurT0,
|
||||
// mCurT1, mCurT0 + (mCurT1-mCurT0)*mFactor)));
|
||||
LabelTrack *lt = (LabelTrack*)track;
|
||||
if (lt == NULL) return false;
|
||||
|
@ -162,8 +162,7 @@ bool EffectSoundTouch::Process()
|
|||
if (bGoodResult)
|
||||
ReplaceProcessedTracks(bGoodResult);
|
||||
|
||||
delete mSoundTouch;
|
||||
mSoundTouch = NULL;
|
||||
mSoundTouch.reset();
|
||||
|
||||
// mT0 = mCurT0;
|
||||
// mT1 = mCurT0 + m_maxNewLength; // Update selection.
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
#endif
|
||||
|
||||
protected:
|
||||
SoundTouch *mSoundTouch;
|
||||
std::unique_ptr<SoundTouch> mSoundTouch;
|
||||
double mCurT0;
|
||||
double mCurT1;
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ Geometric TimeWarper classes
|
|||
|
||||
*//*******************************************************************/
|
||||
|
||||
#include <wx/string.h>
|
||||
#include "../Audacity.h"
|
||||
#include "TimeWarper.h"
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <math.h>
|
||||
|
||||
double IdentityTimeWarper::Warp(double originalTime) const
|
||||
|
|
|
@ -56,6 +56,8 @@ of the warped region.
|
|||
#ifndef __TIMEWARPER__
|
||||
#define __TIMEWARPER__
|
||||
|
||||
#include "../MemoryX.h"
|
||||
|
||||
class TimeWarper /* not final */
|
||||
{
|
||||
public:
|
||||
|
@ -72,13 +74,12 @@ public:
|
|||
class ShiftTimeWarper final : public TimeWarper
|
||||
{
|
||||
private:
|
||||
TimeWarper *mWarper;
|
||||
std::unique_ptr<TimeWarper> mWarper;
|
||||
double mShift;
|
||||
public:
|
||||
ShiftTimeWarper(TimeWarper *warper, double shiftAmount)
|
||||
: mWarper(warper), mShift(shiftAmount) { }
|
||||
virtual ~ShiftTimeWarper()
|
||||
{ delete mWarper; }
|
||||
ShiftTimeWarper(std::unique_ptr<TimeWarper> &&warper, double shiftAmount)
|
||||
: mWarper(std::move(warper)), mShift(shiftAmount) { }
|
||||
virtual ~ShiftTimeWarper() {}
|
||||
double Warp(double originalTime) const override;
|
||||
};
|
||||
|
||||
|
@ -191,17 +192,16 @@ public:
|
|||
class RegionTimeWarper final : public TimeWarper
|
||||
{
|
||||
private:
|
||||
TimeWarper *mWarper;
|
||||
std::unique_ptr<TimeWarper> mWarper;
|
||||
double mTStart;
|
||||
double mTEnd;
|
||||
double mOffset;
|
||||
public:
|
||||
RegionTimeWarper(double tStart, double tEnd, TimeWarper *warper)
|
||||
: mWarper(warper), mTStart(tStart), mTEnd(tEnd),
|
||||
RegionTimeWarper(double tStart, double tEnd, std::unique_ptr<TimeWarper> &&warper)
|
||||
: mWarper(std::move(warper)), mTStart(tStart), mTEnd(tEnd),
|
||||
mOffset(mWarper->Warp(mTEnd)-mTEnd)
|
||||
{ }
|
||||
virtual ~RegionTimeWarper()
|
||||
{ delete mWarper; }
|
||||
virtual ~RegionTimeWarper() {}
|
||||
double Warp(double originalTime) const override
|
||||
{
|
||||
if (originalTime < mTStart)
|
||||
|
|
Loading…
Reference in New Issue