12#ifndef __AUDACITY_WAVECLIP__
13#define __AUDACITY_WAVECLIP__
24#include <wx/longlong.h>
122 int rate,
int colourIndex);
142 double t0,
double t1);
147 bool CheckInvariants()
const;
151 size_t GetWidth()
const override;
154 const std::function<
void(
size_t)> & progressReport = {});
162 void SetRate(
int rate);
169 double GetStretchRatio()
const override;
173 bool HasEqualStretchRatio(
const WaveClip& other)
const;
174 bool StretchRatioEquals(
double value)
const;
184 double GetSequenceStartTime() const noexcept;
185 void SetSequenceStartTime(
double startTime);
186 double GetSequenceEndTime() const;
195 double GetPlayStartTime() const noexcept override;
196 void SetPlayStartTime(
double time);
200 double GetPlayEndTime() const override;
204 double GetPlayDuration() const;
206 bool IsEmpty() const;
216 sampleCount GetVisibleSampleCount() const override;
219 void SetTrimLeft(
double trim);
221 double GetTrimLeft() const noexcept;
224 void SetTrimRight(
double trim);
226 double GetTrimRight() const noexcept;
229 void TrimLeft(
double deltaTime);
231 void TrimRight(
double deltaTime);
239 void ShiftBy(
double delta) noexcept;
248 bool SplitsPlayRegion(
double t) const;
252 bool WithinPlayRegion(
double t) const;
256 bool BeforePlayRegion(
double t) const;
260 bool AtOrBeforePlayRegion(
double t) const;
264 bool AfterPlayRegion(
double t) const;
269 bool EntirelyWithinPlayRegion(
double t0,
double t1) const;
274 bool PartlyWithinPlayRegion(
double t0,
double t1) const;
279 bool IntersectsPlayRegion(
double t0,
double t1) const;
285 bool CoversEntirePlayRegion(
double t0,
double t1) const;
291 sampleCount CountSamples(
double t0,
double t1) const;
303 bool mayThrow = true) const override;
317 size_t iChannel,
double t0,
double t1,
bool mayThrow = true) const;
326 sampleCount start,
size_t len,
bool mayThrow = true) const;
334 sampleCount start,
size_t len,
bool mayThrow = true) const;
355 GetFloatAtTime(
double t,
size_t iChannel,
float& value,
bool mayThrow) const;
370 void SetFloatsFromTime(
371 double t,
size_t iChannel, const
float* buffer,
size_t numSamples,
380 void SetFloatsCenteredAroundTime(
381 double t,
size_t iChannel, const
float* buffer,
size_t numSideSamples,
388 Envelope* GetEnvelope() {
return mEnvelope.get(); }
390 void SetEnvelope(std::unique_ptr<Envelope> p);
400 const BlockArray* GetSequenceBlockArray(
size_t ii)
const;
409 assert(ii < GetWidth());
410 return mSequences[ii].get();
429 std::pair<float, float> GetMinMax(
size_t ii,
430 double t0,
double t1,
bool mayThrow)
const;
434 float GetRMS(
size_t ii,
double t0,
double t1,
bool mayThrow)
const;
439 void UpdateEnvelopeTrackLen();
443 std::shared_ptr<SampleBlock>
448 void AppendSharedBlock(
const std::shared_ptr<SampleBlock> &pBlock);
459 size_t len,
unsigned int stride,
477 void Clear(
double t0,
double t1);
483 void ClearLeft(
double t);
487 void ClearRight(
double t);
491 void ClearAndAddCutLine(
double t0,
double t1);
498 bool Paste(
double t0,
const WaveClip& other);
502 void InsertSilence(
double t,
double len,
double *pEnvelopeValue =
nullptr );
506 void AppendSilence(
double len,
double envelopeValue );
517 bool FindCutLine(
double cutLinePosition,
518 double* cutLineStart = NULL,
519 double *cutLineEnd = NULL)
const;
524 void ExpandCutLine(
double cutLinePosition);
527 bool RemoveCutLine(
double cutLinePosition);
530 void OffsetCutLines(
double t0,
double len);
534 void CloseLock() noexcept;
540 bool HandleXMLTag(const
std::string_view& tag, const
AttributesList &attrs) override;
541 void HandleXMLEndTag(const
std::string_view& tag) override;
543 void WriteXML(
XMLWriter &xmlFile) const ;
546 bool GetIsPlaceholder()
const {
return mIsPlaceholder; }
550 bool SharesBoundaryWithNextClip(
const WaveClip* next)
const;
552 void SetName(
const wxString&
name);
553 const wxString& GetName()
const;
557 sampleCount TimeToSamples(
double time)
const override;
558 double SamplesToTime(
sampleCount s)
const noexcept;
569 size_t GetAppendBufferLen()
const;
572 OnProjectTempoChange(
const std::optional<double>& oldTempo,
double newTempo);
582 std::vector<std::unique_ptr<Sequence>> GetEmptySequenceCopies()
const;
583 void StretchCutLines(
double ratioChange);
584 double SnapToTrackSample(
double time)
const noexcept;
588 void ClearSequence(
double t0,
double t1);
600 bool committed{
false };
605 double mSequenceOffset { 0 };
606 double mTrimLeft { 0 };
607 double mTrimRight { 0 };
612 double mClipStretchRatio = 1.;
639 bool mIsPlaceholder {
false };
An audio segment is either a whole clip or the silence between clips. Views allow shared references t...
Utility ClientData::Site to register hooks into a host class that attach client data.
const TranslatableString name
std::shared_ptr< SampleBlockFactory > SampleBlockFactoryPtr
std::function< void(double)> ProgressReporter
std::shared_ptr< WaveClip > WaveClipHolder
std::vector< WaveClipHolder > WaveClipHolders
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Append(Adapt< My >([](My &table) { return(WaveChannelSubViews::numFactories() > 1) ? std::make_unique< Entry >("MultiView", Entry::CheckItem, OnMultiViewID, XXO("&Multi-view"), POPUP_MENU_FN(OnMultiView), table, [](PopupMenuHandler &handler, wxMenu &menu, int id){ auto &table=static_cast< WaveTrackMenuTable & >(handler);auto &track=table.FindWaveTrack();const auto &view=WaveChannelView::Get(track);menu.Check(id, view.GetMultiView());}) :nullptr;}))
std::vector< Attribute > AttributesList
Abstraction of a progress dialog with well defined time-to-completion estimate.
Utility to register hooks into a host class that attach client data.
Piecewise linear or piecewise exponential function from double to double.
abstract base class with methods to produce SampleBlock objects
Abstract class allows access to contents of a block of sound samples, serialization as XML,...
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
This allows multiple clips to be a part of one WaveTrack.
std::optional< double > mRawAudioTempo
void SetIsPlaceholder(bool val)
std::unique_ptr< Envelope > mEnvelope
Envelope is unique, not per-sequence.
std::optional< double > mProjectTempo
int GetRate() const override
int mRate
Sample rate of the raw audio, i.e., before stretching.
WaveClipHolders & GetCutLines()
Get access to cut lines list.
void SetColourIndex(int index)
WaveClip(const WaveClip &)=delete
const Sequence * GetSequence(size_t ii) const
Sequence * GetSequence(size_t ii)
const WaveClipConstHolders & GetCutLines() const
size_t NumCutLines() const
int GetColourIndex() const
const Envelope * GetEnvelope() const
Site< WaveClip, WaveClipListener > Caches
std::vector< std::unique_ptr< Sequence > > mSequences
std::vector< float > ownMin
std::vector< sampleCount > ownWhere
std::vector< float > ownMax
std::vector< float > ownRms
This class is an interface which should be implemented by classes which wish to be able to load and s...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Positions or offsets within audio files need a wide type.
void StretchRightTo(WaveTrack::Interval &interval, double t)
void StretchLeftTo(WaveTrack::Interval &interval, double t)
void TrimLeftTo(WaveTrack::Interval &interval, double t)
void TrimRightTo(WaveTrack::Interval &interval, double t)
static RegisteredToolbarFactory factory
Restores state when an update loop over mSequences fails midway.
std::vector< std::unique_ptr< Sequence > > sequences
virtual void MarkChanged()=0
virtual void Invalidate()=0