Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
WaveClip::ClearSequenceFinisher Class Reference

Fix consistency of cutlines and envelope after deleting from Sequences. More...

Collaboration diagram for WaveClip::ClearSequenceFinisher:
[legend]

Public Member Functions

 ClearSequenceFinisher () noexcept=default
 
 ClearSequenceFinisher (WaveClip *pClip, double t0, double t1, double clip_t0, double clip_t1) noexcept
 
ClearSequenceFinisheroperator= (ClearSequenceFinisher &&other)
 
 ~ClearSequenceFinisher () noexcept
 
void Commit () noexcept
 

Private Member Functions

ClearSequenceFinisheroperator= (const ClearSequenceFinisher &other)=default
 

Private Attributes

WaveClippClip {}
 
double t0 {}
 
double t1 {}
 
double clip_t0 {}
 
double clip_t1 {}
 
bool committed = false
 

Detailed Description

Fix consistency of cutlines and envelope after deleting from Sequences.

This is like a finally object

Definition at line 890 of file WaveClip.h.

Constructor & Destructor Documentation

◆ ClearSequenceFinisher() [1/2]

WaveClip::ClearSequenceFinisher::ClearSequenceFinisher ( )
defaultnoexcept

◆ ClearSequenceFinisher() [2/2]

WaveClip::ClearSequenceFinisher::ClearSequenceFinisher ( WaveClip pClip,
double  t0,
double  t1,
double  clip_t0,
double  clip_t1 
)
inlinenoexcept

◆ ~ClearSequenceFinisher()

WaveClip::ClearSequenceFinisher::~ClearSequenceFinisher ( )
noexcept

Definition at line 1357 of file WaveClip.cpp.

1358{
1359 if (!pClip || !committed)
1360 return;
1361
1362 // use No-fail-guarantee in the remaining
1363
1364 // msmeyer
1365 //
1366 // Delete all cutlines that are within the given area, if any.
1367 //
1368 // Note that when cutlines are active, two functions are used:
1369 // Clear() and ClearAndAddCutLine(). ClearAndAddCutLine() is called
1370 // whenever the user directly calls a command that removes some audio, e.g.
1371 // "Cut" or "Clear" from the menu. This command takes care about recursive
1372 // preserving of cutlines within clips. Clear() is called when internal
1373 // operations want to remove audio. In the latter case, it is the right
1374 // thing to just remove all cutlines within the area.
1375 //
1376
1377 // May DELETE as we iterate, so don't use range-for
1378 for (auto it = pClip->mCutLines.begin(); it != pClip->mCutLines.end();)
1379 {
1380 WaveClip* clip = it->get();
1381 double cutlinePosition =
1383 if (cutlinePosition >= t0 && cutlinePosition <= t1)
1384 {
1385 // This cutline is within the area, DELETE it
1386 it = pClip->mCutLines.erase(it);
1387 }
1388 else
1389 {
1390 if (cutlinePosition >= t1)
1391 {
1392 clip->ShiftBy(clip_t0 - clip_t1);
1393 }
1394 ++it;
1395 }
1396 }
1397
1398 // Collapse envelope
1399 auto sampleTime = 1.0 / pClip->GetRate();
1400 pClip->GetEnvelope().CollapseRegion(t0, t1, sampleTime);
1401}
void CollapseRegion(double t0, double t1, double sampleDur) noexcept
Definition: Envelope.cpp:396
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238
double GetSequenceStartTime() const noexcept
Definition: WaveClip.cpp:1872
void ShiftBy(double delta) noexcept
Definition: WaveClip.cpp:1898
int GetRate() const override
Definition: WaveClip.h:337
Envelope & GetEnvelope() noexcept
Definition: WaveClip.h:553
WaveClipHolders mCutLines
Definition: WaveClip.h:973

References clip_t0, clip_t1, Envelope::CollapseRegion(), committed, WaveClip::GetEnvelope(), WaveClip::GetRate(), WaveClip::GetSequenceStartTime(), WaveClip::mCutLines, pClip, WaveClip::ShiftBy(), t0, and t1.

Here is the call graph for this function:

Member Function Documentation

◆ Commit()

void WaveClip::ClearSequenceFinisher::Commit ( )
inlinenoexcept

Definition at line 911 of file WaveClip.h.

911{ committed = true; }

Referenced by WaveClip::Clear(), WaveClip::ClearLeft(), WaveClip::ClearRight(), WaveClip::InsertSilence(), and WaveClip::Paste().

Here is the caller graph for this function:

◆ operator=() [1/2]

ClearSequenceFinisher & WaveClip::ClearSequenceFinisher::operator= ( ClearSequenceFinisher &&  other)
inline

Definition at line 904 of file WaveClip.h.

905 {
906 *this = other;
907 other.pClip = nullptr;
908 return *this;
909 }

References pClip.

◆ operator=() [2/2]

ClearSequenceFinisher & WaveClip::ClearSequenceFinisher::operator= ( const ClearSequenceFinisher other)
privatedefault

Member Data Documentation

◆ clip_t0

double WaveClip::ClearSequenceFinisher::clip_t0 {}
private

Definition at line 917 of file WaveClip.h.

Referenced by ~ClearSequenceFinisher().

◆ clip_t1

double WaveClip::ClearSequenceFinisher::clip_t1 {}
private

Definition at line 917 of file WaveClip.h.

Referenced by ~ClearSequenceFinisher().

◆ committed

bool WaveClip::ClearSequenceFinisher::committed = false
private

Definition at line 918 of file WaveClip.h.

Referenced by ~ClearSequenceFinisher().

◆ pClip

WaveClip* WaveClip::ClearSequenceFinisher::pClip {}
private

Definition at line 916 of file WaveClip.h.

Referenced by operator=(), and ~ClearSequenceFinisher().

◆ t0

double WaveClip::ClearSequenceFinisher::t0 {}
private

Definition at line 917 of file WaveClip.h.

Referenced by ~ClearSequenceFinisher().

◆ t1

double WaveClip::ClearSequenceFinisher::t1 {}
private

Definition at line 917 of file WaveClip.h.

Referenced by ~ClearSequenceFinisher().


The documentation for this class was generated from the following files: