23#include "../LabelTrack.h"
24#include "../SyncLock.h"
25#include "../WaveClip.h"
26#include "../WaveTrack.h"
54 return XO(
"Reverses the selected audio");
75 bool bGoodResult =
true;
80 trackRange.VisitWhile( bGoodResult,
85 auto len =
end - start;
93 track->ChangeLabelsOnReverse(
mT0,
mT1);
106 auto end = start + len;
111 const auto &clips = track->
GetClips();
113 for (
size_t ii = 0; ii < clips.size(); ++ii) {
114 const auto &clip = clips[ii].get();
115 auto clipStart = clip->GetPlayStartSample();
116 auto clipEnd = clip->GetPlayEndSample();
117 if (clipStart < start && clipEnd > start && clipEnd <=
end) {
121 else if (clipStart >= start && clipStart < end && clipEnd >
end) {
125 else if (clipStart < start && clipEnd >
end) {
137 bool checkedFirstClip =
false;
141 auto currentEnd =
end;
147 for (i=0; i < clipArray.size(); i++) {
153 if (clipStart >= start && clipEnd <=
end) {
158 if(checkedFirstClip ==
false && clipStart > start) {
159 checkedFirstClip =
true;
161 if (clipArray[i-1]->GetPlayEndSample() <= start) {
162 currentEnd -= (clipStart - start);
166 currentEnd -= (clipStart - start);
170 auto revStart = (clipStart >= start)? clipStart: start;
171 auto revEnd = (clipEnd >=
end)?
end: clipEnd;
172 auto revLen = revEnd - revStart;
173 if (revEnd >= revStart) {
180 auto clipOffsetStart = currentEnd - (clipEnd - clipStart);
182 if(i+1 < clipArray.size())
184 auto nextClipStart = clipArray[i+1]->GetPlayStartSample();
185 currentEnd = currentEnd - (clipEnd - clipStart) - (nextClipStart - clipEnd);
192 else if (clipStart >=
end) {
203 for (
auto it = revClips.rbegin(), revEnd = revClips.rend(); rValue && it != revEnd; ++it)
207 for (
auto &clip : otherClips)
208 if (!(rValue = track->
AddClip(clip)))
224 Floats buffer1{ blockSize };
225 Floats buffer2{ blockSize };
227 auto originalLen = originalEnd - originalStart;
232 auto second = first + (len - block);
234 track->
GetFloats(buffer1.get(), first, block);
235 track->
GetFloats(buffer2.get(), second, block);
236 for (
decltype(block) i = 0; i < block; i++) {
238 buffer1[i] = buffer2[block-i-1];
239 buffer2[block-i-1] = tmp;
250 if(
TrackProgress(count, 2 * ( first - originalStart ).as_double() /
251 originalLen.as_double() ) ) {
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
std::vector< WaveClipHolder > WaveClipHolders
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
std::shared_ptr< TrackList > mOutputTracks
void ReplaceProcessedTracks(const bool bGoodResult)
void CopyInputTracks(bool allSyncLockSelected=false)
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Performs effect computation.
static const ComponentInterfaceSymbol Symbol
ComponentInterfaceSymbol GetSymbol() const override
EffectType GetType() const override
Type determines how it behaves.
bool ProcessOneClip(int count, WaveTrack *track, sampleCount start, sampleCount len, sampleCount originalStart, sampleCount originalEnd)
TranslatableString GetDescription() const override
bool Process(EffectInstance &instance, EffectSettings &settings) override
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
bool ProcessOneWave(int count, WaveTrack *track, sampleCount start, sampleCount len)
A LabelTrack is a Track that holds labels (LabelStruct).
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Holds a msgid for the translation catalog; may also bind format arguments.
This allows multiple clips to be a part of one WaveTrack.
sampleCount GetPlayEndSample() const
sampleCount GetPlayStartSample() const
A Track that contains audio waveform data.
bool AddClip(const std::shared_ptr< WaveClip > &clip)
Append a clip to the track; which must have the same block factory as this track; return success.
size_t GetMaxBlockSize() const override
This returns a nonnegative number of samples meant to size a memory buffer.
size_t GetBestBlockSize(sampleCount t) const override
This returns a nonnegative number of samples meant to size a memory buffer.
WaveClipPointers SortedClipArray()
std::shared_ptr< WaveClip > RemoveAndReturnClip(WaveClip *clip)
WaveClipHolders & GetClips()
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len, sampleFormat effectiveFormat=widestSampleFormat)
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
BuiltinEffectsModule::Registration< EffectReverse > reg
Externalized state of a plug-in.