Audacity 3.2.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
WaveClip Class Referencefinal

This allows multiple clips to be a part of one WaveTrack. More...

#include <WaveClip.h>

Inheritance diagram for WaveClip:
[legend]
Collaboration diagram for WaveClip:
[legend]

Public Types

using Caches = Site< WaveClip, WaveClipListener >
 
- Public Types inherited from ClientData::Site< WaveClip, WaveClipListener >
using DataType = WaveClipListener
 
using DataPointer = UniquePtr< WaveClipListener >
 
using DataFactory = std::function< DataPointer(WaveClip &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 

Public Member Functions

 WaveClip (const SampleBlockFactoryPtr &factory, sampleFormat format, int rate, int colourIndex)
 
 WaveClip (const WaveClip &orig, const SampleBlockFactoryPtr &factory, bool copyCutlines)
 
 WaveClip (const WaveClip &orig, const SampleBlockFactoryPtr &factory, bool copyCutlines, double t0, double t1)
 Copy only a range from the given WaveClip. More...
 
virtual ~WaveClip ()
 
void ConvertToSampleFormat (sampleFormat format, const std::function< void(size_t)> &progressReport={})
 
sampleCount TimeToSequenceSamples (double t) const
 
sampleCount ToSequenceSamples (sampleCount s) const
 
int GetRate () const
 
void SetRate (int rate)
 
void Resample (int rate, BasicUI::ProgressDialog *progress=NULL)
 
void SetColourIndex (int index)
 
int GetColourIndex () const
 
double GetSequenceStartTime () const noexcept
 
void SetSequenceStartTime (double startTime)
 
double GetSequenceEndTime () const
 
sampleCount GetSequenceStartSample () const
 Returns the index of the first sample of the underlying sequence. More...
 
sampleCount GetSequenceEndSample () const
 Returns the index of the sample next after the last sample of the underlying sequence. More...
 
sampleCount GetSequenceSamplesCount () const
 Returns the total number of samples in underlying sequence (not counting the cutlines) More...
 
double GetPlayStartTime () const noexcept
 
void SetPlayStartTime (double time)
 
double GetPlayEndTime () const
 
sampleCount GetPlayStartSample () const
 
sampleCount GetPlayEndSample () const
 
sampleCount GetPlaySamplesCount () const
 
void SetTrimLeft (double trim)
 Sets the play start offset in seconds from the beginning of the underlying sequence. More...
 
double GetTrimLeft () const noexcept
 Returns the play start offset in seconds from the beginning of the underlying sequence. More...
 
void SetTrimRight (double trim)
 Sets the play end offset in seconds from the ending of the underlying sequence. More...
 
double GetTrimRight () const noexcept
 Returns the play end offset in seconds from the ending of the underlying sequence. More...
 
void TrimLeft (double deltaTime)
 Moves play start position by deltaTime. More...
 
void TrimRight (double deltaTime)
 Moves play end position by deltaTime. More...
 
void TrimLeftTo (double to)
 Sets the the left trimming to the absolute time (if that is in bounds) More...
 
void TrimRightTo (double to)
 Sets the the right trimming to the absolute time (if that is in bounds) More...
 
void Offset (double delta) noexcept
 
bool WithinPlayRegion (double t) const
 
bool BeforePlayStartTime (double t) const
 
bool AfterPlayEndTime (double t) const
 
sampleCount CountSamples (double t0, double t1) const
 
bool GetSamples (samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow=true) const
 
void SetSamples (constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len, sampleFormat effectiveFormat)
 
EnvelopeGetEnvelope ()
 
const EnvelopeGetEnvelope () const
 
BlockArrayGetSequenceBlockArray ()
 
const BlockArrayGetSequenceBlockArray () const
 
SequenceGetSequence ()
 
const SequenceGetSequence () const
 
void MarkChanged ()
 
std::pair< float, float > GetMinMax (double t0, double t1, bool mayThrow=true) const
 
float GetRMS (double t0, double t1, bool mayThrow=true) const
 
void UpdateEnvelopeTrackLen ()
 
std::shared_ptr< SampleBlockAppendNewBlock (samplePtr buffer, sampleFormat format, size_t len)
 For use in importing pre-version-3 projects to preserve sharing of blocks; no dithering applied. More...
 
void AppendSharedBlock (const std::shared_ptr< SampleBlock > &pBlock)
 For use in importing pre-version-3 projects to preserve sharing of blocks. More...
 
bool Append (constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride, sampleFormat effectiveFormat)
 
void Flush ()
 Flush must be called after last Append. More...
 
void Clear (double t0, double t1)
 
void ClearLeft (double t)
 
void ClearRight (double t)
 
void ClearAndAddCutLine (double t0, double t1)
 
void Paste (double t0, const WaveClip *other)
 Paste data from other clip, resampling it if not equal rate. More...
 
void InsertSilence (double t, double len, double *pEnvelopeValue=nullptr)
 
void AppendSilence (double len, double envelopeValue)
 
WaveClipHoldersGetCutLines ()
 Get access to cut lines list. More...
 
const WaveClipConstHoldersGetCutLines () const
 
size_t NumCutLines () const
 
bool FindCutLine (double cutLinePosition, double *cutLineStart=NULL, double *cutLineEnd=NULL) const
 
void ExpandCutLine (double cutLinePosition)
 
bool RemoveCutLine (double cutLinePosition)
 Remove cut line, without expanding the audio in it. More...
 
void OffsetCutLines (double t0, double len)
 Offset cutlines right to time 't0' by time amount 'len'. More...
 
void CloseLock ()
 
bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override
 
void HandleXMLEndTag (const std::string_view &tag) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &tag) override
 
void WriteXML (XMLWriter &xmlFile) const
 
bool GetIsPlaceholder () const
 
void SetIsPlaceholder (bool val)
 
bool SharesBoundaryWithNextClip (const WaveClip *next) const
 
void SetName (const wxString &name)
 
const wxString & GetName () const
 
sampleCount TimeToSamples (double time) const noexcept
 
double SamplesToTime (sampleCount s) const noexcept
 
void SetSilence (sampleCount offset, sampleCount length)
 Silences the 'length' amount of samples starting from 'offset'(relative to the play start) More...
 
constSamplePtr GetAppendBuffer () const
 
size_t GetAppendBufferLen () const
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< WaveClip, WaveClipListener >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (const Site &other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Protected Member Functions

void ClearSequence (double t0, double t1)
 
- Protected Member Functions inherited from ClientData::Site< WaveClip, WaveClipListener >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
WaveClipListenerFindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
const WaveClipListenerFindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 

Protected Attributes

double mSequenceOffset { 0 }
 
double mTrimLeft { 0 }
 
double mTrimRight { 0 }
 
int mRate
 
int mColourIndex
 
std::unique_ptr< SequencemSequence
 
std::unique_ptr< EnvelopemEnvelope
 
WaveClipHolders mCutLines {}
 
bool mIsPlaceholder { false }
 

Private Member Functions

 WaveClip (const WaveClip &) PROHIBITED
 
WaveClipoperator= (const WaveClip &) PROHIBITED
 

Private Attributes

wxString mName
 

Additional Inherited Members

- Static Public Member Functions inherited from ClientData::Site< WaveClip, WaveClipListener >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 

Detailed Description

This allows multiple clips to be a part of one WaveTrack.

Definition at line 99 of file WaveClip.h.

Member Typedef Documentation

◆ Caches

Definition at line 110 of file WaveClip.h.

Constructor & Destructor Documentation

◆ WaveClip() [1/4]

WaveClip::WaveClip ( const WaveClip )
private

◆ WaveClip() [2/4]

WaveClip::WaveClip ( const SampleBlockFactoryPtr factory,
sampleFormat  format,
int  rate,
int  colourIndex 
)

Definition at line 41 of file WaveClip.cpp.

43{
44 mRate = rate;
45 mColourIndex = colourIndex;
46 mSequence = std::make_unique<Sequence>( factory,
48
49 mEnvelope = std::make_unique<Envelope>(true, 1e-7, 2.0, 1.0);
50}
int format
Definition: ExportPCM.cpp:53
@ narrowestSampleFormat
Two synonyms for previous values that might change if more values were added.
Two sample formats, remembering format of original source and describing stored format.
Definition: SampleFormat.h:77
std::unique_ptr< Sequence > mSequence
Definition: WaveClip.h:366
std::unique_ptr< Envelope > mEnvelope
Definition: WaveClip.h:367
int mRate
Definition: WaveClip.h:363
int mColourIndex
Definition: WaveClip.h:364
static RegisteredToolbarFactory factory

References cloud::factory, format, mColourIndex, mEnvelope, mRate, mSequence, and narrowestSampleFormat.

◆ WaveClip() [3/4]

WaveClip::WaveClip ( const WaveClip orig,
const SampleBlockFactoryPtr factory,
bool  copyCutlines 
)

Definition at line 52 of file WaveClip.cpp.

55{
56 // essentially a copy constructor - but you must pass in the
57 // current sample block factory, because we might be copying
58 // from one project to another
59
61 mTrimLeft = orig.mTrimLeft;
63 mRate = orig.mRate;
65 mSequence = std::make_unique<Sequence>(*orig.mSequence, factory);
66
67 mEnvelope = std::make_unique<Envelope>(*orig.mEnvelope);
68
69 mName = orig.mName;
70
71 if ( copyCutlines )
72 for (const auto &clip: orig.mCutLines)
73 mCutLines.push_back
74 ( std::make_unique<WaveClip>( *clip, factory, true ) );
75
77}
bool mIsPlaceholder
Definition: WaveClip.h:374
double mTrimRight
Definition: WaveClip.h:361
wxString mName
Definition: WaveClip.h:377
bool GetIsPlaceholder() const
Definition: WaveClip.h:334
double mSequenceOffset
Definition: WaveClip.h:359
double mTrimLeft
Definition: WaveClip.h:360
WaveClipHolders mCutLines
Definition: WaveClip.h:371

References cloud::factory, GetIsPlaceholder(), mColourIndex, mCutLines, mEnvelope, mIsPlaceholder, mName, mRate, mSequence, mSequenceOffset, mTrimLeft, and mTrimRight.

Here is the call graph for this function:

◆ WaveClip() [4/4]

WaveClip::WaveClip ( const WaveClip orig,
const SampleBlockFactoryPtr factory,
bool  copyCutlines,
double  t0,
double  t1 
)

Copy only a range from the given WaveClip.

Precondition
CountSamples(t1, t0) > 0

Definition at line 79 of file WaveClip.cpp.

83{
84 assert(orig.CountSamples(t0, t1) > 0);
85
87
88 //Adjust trim values to sample-boundary
89 if(t0 > orig.GetPlayStartTime())
90 {
91 const auto s0 = orig.TimeToSamples(t0 - orig.GetSequenceStartTime());
92 mTrimLeft = orig.SamplesToTime(s0);
93
94 }else
95 mTrimLeft = orig.mTrimLeft;
96
97 if(t1 < orig.GetPlayEndTime())
98 {
99 const auto s1 = orig.TimeToSamples(orig.GetSequenceEndTime() - t1);
100 mTrimRight = orig.SamplesToTime(s1);
101 }
102 else
103 mTrimRight = orig.mTrimRight;
104
105 mRate = orig.mRate;
107
109
110 mSequence = std::make_unique<Sequence>(*orig.mSequence, factory);
111
112 mEnvelope = std::make_unique<Envelope>(*orig.mEnvelope);
113
114 if ( copyCutlines )
115 for (const auto &cutline : orig.mCutLines)
116 mCutLines.push_back(std::make_unique<WaveClip>(*cutline, factory, true));
117}
double GetSequenceStartTime() const noexcept
Definition: WaveClip.cpp:956
double GetPlayStartTime() const noexcept
Definition: WaveClip.cpp:878
sampleCount CountSamples(double t0, double t1) const
Definition: WaveClip.cpp:1017
double GetPlayEndTime() const
Definition: WaveClip.cpp:888
sampleCount TimeToSamples(double time) const noexcept
Definition: WaveClip.cpp:857
double SamplesToTime(sampleCount s) const noexcept
Definition: WaveClip.cpp:862
double GetSequenceEndTime() const
Definition: WaveClip.cpp:968

References CountSamples(), cloud::factory, GetIsPlaceholder(), GetPlayEndTime(), GetPlayStartTime(), GetSequenceEndTime(), GetSequenceStartTime(), mColourIndex, mCutLines, mEnvelope, mIsPlaceholder, mRate, mSequence, mSequenceOffset, mTrimLeft, mTrimRight, SamplesToTime(), and TimeToSamples().

Here is the call graph for this function:

◆ ~WaveClip()

WaveClip::~WaveClip ( )
virtual

Definition at line 120 of file WaveClip.cpp.

121{
122}

Member Function Documentation

◆ AfterPlayEndTime()

bool WaveClip::AfterPlayEndTime ( double  t) const

Definition at line 1011 of file WaveClip.cpp.

1012{
1013 auto ts = TimeToSamples(t);
1014 return ts >= GetPlayEndSample() + GetAppendBufferLen();
1015}
sampleCount GetPlayEndSample() const
Definition: WaveClip.cpp:905
size_t GetAppendBufferLen() const
Definition: WaveClip.cpp:152

References GetAppendBufferLen(), GetPlayEndSample(), and TimeToSamples().

Here is the call graph for this function:

◆ Append()

bool WaveClip::Append ( constSamplePtr  buffer,
sampleFormat  format,
size_t  len,
unsigned int  stride,
sampleFormat  effectiveFormat 
)

You must call Flush after the last Append

Returns
true if at least one complete block was created
Exception safety guarantee:
Partial – Some prefix (maybe none) of the buffer is appended, and no content already flushed to disk is lost.
Parameters
effectiveFormatMake the effective format of the data at least the minumum of this value and `format`. (Maybe wider, if merging with preexistent data.) If the data are later narrowed from stored format, but not narrower than the effective, then no dithering will occur.

Definition at line 242 of file WaveClip.cpp.

244{
245 //wxLogDebug(wxT("Append: len=%lli"), (long long) len);
246 auto cleanup = finally( [&] {
247 // use No-fail-guarantee
249 MarkChanged();
250 } );
251
252 return mSequence->Append(buffer, format, len, stride, effectiveFormat);
253}
void MarkChanged()
Definition: WaveClip.cpp:162
void UpdateEnvelopeTrackLen()
Definition: WaveClip.cpp:219

References format, MarkChanged(), mSequence, and UpdateEnvelopeTrackLen().

Referenced by WaveTrack::Append().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendNewBlock()

std::shared_ptr< SampleBlock > WaveClip::AppendNewBlock ( samplePtr  buffer,
sampleFormat  format,
size_t  len 
)

For use in importing pre-version-3 projects to preserve sharing of blocks; no dithering applied.

Exception safety guarantee:
Strong

Definition at line 227 of file WaveClip.cpp.

229{
230 return mSequence->AppendNewBlock( buffer, format, len );
231}

References format, and mSequence.

◆ AppendSharedBlock()

void WaveClip::AppendSharedBlock ( const std::shared_ptr< SampleBlock > &  pBlock)

For use in importing pre-version-3 projects to preserve sharing of blocks.

Exception safety guarantee:
Strong

Definition at line 234 of file WaveClip.cpp.

235{
236 mSequence->AppendSharedBlock( pBlock );
237}

References mSequence.

◆ AppendSilence()

void WaveClip::AppendSilence ( double  len,
double  envelopeValue 
)

Insert silence at the end, and causes the envelope to ramp linearly to the given value

Exception safety guarantee:
Strong

Definition at line 492 of file WaveClip.cpp.

493{
494 auto t = GetPlayEndTime();
495 InsertSilence( t, len, &envelopeValue );
496}
void InsertSilence(double t, double len, double *pEnvelopeValue=nullptr)
Definition: WaveClip.cpp:453

References GetPlayEndTime(), and InsertSilence().

Here is the call graph for this function:

◆ BeforePlayStartTime()

bool WaveClip::BeforePlayStartTime ( double  t) const

Definition at line 1005 of file WaveClip.cpp.

1006{
1007 auto ts = TimeToSamples(t);
1008 return ts <= GetPlayStartSample();
1009}
sampleCount GetPlayStartSample() const
Definition: WaveClip.cpp:900

References GetPlayStartSample(), and TimeToSamples().

Here is the call graph for this function:

◆ Clear()

void WaveClip::Clear ( double  t0,
double  t1 
)

This name is consistent with WaveTrack::Clear. It performs a "Cut" operation (but without putting the cut audio to the clipboard)

Exception safety guarantee:
Strong

Definition at line 499 of file WaveClip.cpp.

500{
501 auto st0 = t0;
502 auto st1 = t1;
503 auto offset = .0;
504 if (st0 <= GetPlayStartTime())
505 {
506 offset = (t0 - GetPlayStartTime()) + GetTrimLeft();
507 st0 = GetSequenceStartTime();
508
509 SetTrimLeft(.0);
510 }
511 if (st1 >= GetPlayEndTime())
512 {
513 st1 = GetSequenceEndTime();
514 SetTrimRight(.0);
515 }
516 ClearSequence(st0, st1);
517
518 if (offset != .0)
519 Offset(offset);
520}
double GetTrimLeft() const noexcept
Returns the play start offset in seconds from the beginning of the underlying sequence.
Definition: WaveClip.cpp:921
void SetTrimRight(double trim)
Sets the play end offset in seconds from the ending of the underlying sequence.
Definition: WaveClip.cpp:926
void Offset(double delta) noexcept
Definition: WaveClip.cpp:989
void ClearSequence(double t0, double t1)
Definition: WaveClip.cpp:541
void SetTrimLeft(double trim)
Sets the play start offset in seconds from the beginning of the underlying sequence.
Definition: WaveClip.cpp:916

References ClearSequence(), GetPlayEndTime(), GetPlayStartTime(), GetSequenceEndTime(), GetSequenceStartTime(), GetTrimLeft(), Offset(), SetTrimLeft(), and SetTrimRight().

Here is the call graph for this function:

◆ ClearAndAddCutLine()

void WaveClip::ClearAndAddCutLine ( double  t0,
double  t1 
)

Clear, and add cut line that starts at t0 and contains everything until t1 if there is at least one clip sample between t0 and t1, noop otherwise.

Exception safety guarantee:
Weak – This WaveClip remains destructible in case of AudacityException. But some cutlines may be deleted

Definition at line 601 of file WaveClip.cpp.

602{
603 if (t0 > GetPlayEndTime() || t1 < GetPlayStartTime() || CountSamples(t0, t1) == 0)
604 return; // no samples to remove
605
606 const double clip_t0 = std::max( t0, GetPlayStartTime() );
607 const double clip_t1 = std::min( t1, GetPlayEndTime() );
608
609 auto newClip = std::make_unique< WaveClip >
610 (*this, mSequence->GetFactory(), true, clip_t0, clip_t1);
611
612 newClip->SetSequenceStartTime( clip_t0 - GetSequenceStartTime() );
613
614 // Remove cutlines from this clip that were in the selection, shift
615 // left those that were after the selection
616 // May DELETE as we iterate, so don't use range-for
617 for (auto it = mCutLines.begin(); it != mCutLines.end();)
618 {
619 WaveClip* clip = it->get();
620 double cutlinePosition = GetSequenceStartTime() + clip->GetSequenceStartTime();
621 if (cutlinePosition >= t0 && cutlinePosition <= t1)
622 it = mCutLines.erase(it);
623 else
624 {
625 if (cutlinePosition >= t1)
626 {
627 clip->Offset(clip_t0 - clip_t1);
628 }
629 ++it;
630 }
631 }
632
633 // Clear actual audio data
634 auto s0 = TimeToSequenceSamples(t0);
635 auto s1 = TimeToSequenceSamples(t1);
636
637 // use Weak-guarantee
638 GetSequence()->Delete(s0, s1-s0);
639
640 // Collapse envelope
641 auto sampleTime = 1.0 / GetRate();
642 GetEnvelope()->CollapseRegion( t0, t1, sampleTime );
643
644 MarkChanged();
645
646 mCutLines.push_back(std::move(newClip));
647}
int min(int a, int b)
void CollapseRegion(double t0, double t1, double sampleDur)
Definition: Envelope.cpp:377
void Delete(sampleCount start, sampleCount len)
Definition: Sequence.cpp:1524
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:101
sampleCount TimeToSequenceSamples(double t) const
Definition: WaveClip.cpp:1030
Sequence * GetSequence()
Definition: WaveClip.h:227
Envelope * GetEnvelope()
Definition: WaveClip.h:219
int GetRate() const
Definition: WaveClip.h:140

References Envelope::CollapseRegion(), CountSamples(), Sequence::Delete(), GetEnvelope(), GetPlayEndTime(), GetPlayStartTime(), GetRate(), GetSequence(), GetSequenceStartTime(), MarkChanged(), mCutLines, min(), mSequence, Offset(), and TimeToSequenceSamples().

Here is the call graph for this function:

◆ ClearLeft()

void WaveClip::ClearLeft ( double  t)

Removes samples starting from the left boundary of the clip till t, if it's inside the play region. Also removes trimmed (hidden) data, if present. Changes offset to make remaining samples stay at their old place. Destructive operation.

Definition at line 522 of file WaveClip.cpp.

523{
524 if (t > GetPlayStartTime() && t < GetPlayEndTime())
525 {
527 SetTrimLeft(.0);
529 }
530}
void SetSequenceStartTime(double startTime)
Definition: WaveClip.cpp:962

References ClearSequence(), GetPlayEndTime(), GetPlayStartTime(), GetSequenceStartTime(), SetSequenceStartTime(), and SetTrimLeft().

Here is the call graph for this function:

◆ ClearRight()

void WaveClip::ClearRight ( double  t)

Removes samples starting from t (if it's inside the clip), till the right boundary. Also removes trimmed (hidden) data, if present. Destructive operation.

Definition at line 532 of file WaveClip.cpp.

533{
534 if (t > GetPlayStartTime() && t < GetPlayEndTime())
535 {
537 SetTrimRight(.0);
538 }
539}

References ClearSequence(), GetPlayEndTime(), GetPlayStartTime(), GetSequenceEndTime(), and SetTrimRight().

Here is the call graph for this function:

◆ ClearSequence()

void WaveClip::ClearSequence ( double  t0,
double  t1 
)
protected

This name is consistent with WaveTrack::Clear. It performs a "Cut" operation (but without putting the cut audio to the clipboard)

Definition at line 541 of file WaveClip.cpp.

542{
543 auto clip_t0 = std::max(t0, GetSequenceStartTime());
544 auto clip_t1 = std::min(t1, GetSequenceEndTime());
545
546 auto s0 = TimeToSequenceSamples(clip_t0);
547 auto s1 = TimeToSequenceSamples(clip_t1);
548
549 if (s0 != s1)
550 {
551 // use Strong-guarantee
552 GetSequence()->Delete(s0, s1 - s0);
553
554 // use No-fail-guarantee in the remaining
555
556 // msmeyer
557 //
558 // Delete all cutlines that are within the given area, if any.
559 //
560 // Note that when cutlines are active, two functions are used:
561 // Clear() and ClearAndAddCutLine(). ClearAndAddCutLine() is called
562 // whenever the user directly calls a command that removes some audio, e.g.
563 // "Cut" or "Clear" from the menu. This command takes care about recursive
564 // preserving of cutlines within clips. Clear() is called when internal
565 // operations want to remove audio. In the latter case, it is the right
566 // thing to just remove all cutlines within the area.
567 //
568
569 // May DELETE as we iterate, so don't use range-for
570 for (auto it = mCutLines.begin(); it != mCutLines.end();)
571 {
572 WaveClip* clip = it->get();
573 double cutlinePosition = GetSequenceStartTime() + clip->GetSequenceStartTime();
574 if (cutlinePosition >= t0 && cutlinePosition <= t1)
575 {
576 // This cutline is within the area, DELETE it
577 it = mCutLines.erase(it);
578 }
579 else
580 {
581 if (cutlinePosition >= t1)
582 {
583 clip->Offset(clip_t0 - clip_t1);
584 }
585 ++it;
586 }
587 }
588
589 // Collapse envelope
590 auto sampleTime = 1.0 / GetRate();
591 GetEnvelope()->CollapseRegion(t0, t1, sampleTime);
592 }
593
594
595 MarkChanged();
596}

References Envelope::CollapseRegion(), Sequence::Delete(), GetEnvelope(), GetRate(), GetSequence(), GetSequenceEndTime(), GetSequenceStartTime(), MarkChanged(), mCutLines, min(), Offset(), and TimeToSequenceSamples().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseLock()

void WaveClip::CloseLock ( )

Definition at line 728 of file WaveClip.cpp.

729{
731 for (const auto &cutline: mCutLines)
732 cutline->CloseLock();
733}
bool CloseLock()
Definition: Sequence.cpp:87

References Sequence::CloseLock(), GetSequence(), and mCutLines.

Here is the call graph for this function:

◆ ConvertToSampleFormat()

void WaveClip::ConvertToSampleFormat ( sampleFormat  format,
const std::function< void(size_t)> &  progressReport = {} 
)

Definition at line 207 of file WaveClip.cpp.

209{
210 // Note: it is not necessary to do this recursively to cutlines.
211 // They get converted as needed when they are expanded.
212
213 auto bChanged = mSequence->ConvertToSampleFormat(format, progressReport);
214 if (bChanged)
215 MarkChanged();
216}

References format, MarkChanged(), and mSequence.

Here is the call graph for this function:

◆ CountSamples()

sampleCount WaveClip::CountSamples ( double  t0,
double  t1 
) const

Counts number of samples within t0 and t1 region. t0 and t1 are rounded to the nearest clip sample boundary, i.e. relative to clips start time offset.

Returns
Number of samples within t0 and t1 if t1 > t0, 0 otherwise

Definition at line 1017 of file WaveClip.cpp.

1018{
1019 if(t0 < t1)
1020 {
1021 t0 = std::max(t0, GetPlayStartTime());
1022 t1 = std::min(t1, GetPlayEndTime());
1023 const auto s0 = TimeToSamples(t0 - GetPlayStartTime());
1024 const auto s1 = TimeToSamples(t1 - GetPlayStartTime());
1025 return s1 - s0;
1026 }
1027 return { 0 };
1028}

References GetPlayEndTime(), GetPlayStartTime(), min(), and TimeToSamples().

Referenced by ClearAndAddCutLine(), and WaveClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExpandCutLine()

void WaveClip::ExpandCutLine ( double  cutLinePosition)

Expand cut line (that is, re-insert audio, then DELETE audio saved in cut line). Returns true if a cut line could be found and successfully expanded, false otherwise

Exception safety guarantee:
Strong

Definition at line 670 of file WaveClip.cpp.

671{
672 auto end = mCutLines.end();
673 auto it = std::find_if( mCutLines.begin(), end,
674 [&](const WaveClipHolder &cutline) {
675 return fabs(GetSequenceStartTime() + cutline->GetSequenceStartTime() - cutLinePosition) < 0.0001;
676 } );
677
678 if ( it != end ) {
679 auto cutline = it->get();
680 // assume Strong-guarantee from Paste
681
682 // Envelope::Paste takes offset into account, WaveClip::Paste doesn't!
683 // Do this to get the right result:
684 cutline->mEnvelope->SetOffset(0);
685
686 Paste(GetSequenceStartTime()+cutline->GetSequenceStartTime(), cutline);
687 // Now erase the cutline,
688 // but be careful to find it again, because Paste above may
689 // have modified the array of cutlines (if our cutline contained
690 // another cutline!), invalidating the iterator we had.
691 end = mCutLines.end();
692 it = std::find_if(mCutLines.begin(), end,
693 [=](const WaveClipHolder &p) { return p.get() == cutline; });
694 if (it != end)
695 mCutLines.erase(it); // deletes cutline!
696 else {
697 wxASSERT(false);
698 }
699 }
700}
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:41
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:374
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), GetSequenceStartTime(), mCutLines, and Paste().

Here is the call graph for this function:

◆ FindCutLine()

bool WaveClip::FindCutLine ( double  cutLinePosition,
double *  cutLineStart = NULL,
double *  cutLineEnd = NULL 
) const

Find cut line at (approximately) this position. Returns true and fills in cutLineStart and cutLineEnd (if specified) if a cut line at this position could be found. Return false otherwise.

Definition at line 649 of file WaveClip.cpp.

652{
653 for (const auto &cutline: mCutLines)
654 {
655 if (fabs(GetSequenceStartTime() + cutline->GetSequenceStartTime() - cutLinePosition) < 0.0001)
656 {
657 auto startTime = GetSequenceStartTime() + cutline->GetSequenceStartTime();
658 if (cutlineStart)
659 *cutlineStart = startTime;
660 if (cutlineEnd)
661 *cutlineEnd = startTime + cutline->SamplesToTime(cutline->GetPlaySamplesCount());
662 return true;
663 }
664 }
665
666 return false;
667}

References GetSequenceStartTime(), and mCutLines.

Here is the call graph for this function:

◆ Flush()

void WaveClip::Flush ( )

Flush must be called after last Append.

Exception safety guarantee:
Mixed
Exception safety guarantee:
No-fail – The clip will be in a flushed state.
Exception safety guarantee:
Partial – Some initial portion (maybe none) of the append buffer of the clip gets appended; no previously flushed contents are lost.

Definition at line 260 of file WaveClip.cpp.

261{
262 //wxLogDebug(wxT("WaveClip::Flush"));
263 //wxLogDebug(wxT(" mAppendBufferLen=%lli"), (long long) mAppendBufferLen);
264 //wxLogDebug(wxT(" previous sample count %lli"), (long long) mSequence->GetNumSamples());
265
266 if (GetAppendBufferLen() > 0) {
267
268 auto cleanup = finally( [&] {
270 MarkChanged();
271 } );
272
273 mSequence->Flush();
274 }
275
276 //wxLogDebug(wxT("now sample count %lli"), (long long) mSequence->GetNumSamples());
277}

References GetAppendBufferLen(), MarkChanged(), mSequence, and UpdateEnvelopeTrackLen().

Referenced by WaveTrack::Flush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAppendBuffer()

constSamplePtr WaveClip::GetAppendBuffer ( ) const

Definition at line 157 of file WaveClip.cpp.

158{
159 return GetSequence()->GetAppendBuffer();
160}
constSamplePtr GetAppendBuffer() const
Definition: Sequence.h:221

References Sequence::GetAppendBuffer(), and GetSequence().

Referenced by WaveClipWaveformCache::GetWaveDisplay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAppendBufferLen()

size_t WaveClip::GetAppendBufferLen ( ) const

Definition at line 152 of file WaveClip.cpp.

153{
155}
size_t GetAppendBufferLen() const
Definition: Sequence.h:220

References Sequence::GetAppendBufferLen(), and GetSequence().

Referenced by AfterPlayEndTime(), Flush(), GetPlayEndTime(), GetSequenceEndTime(), WaveClipWaveformCache::GetWaveDisplay(), and WithinPlayRegion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetColourIndex()

int WaveClip::GetColourIndex ( ) const
inline

Definition at line 150 of file WaveClip.h.

150{ return mColourIndex;};

Referenced by anonymous_namespace{WaveformView.cpp}::DrawClipWaveform().

Here is the caller graph for this function:

◆ GetCutLines() [1/2]

WaveClipHolders & WaveClip::GetCutLines ( )
inline

Get access to cut lines list.

Definition at line 298 of file WaveClip.h.

298{ return mCutLines; }

◆ GetCutLines() [2/2]

const WaveClipConstHolders & WaveClip::GetCutLines ( ) const
inline

Definition at line 299 of file WaveClip.h.

300 { return reinterpret_cast< const WaveClipConstHolders& >( mCutLines ); }
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Definition: WaveClip.h:43

◆ GetEnvelope() [1/2]

Envelope * WaveClip::GetEnvelope ( )
inline

Definition at line 219 of file WaveClip.h.

219{ return mEnvelope.get(); }

Referenced by SetEnvelopeCommand::ApplyInner(), ClearAndAddCutLine(), ClearSequence(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), WaveTrack::GetEnvelopeAtTime(), AUPImportFileHandle::HandleEnvelope(), WaveTrack::HandleXMLChild(), and InsertSilence().

Here is the caller graph for this function:

◆ GetEnvelope() [2/2]

const Envelope * WaveClip::GetEnvelope ( ) const
inline

Definition at line 220 of file WaveClip.h.

220{ return mEnvelope.get(); }

◆ GetIsPlaceholder()

bool WaveClip::GetIsPlaceholder ( ) const
inline

Definition at line 334 of file WaveClip.h.

334{ return mIsPlaceholder; }

Referenced by WaveClip().

Here is the caller graph for this function:

◆ GetMinMax()

std::pair< float, float > WaveClip::GetMinMax ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Getting high-level data for screen display and clipping calculations and Contrast

Definition at line 167 of file WaveClip.cpp.

169{
170 t0 = std::max(t0, GetPlayStartTime());
171 t1 = std::min(t1, GetPlayEndTime());
172 if (t0 > t1) {
173 if (mayThrow)
175 return {
176 0.f, // harmless, but unused since Sequence::GetMinMax does not use these values
177 0.f // harmless, but unused since Sequence::GetMinMax does not use these values
178 };
179 }
180
181 if (t0 == t1)
182 return{ 0.f, 0.f };
183
184 auto s0 = TimeToSequenceSamples(t0);
185 auto s1 = TimeToSequenceSamples(t1);
186
187 return mSequence->GetMinMax(s0, s1-s0, mayThrow);
188}
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.

References GetPlayEndTime(), GetPlayStartTime(), min(), mSequence, THROW_INCONSISTENCY_EXCEPTION, and TimeToSequenceSamples().

Here is the call graph for this function:

◆ GetName()

const wxString & WaveClip::GetName ( ) const

Definition at line 852 of file WaveClip.cpp.

853{
854 return mName;
855}

References mName.

◆ GetPlayEndSample()

sampleCount WaveClip::GetPlayEndSample ( ) const

Definition at line 905 of file WaveClip.cpp.

906{
908}
sampleCount GetPlaySamplesCount() const
Definition: WaveClip.cpp:910

References GetPlaySamplesCount(), and GetPlayStartSample().

Referenced by AfterPlayEndTime(), EffectReverse::ProcessOneWave(), and WithinPlayRegion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlayEndTime()

double WaveClip::GetPlayEndTime ( ) const

Definition at line 888 of file WaveClip.cpp.

889{
890 auto numSamples = mSequence->GetNumSamples();
891
892 double maxLen = GetSequenceStartTime() + ((numSamples + GetAppendBufferLen()).as_double()) / mRate
894 // JS: calculated value is not the length;
895 // it is a maximum value and can be negative; no clipping to 0
896
897 return maxLen;
898}

References GetAppendBufferLen(), GetSequenceStartTime(), mRate, mSequence, mTrimRight, SamplesToTime(), and TimeToSamples().

Referenced by AUPImportFileHandle::AddSilence(), AppendSilence(), SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::CanInsertClip(), Clear(), ClearAndAddCutLine(), WaveTrack::ClearAndPaste(), ClearLeft(), ClearRight(), ClipParameters::ClipParameters(), CountSamples(), ClipParameters::GetClipRect(), GetMinMax(), InsertSilence(), WaveTrackUtils::IsClipSelected(), WaveTrack::MergeClips(), Paste(), WaveTrack::PasteWaveTrack(), TrimLeftTo(), WaveTrackLocations::Update(), and WaveClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlaySamplesCount()

sampleCount WaveClip::GetPlaySamplesCount ( ) const

Definition at line 910 of file WaveClip.cpp.

911{
912 return mSequence->GetNumSamples()
914}

References mSequence, mTrimLeft, mTrimRight, and TimeToSamples().

Referenced by anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), GetPlayEndSample(), and SharesBoundaryWithNextClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlayStartSample()

sampleCount WaveClip::GetPlayStartSample ( ) const

Definition at line 900 of file WaveClip.cpp.

901{
903}

References GetPlayStartTime(), and TimeToSamples().

Referenced by BeforePlayStartTime(), GetPlayEndSample(), EffectReverse::ProcessOneWave(), and WithinPlayRegion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlayStartTime()

double WaveClip::GetPlayStartTime ( ) const
noexcept

Definition at line 878 of file WaveClip.cpp.

References mSequenceOffset, mTrimLeft, SamplesToTime(), and TimeToSamples().

Referenced by SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::CanInsertClip(), Clear(), ClearAndAddCutLine(), WaveTrack::ClearAndPaste(), ClearLeft(), ClearRight(), ClipParameters::ClipParameters(), CountSamples(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), ClipParameters::GetClipRect(), GetMinMax(), GetPlayStartSample(), InsertSilence(), WaveTrackUtils::IsClipSelected(), Paste(), WaveTrack::PasteWaveTrack(), WaveTrack::RightmostOrNewClip(), SharesBoundaryWithNextClip(), TrimRightTo(), and WaveClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRate()

int WaveClip::GetRate ( ) const
inline

Definition at line 140 of file WaveClip.h.

140{ return mRate; }

Referenced by ClearAndAddCutLine(), ClearSequence(), ClipParameters::ClipParameters(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), ClipParameters::GetClipRect(), WaveClipSpectrumCache::GetSpectrogram(), WaveClipWaveformCache::GetWaveDisplay(), InsertSilence(), Paste(), SharesBoundaryWithNextClip(), and UpdateEnvelopeTrackLen().

Here is the caller graph for this function:

◆ GetRMS()

float WaveClip::GetRMS ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 190 of file WaveClip.cpp.

191{
192 if (t0 > t1) {
193 if (mayThrow)
195 return 0.f;
196 }
197
198 if (t0 == t1)
199 return 0.f;
200
201 auto s0 = TimeToSequenceSamples(t0);
202 auto s1 = TimeToSequenceSamples(t1);
203
204 return mSequence->GetRMS(s0, s1-s0, mayThrow);
205}

References mSequence, THROW_INCONSISTENCY_EXCEPTION, and TimeToSequenceSamples().

Here is the call graph for this function:

◆ GetSamples()

bool WaveClip::GetSamples ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len,
bool  mayThrow = true 
) const

Definition at line 124 of file WaveClip.cpp.

126{
127 return mSequence->Get(buffer, format, start + TimeToSamples(mTrimLeft), len, mayThrow);
128}

References format, mSequence, mTrimLeft, and TimeToSamples().

Referenced by anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSequence() [1/2]

Sequence * WaveClip::GetSequence ( )
inline

Definition at line 227 of file WaveClip.h.

227{ return mSequence.get(); }

Referenced by ClearAndAddCutLine(), ClearSequence(), CloseLock(), GetAppendBuffer(), GetAppendBufferLen(), WaveTrack::GetIdealBlockSize(), WaveTrack::GetSequenceAtTime(), WaveClipWaveformCache::GetWaveDisplay(), AUPImportFileHandle::HandleSequence(), WaveTrack::HandleXMLChild(), InsertSilence(), and SetSilence().

Here is the caller graph for this function:

◆ GetSequence() [2/2]

const Sequence * WaveClip::GetSequence ( ) const
inline

Definition at line 228 of file WaveClip.h.

228{ return mSequence.get(); }

◆ GetSequenceBlockArray() [1/2]

BlockArray * WaveClip::GetSequenceBlockArray ( )

Definition at line 142 of file WaveClip.cpp.

143{
144 return &mSequence->GetBlockArray();
145}

References mSequence.

◆ GetSequenceBlockArray() [2/2]

const BlockArray * WaveClip::GetSequenceBlockArray ( ) const

Definition at line 147 of file WaveClip.cpp.

148{
149 return &mSequence->GetBlockArray();
150}

References mSequence.

◆ GetSequenceEndSample()

sampleCount WaveClip::GetSequenceEndSample ( ) const

Returns the index of the sample next after the last sample of the underlying sequence.

Definition at line 984 of file WaveClip.cpp.

985{
986 return GetSequenceStartSample() + mSequence->GetNumSamples();
987}
sampleCount GetSequenceStartSample() const
Returns the index of the first sample of the underlying sequence.
Definition: WaveClip.cpp:979

References GetSequenceStartSample(), and mSequence.

Here is the call graph for this function:

◆ GetSequenceEndTime()

double WaveClip::GetSequenceEndTime ( ) const

Definition at line 968 of file WaveClip.cpp.

969{
970 auto numSamples = mSequence->GetNumSamples();
971
972 double maxLen = GetSequenceStartTime() + (numSamples + GetAppendBufferLen()).as_double() / mRate;
973 // JS: calculated value is not the length;
974 // it is a maximum value and can be negative; no clipping to 0
975
976 return maxLen;
977}

References GetAppendBufferLen(), GetSequenceStartTime(), mRate, and mSequence.

Referenced by Clear(), ClearRight(), ClearSequence(), InsertSilence(), Paste(), TimeToSequenceSamples(), TrimRightTo(), and WaveClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSequenceSamplesCount()

sampleCount WaveClip::GetSequenceSamplesCount ( ) const

Returns the total number of samples in underlying sequence (not counting the cutlines)

Definition at line 873 of file WaveClip.cpp.

874{
875 return mSequence->GetNumSamples();
876}

References mSequence.

Referenced by WaveClipSpectrumCache::GetSpectrogram().

Here is the caller graph for this function:

◆ GetSequenceStartSample()

sampleCount WaveClip::GetSequenceStartSample ( ) const

Returns the index of the first sample of the underlying sequence.

Definition at line 979 of file WaveClip.cpp.

980{
982}

References mSequenceOffset, and TimeToSamples().

Referenced by GetSequenceEndSample(), and ToSequenceSamples().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSequenceStartTime()

double WaveClip::GetSequenceStartTime ( ) const
noexcept

Definition at line 956 of file WaveClip.cpp.

957{
958 // JS: mSequenceOffset is the minimum value and it is returned; no clipping to 0
959 return mSequenceOffset;
960}

References mSequenceOffset.

Referenced by Clear(), ClearAndAddCutLine(), WaveTrack::ClearAndPaste(), ClearLeft(), ClearSequence(), ExpandCutLine(), FindCutLine(), GetPlayEndTime(), GetSequenceEndTime(), WaveClipSpectrumCache::GetSpectrogram(), InsertSilence(), OffsetCutLines(), Paste(), RemoveCutLine(), TimeToSequenceSamples(), TrimLeftTo(), WaveTrackLocations::Update(), and WaveClip().

Here is the caller graph for this function:

◆ GetTrimLeft()

double WaveClip::GetTrimLeft ( ) const
noexcept

Returns the play start offset in seconds from the beginning of the underlying sequence.

Definition at line 921 of file WaveClip.cpp.

922{
923 return mTrimLeft;
924}

References mTrimLeft.

Referenced by Clear(), WaveTrack::ClearAndPaste(), WaveClipSpectrumCache::GetSpectrogram(), WaveClipWaveformCache::GetWaveDisplay(), Paste(), and SetSilence().

Here is the caller graph for this function:

◆ GetTrimRight()

double WaveClip::GetTrimRight ( ) const
noexcept

Returns the play end offset in seconds from the ending of the underlying sequence.

Definition at line 931 of file WaveClip.cpp.

932{
933 return mTrimRight;
934}

References mTrimRight.

Referenced by WaveTrack::ClearAndPaste(), WaveClipSpectrumCache::GetSpectrogram(), and Paste().

Here is the caller graph for this function:

◆ HandleXMLChild()

XMLTagHandler * WaveClip::HandleXMLChild ( const std::string_view &  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 332 of file WaveClip.cpp.

333{
334 if (tag == "sequence")
335 return mSequence.get();
336 else if (tag == "envelope")
337 return mEnvelope.get();
338 else if (tag == "waveclip")
339 {
340 // Nested wave clips are cut lines
341 auto format = mSequence->GetSampleFormats().Stored();
342 // The format is not stored in WaveClip itself but passed to
343 // Sequence::Sequence; but then the Sequence will deserialize format
344 // again
345 mCutLines.push_back(
346 std::make_unique<WaveClip>(mSequence->GetFactory(),
347 format, mRate, 0 /*colourindex*/));
348 return mCutLines.back().get();
349 }
350 else
351 return NULL;
352}

References format, mCutLines, mEnvelope, mRate, and mSequence.

Referenced by AUPImportFileHandle::HandleWaveClip().

Here is the caller graph for this function:

◆ HandleXMLEndTag()

void WaveClip::HandleXMLEndTag ( const std::string_view &  tag)
override

Definition at line 326 of file WaveClip.cpp.

327{
328 if (tag == "waveclip")
330}

References UpdateEnvelopeTrackLen().

Referenced by WaveTrack::HandleXMLEndTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleXMLTag()

bool WaveClip::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 279 of file WaveClip.cpp.

280{
281 if (tag == "waveclip")
282 {
283 double dblValue;
284 long longValue;
285 for (auto pair : attrs)
286 {
287 auto attr = pair.first;
288 auto value = pair.second;
289
290 if (attr == "offset")
291 {
292 if (!value.TryGet(dblValue))
293 return false;
294 SetSequenceStartTime(dblValue);
295 }
296 else if (attr == "trimLeft")
297 {
298 if (!value.TryGet(dblValue))
299 return false;
300 SetTrimLeft(dblValue);
301 }
302 else if (attr == "trimRight")
303 {
304 if (!value.TryGet(dblValue))
305 return false;
306 SetTrimRight(dblValue);
307 }
308 else if (attr == "name")
309 {
310 if(value.IsStringView())
311 SetName(value.ToWString());
312 }
313 else if (attr == "colorindex")
314 {
315 if (!value.TryGet(longValue))
316 return false;
317 SetColourIndex(longValue);
318 }
319 }
320 return true;
321 }
322
323 return false;
324}
void SetName(const wxString &name)
Definition: WaveClip.cpp:847
void SetColourIndex(int index)
Definition: WaveClip.h:149

References SetColourIndex(), SetName(), SetSequenceStartTime(), SetTrimLeft(), and SetTrimRight().

Here is the call graph for this function:

◆ InsertSilence()

void WaveClip::InsertSilence ( double  t,
double  len,
double *  pEnvelopeValue = nullptr 
)

Insert silence - note that this is an efficient operation for large amounts of silence

Exception safety guarantee:
Strong

Definition at line 453 of file WaveClip.cpp.

454{
455 if (t == GetPlayStartTime() && t > GetSequenceStartTime())
457 else if (t == GetPlayEndTime() && t < GetSequenceEndTime()) {
459 SetTrimRight(.0);
460 }
461
462 auto s0 = TimeToSequenceSamples(t);
463 auto slen = (sampleCount)floor(len * mRate + 0.5);
464
465 // use Strong-guarantee
466 GetSequence()->InsertSilence(s0, slen);
467
468 // use No-fail-guarantee
469 OffsetCutLines(t, len);
470
471 const auto sampleTime = 1.0 / GetRate();
472 auto pEnvelope = GetEnvelope();
473 if ( pEnvelopeValue ) {
474
475 // Preserve limit value at the end
476 auto oldLen = pEnvelope->GetTrackLen();
477 auto newLen = oldLen + len;
478 pEnvelope->Cap( sampleTime );
479
480 // Ramp across the silence to the given value
481 pEnvelope->SetTrackLen( newLen, sampleTime );
482 pEnvelope->InsertOrReplace
483 ( pEnvelope->GetOffset() + newLen, *pEnvelopeValue );
484 }
485 else
486 pEnvelope->InsertSpace( t, len );
487
488 MarkChanged();
489}
void InsertSilence(sampleCount s0, sampleCount len)
Definition: Sequence.cpp:707
void OffsetCutLines(double t0, double len)
Offset cutlines right to time 't0' by time amount 'len'.
Definition: WaveClip.cpp:719
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References ClearSequence(), GetEnvelope(), GetPlayEndTime(), GetPlayStartTime(), GetRate(), GetSequence(), GetSequenceEndTime(), GetSequenceStartTime(), Sequence::InsertSilence(), MarkChanged(), mRate, OffsetCutLines(), SetTrimRight(), and TimeToSequenceSamples().

Referenced by AUPImportFileHandle::AddSilence(), and AppendSilence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MarkChanged()

void WaveClip::MarkChanged ( )

WaveTrack calls this whenever data in the wave clip changes. It is called automatically when WaveClip has a chance to know that something has changed, like when member functions SetSamples() etc. are called.

Exception safety guarantee:
No-fail

Definition at line 162 of file WaveClip.cpp.

163{
164 Caches::ForEach( std::mem_fn( &WaveClipListener::MarkChanged ) );
165}
virtual void MarkChanged()=0

References WaveClipListener::MarkChanged().

Referenced by Append(), ClearAndAddCutLine(), ClearSequence(), ConvertToSampleFormat(), Flush(), InsertSilence(), Paste(), SetRate(), SetSamples(), and SetSilence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NumCutLines()

size_t WaveClip::NumCutLines ( ) const
inline

Definition at line 301 of file WaveClip.h.

301{ return mCutLines.size(); }

Referenced by WaveTrackLocations::Update().

Here is the caller graph for this function:

◆ Offset()

void WaveClip::Offset ( double  delta)
noexcept
Exception safety guarantee:
No-fail

Definition at line 989 of file WaveClip.cpp.

990{
992}

Referenced by Clear(), ClearAndAddCutLine(), WaveTrack::ClearAndPaste(), ClearSequence(), and WaveTrack::Copy().

Here is the caller graph for this function:

◆ OffsetCutLines()

void WaveClip::OffsetCutLines ( double  t0,
double  len 
)

Offset cutlines right to time 't0' by time amount 'len'.

Exception safety guarantee:
No-fail

Definition at line 719 of file WaveClip.cpp.

720{
721 for (const auto &cutLine : mCutLines)
722 {
723 if (GetSequenceStartTime() + cutLine->GetSequenceStartTime() >= t0)
724 cutLine->Offset(len);
725 }
726}

References GetSequenceStartTime(), and mCutLines.

Referenced by InsertSilence(), and Paste().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

WaveClip & WaveClip::operator= ( const WaveClip )
private

◆ Paste()

void WaveClip::Paste ( double  t0,
const WaveClip other 
)

Paste data from other clip, resampling it if not equal rate.

Exception safety guarantee:
Strong

Definition at line 374 of file WaveClip.cpp.

375{
376 const bool clipNeedsResampling = other->mRate != mRate;
377 const bool clipNeedsNewFormat =
378 other->mSequence->GetSampleFormats().Stored()
379 != mSequence->GetSampleFormats().Stored();
380 std::unique_ptr<WaveClip> newClip;
381
382 t0 = std::clamp(t0, GetPlayStartTime(), GetPlayEndTime());
383
384 //seems like edge cases cannot happen, see WaveTrack::PasteWaveTrack
385 if (t0 == GetPlayStartTime())
386 {
388 SetTrimLeft(other->GetTrimLeft());
389
390 auto copy = std::make_unique<WaveClip>(*other, mSequence->GetFactory(), true);
391 copy->ClearSequence(copy->GetPlayEndTime(), copy->GetSequenceEndTime());
392 newClip = std::move(copy);
393 }
394 else if (t0 == GetPlayEndTime())
395 {
397 SetTrimRight(other->GetTrimRight());
398
399 auto copy = std::make_unique<WaveClip>(*other, mSequence->GetFactory(), true);
400 copy->ClearSequence(copy->GetSequenceStartTime(), copy->GetPlayStartTime());
401 newClip = std::move(copy);
402 }
403 else
404 {
405 newClip = std::make_unique<WaveClip>(*other, mSequence->GetFactory(), true);
406 newClip->ClearSequence(newClip->GetPlayEndTime(), newClip->GetSequenceEndTime());
407 newClip->ClearSequence(newClip->GetSequenceStartTime(), newClip->GetPlayStartTime());
408 newClip->SetTrimLeft(0);
409 newClip->SetTrimRight(0);
410 }
411
412 if (clipNeedsResampling || clipNeedsNewFormat)
413 {
414 auto copy = std::make_unique<WaveClip>(*newClip.get(), mSequence->GetFactory(), true);
415 if (clipNeedsResampling)
416 // The other clip's rate is different from ours, so resample
417 copy->Resample(mRate);
418 if (clipNeedsNewFormat)
419 // Force sample formats to match.
420 copy->ConvertToSampleFormat(mSequence->GetSampleFormats().Stored());
421 newClip = std::move(copy);
422 }
423
424 // Paste cut lines contained in pasted clip
425 WaveClipHolders newCutlines;
426 for (const auto &cutline: newClip->mCutLines)
427 {
428 auto cutlineCopy = std::make_unique<WaveClip>(*cutline, mSequence->GetFactory(),
429 // Recursively copy cutlines of cutlines. They don't need
430 // their offsets adjusted.
431 true);
432 cutlineCopy->Offset(t0 - GetSequenceStartTime());
433 newCutlines.push_back(std::move(cutlineCopy));
434 }
435
437
438 // Assume Strong-guarantee from Sequence::Paste
439 mSequence->Paste(s0, newClip->mSequence.get());
440
441 // Assume No-fail-guarantee in the remaining
442 MarkChanged();
443 auto sampleTime = 1.0 / GetRate();
444 mEnvelope->PasteEnvelope
445 (s0.as_double()/mRate + GetSequenceStartTime(), newClip->mEnvelope.get(), sampleTime);
446 OffsetCutLines(t0, newClip->GetPlayEndTime() - newClip->GetPlayStartTime());
447
448 for (auto &holder : newCutlines)
449 mCutLines.push_back(std::move(holder));
450}
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:42
double GetTrimRight() const noexcept
Returns the play end offset in seconds from the ending of the underlying sequence.
Definition: WaveClip.cpp:931
double as_double() const
Definition: SampleCount.h:46

References sampleCount::as_double(), ClearSequence(), GetPlayEndTime(), GetPlayStartTime(), GetRate(), GetSequenceEndTime(), GetSequenceStartTime(), GetTrimLeft(), GetTrimRight(), MarkChanged(), mCutLines, mEnvelope, mRate, mSequence, OffsetCutLines(), SetTrimLeft(), SetTrimRight(), and TimeToSequenceSamples().

Referenced by WaveTrack::ClearAndPaste(), ExpandCutLine(), WaveTrack::MergeClips(), and WaveTrack::PasteWaveTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveCutLine()

bool WaveClip::RemoveCutLine ( double  cutLinePosition)

Remove cut line, without expanding the audio in it.

Definition at line 702 of file WaveClip.cpp.

703{
704 for (auto it = mCutLines.begin(); it != mCutLines.end(); ++it)
705 {
706 const auto &cutline = *it;
707 //std::numeric_limits<double>::epsilon() or (1.0 / static_cast<double>(mRate))?
708 if (fabs(GetSequenceStartTime() + cutline->GetSequenceStartTime() - cutLinePosition) < 0.0001)
709 {
710 mCutLines.erase(it); // deletes cutline!
711 return true;
712 }
713 }
714
715 return false;
716}

References GetSequenceStartTime(), and mCutLines.

Here is the call graph for this function:

◆ Resample()

void WaveClip::Resample ( int  rate,
BasicUI::ProgressDialog progress = NULL 
)
Exception safety guarantee:
Strong

We want to keep going as long as we have something to feed the resampler with OR as long as the resampler spews out samples (which could continue for a few iterations after we stop feeding it)

Definition at line 748 of file WaveClip.cpp.

749{
750 // Note: it is not necessary to do this recursively to cutlines.
751 // They get resampled as needed when they are expanded.
752
753 if (rate == mRate)
754 return; // Nothing to do
755
756 double factor = (double)rate / (double)mRate;
757 ::Resample resample(true, factor, factor); // constant rate resampling
758
759 const size_t bufsize = 65536;
760 Floats inBuffer{ bufsize };
761 Floats outBuffer{ bufsize };
762 sampleCount pos = 0;
763 bool error = false;
764 int outGenerated = 0;
765 auto numSamples = mSequence->GetNumSamples();
766
767 // This sequence is appended to below
768 auto newSequence = std::make_unique<Sequence>(
769 mSequence->GetFactory(), mSequence->GetSampleFormats());
770
776 while (pos < numSamples || outGenerated > 0)
777 {
778 const auto inLen = limitSampleBufferSize( bufsize, numSamples - pos );
779
780 bool isLast = ((pos + inLen) == numSamples);
781
782 if (!mSequence->Get((samplePtr)inBuffer.get(), floatSample, pos, inLen, true))
783 {
784 error = true;
785 break;
786 }
787
788 const auto results = resample.Process(factor, inBuffer.get(), inLen, isLast,
789 outBuffer.get(), bufsize);
790 outGenerated = results.second;
791
792 pos += results.first;
793
794 if (outGenerated < 0)
795 {
796 error = true;
797 break;
798 }
799
800 newSequence->Append((samplePtr)outBuffer.get(), floatSample,
801 outGenerated, 1,
802 widestSampleFormat /* computed samples need dither */
803 );
804
805 if (progress)
806 {
807 auto updateResult = progress->Poll(
808 pos.as_long_long(),
809 numSamples.as_long_long()
810 );
811 error = (updateResult != BasicUI::ProgressResult::Success);
812 if (error)
813 throw UserException{};
814 }
815 }
816
817 if (error)
820 XO("Resampling failed."),
821 XO("Warning"),
822 "Error:_Resampling"
823 };
824 else
825 {
826 // Use No-fail-guarantee in these steps
827 mSequence = std::move(newSequence);
828 mRate = rate;
829 Caches::ForEach( std::mem_fn( &WaveClipListener::Invalidate ) );
830 }
831}
@ Internal
Indicates internal failure from Audacity.
XO("Cut/Copy/Paste")
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:22
char * samplePtr
Definition: SampleFormat.h:55
virtual ProgressResult Poll(unsigned long long numerator, unsigned long long denominator, const TranslatableString &message={})=0
Update the bar and poll for clicks. Call only on the main thread.
Interface to libsoxr.
Definition: Resample.h:27
A MessageBoxException that shows a given, unvarying string.
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
virtual void Invalidate()=0

References floatSample, Internal, WaveClipListener::Invalidate(), limitSampleBufferSize(), mRate, mSequence, BasicUI::ProgressDialog::Poll(), Resample::Process(), BasicUI::Success, widestSampleFormat, and XO().

Here is the call graph for this function:

◆ SamplesToTime()

double WaveClip::SamplesToTime ( sampleCount  s) const
noexcept

Definition at line 862 of file WaveClip.cpp.

863{
864 return s.as_double() / mRate;
865}

Referenced by GetPlayEndTime(), GetPlayStartTime(), SetRate(), and WaveClip().

Here is the caller graph for this function:

◆ SetColourIndex()

void WaveClip::SetColourIndex ( int  index)
inline

Definition at line 149 of file WaveClip.h.

149{ mColourIndex = index;};

Referenced by SetClipCommand::ApplyInner(), and HandleXMLTag().

Here is the caller graph for this function:

◆ SetIsPlaceholder()

void WaveClip::SetIsPlaceholder ( bool  val)
inline

Definition at line 335 of file WaveClip.h.

335{ mIsPlaceholder = val; }

◆ SetName()

void WaveClip::SetName ( const wxString &  name)

Definition at line 847 of file WaveClip.cpp.

848{
849 mName = name;
850}
const TranslatableString name
Definition: Distortion.cpp:76

References mName, and name.

Referenced by SetClipCommand::ApplyInner(), HandleXMLTag(), and PasteOverPreservingClips().

Here is the caller graph for this function:

◆ SetPlayStartTime()

void WaveClip::SetPlayStartTime ( double  time)

Definition at line 883 of file WaveClip.cpp.

884{
886}

References mTrimLeft, and SetSequenceStartTime().

Referenced by SetClipCommand::ApplyInner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRate()

void WaveClip::SetRate ( int  rate)

Definition at line 735 of file WaveClip.cpp.

736{
737 const auto trimLeftSampleNum = TimeToSamples(mTrimLeft);
738 const auto trimRightSampleNum = TimeToSamples(mTrimRight);
739 mRate = rate;
740 mTrimLeft = SamplesToTime(trimLeftSampleNum);
741 mTrimRight = SamplesToTime(trimRightSampleNum);
742 auto newLength = mSequence->GetNumSamples().as_double() / mRate;
743 mEnvelope->RescaleTimes( newLength );
744 MarkChanged();
745}

References MarkChanged(), mEnvelope, mRate, mSequence, mTrimLeft, mTrimRight, SamplesToTime(), and TimeToSamples().

Here is the call graph for this function:

◆ SetSamples()

void WaveClip::SetSamples ( constSamplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len,
sampleFormat  effectiveFormat 
)
Exception safety guarantee:
Strong
Parameters
effectiveFormatMake the effective format of the data at least the minumum of this value and `format`. (Maybe wider, if merging with preexistent data.) If the data are later narrowed from stored format, but not narrower than the effective, then no dithering will occur.

Definition at line 131 of file WaveClip.cpp.

133{
134 // use Strong-guarantee
135 mSequence->SetSamples(buffer, format,
136 start + TimeToSamples(mTrimLeft), len, effectiveFormat);
137
138 // use No-fail-guarantee
139 MarkChanged();
140}

References format, MarkChanged(), mSequence, mTrimLeft, and TimeToSamples().

Here is the call graph for this function:

◆ SetSequenceStartTime()

void WaveClip::SetSequenceStartTime ( double  startTime)

Definition at line 962 of file WaveClip.cpp.

963{
964 mSequenceOffset = startTime;
965 mEnvelope->SetOffset(startTime);
966}

References mEnvelope, and mSequenceOffset.

Referenced by WaveTrack::ClearAndPaste(), ClearLeft(), WaveTrack::HandleXMLChild(), HandleXMLTag(), and SetPlayStartTime().

Here is the caller graph for this function:

◆ SetSilence()

void WaveClip::SetSilence ( sampleCount  offset,
sampleCount  length 
)

Silences the 'length' amount of samples starting from 'offset'(relative to the play start)

Definition at line 867 of file WaveClip.cpp.

868{
869 GetSequence()->SetSilence(TimeToSamples(GetTrimLeft()) + offset, length);
870 MarkChanged();
871}
void SetSilence(sampleCount s0, sampleCount len)
Definition: Sequence.cpp:700

References GetSequence(), GetTrimLeft(), MarkChanged(), Sequence::SetSilence(), and TimeToSamples().

Here is the call graph for this function:

◆ SetTrimLeft()

void WaveClip::SetTrimLeft ( double  trim)

Sets the play start offset in seconds from the beginning of the underlying sequence.

Definition at line 916 of file WaveClip.cpp.

917{
918 mTrimLeft = std::max(.0, trim);
919}

References mTrimLeft.

Referenced by Clear(), WaveTrack::ClearAndPaste(), ClearLeft(), HandleXMLTag(), and Paste().

Here is the caller graph for this function:

◆ SetTrimRight()

void WaveClip::SetTrimRight ( double  trim)

Sets the play end offset in seconds from the ending of the underlying sequence.

Definition at line 926 of file WaveClip.cpp.

927{
928 mTrimRight = std::max(.0, trim);
929}

References mTrimRight.

Referenced by Clear(), WaveTrack::ClearAndPaste(), ClearRight(), HandleXMLTag(), InsertSilence(), and Paste().

Here is the caller graph for this function:

◆ SharesBoundaryWithNextClip()

bool WaveClip::SharesBoundaryWithNextClip ( const WaveClip next) const

Definition at line 837 of file WaveClip.cpp.

838{
839 double endThis = GetRate() * GetPlayStartTime() + GetPlaySamplesCount().as_double();
840 double startNext = next->GetRate() * next->GetPlayStartTime();
841
842 // given that a double has about 15 significant digits, using a criterion
843 // of half a sample should be safe in all normal usage.
844 return fabs(startNext - endThis) < 0.5;
845}

References sampleCount::as_double(), GetPlaySamplesCount(), GetPlayStartTime(), and GetRate().

Here is the call graph for this function:

◆ TimeToSamples()

sampleCount WaveClip::TimeToSamples ( double  time) const
noexcept

Definition at line 857 of file WaveClip.cpp.

858{
859 return sampleCount(floor(time * mRate + 0.5));
860}

Referenced by AfterPlayEndTime(), BeforePlayStartTime(), CountSamples(), GetPlayEndTime(), GetPlaySamplesCount(), GetPlayStartSample(), GetPlayStartTime(), GetSamples(), GetSequenceStartSample(), SetRate(), SetSamples(), SetSilence(), TimeToSequenceSamples(), WaveClip(), and WithinPlayRegion().

Here is the caller graph for this function:

◆ TimeToSequenceSamples()

sampleCount WaveClip::TimeToSequenceSamples ( double  t) const

Definition at line 1030 of file WaveClip.cpp.

1031{
1032 if (t < GetSequenceStartTime())
1033 return 0;
1034 else if (t > GetSequenceEndTime())
1035 return mSequence->GetNumSamples();
1036 return TimeToSamples(t - GetSequenceStartTime());
1037}

References GetSequenceEndTime(), GetSequenceStartTime(), mSequence, and TimeToSamples().

Referenced by ClearAndAddCutLine(), ClearSequence(), GetMinMax(), GetRMS(), InsertSilence(), and Paste().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToSequenceSamples()

sampleCount WaveClip::ToSequenceSamples ( sampleCount  s) const

Definition at line 1039 of file WaveClip.cpp.

1040{
1041 return s - GetSequenceStartSample();
1042}

References GetSequenceStartSample().

Here is the call graph for this function:

◆ TrimLeft()

void WaveClip::TrimLeft ( double  deltaTime)

Moves play start position by deltaTime.

Definition at line 936 of file WaveClip.cpp.

937{
938 mTrimLeft += deltaTime;
939}

References mTrimLeft.

◆ TrimLeftTo()

void WaveClip::TrimLeftTo ( double  to)

Sets the the left trimming to the absolute time (if that is in bounds)

Definition at line 946 of file WaveClip.cpp.

947{
949}

References GetPlayEndTime(), GetSequenceStartTime(), and mTrimLeft.

Here is the call graph for this function:

◆ TrimRight()

void WaveClip::TrimRight ( double  deltaTime)

Moves play end position by deltaTime.

Definition at line 941 of file WaveClip.cpp.

942{
943 mTrimRight += deltaTime;
944}

References mTrimRight.

◆ TrimRightTo()

void WaveClip::TrimRightTo ( double  to)

Sets the the right trimming to the absolute time (if that is in bounds)

Definition at line 951 of file WaveClip.cpp.

952{
954}

References GetPlayStartTime(), GetSequenceEndTime(), and mTrimRight.

Here is the call graph for this function:

◆ UpdateEnvelopeTrackLen()

void WaveClip::UpdateEnvelopeTrackLen ( )

Whenever you do an operation to the sequence that will change the number of samples (that is, the length of the clip), you will want to call this function to tell the envelope about it.

Exception safety guarantee:
No-fail

Definition at line 219 of file WaveClip.cpp.

220{
221 auto len = (mSequence->GetNumSamples().as_double()) / mRate;
222 if (len != mEnvelope->GetTrackLen())
223 mEnvelope->SetTrackLen(len, 1.0 / GetRate());
224}

References GetRate(), mEnvelope, mRate, and mSequence.

Referenced by Append(), Flush(), and HandleXMLEndTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WithinPlayRegion()

bool WaveClip::WithinPlayRegion ( double  t) const

Definition at line 999 of file WaveClip.cpp.

1000{
1001 auto ts = TimeToSamples(t);
1002 return ts > GetPlayStartSample() && ts < GetPlayEndSample() + GetAppendBufferLen();
1003}

References GetAppendBufferLen(), GetPlayEndSample(), GetPlayStartSample(), and TimeToSamples().

Here is the call graph for this function:

◆ WriteXML()

void WaveClip::WriteXML ( XMLWriter xmlFile) const

Definition at line 354 of file WaveClip.cpp.

356{
357 xmlFile.StartTag(wxT("waveclip"));
358 xmlFile.WriteAttr(wxT("offset"), mSequenceOffset, 8);
359 xmlFile.WriteAttr(wxT("trimLeft"), mTrimLeft, 8);
360 xmlFile.WriteAttr(wxT("trimRight"), mTrimRight, 8);
361 xmlFile.WriteAttr(wxT("name"), mName);
362 xmlFile.WriteAttr(wxT("colorindex"), mColourIndex );
363
364 mSequence->WriteXML(xmlFile);
365 mEnvelope->WriteXML(xmlFile);
366
367 for (const auto &clip: mCutLines)
368 clip->WriteXML(xmlFile);
369
370 xmlFile.EndTag(wxT("waveclip"));
371}
wxT("CloseDown"))
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102

References wxT().

Here is the call graph for this function:

Member Data Documentation

◆ mColourIndex

int WaveClip::mColourIndex
protected

Definition at line 364 of file WaveClip.h.

Referenced by WaveClip().

◆ mCutLines

WaveClipHolders WaveClip::mCutLines {}
protected

◆ mEnvelope

std::unique_ptr<Envelope> WaveClip::mEnvelope
protected

◆ mIsPlaceholder

bool WaveClip::mIsPlaceholder { false }
protected

Definition at line 374 of file WaveClip.h.

Referenced by WaveClip().

◆ mName

wxString WaveClip::mName
private

Definition at line 377 of file WaveClip.h.

Referenced by GetName(), SetName(), and WaveClip().

◆ mRate

int WaveClip::mRate
protected

◆ mSequence

std::unique_ptr<Sequence> WaveClip::mSequence
protected

◆ mSequenceOffset

double WaveClip::mSequenceOffset { 0 }
protected

◆ mTrimLeft

double WaveClip::mTrimLeft { 0 }
protected

◆ mTrimRight

double WaveClip::mTrimRight { 0 }
protected

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