29 return XO(
"Sets the peak amplitude of a one or more tracks");
54 bool bGoodResult =
true;
57 for (
auto track : outputs.Get().Selected<
WaveTrack>())
59 const double trackStart = track->GetStartTime();
60 const double repair_t0 = std::max(
mT0, trackStart);
61 const double trackEnd = track->GetEndTime();
63 const double repair_deltat = repair_t1 - repair_t0;
64 if (repair_deltat > 0)
66 const auto repair0 = track->TimeToLongSamples(repair_t0);
67 const auto repair1 = track->TimeToLongSamples(repair_t1);
68 const auto repairLen = repair1 - repair0;
72 "The Repair effect cannot be applied within stretched or shrunk clips"));
79 "The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair."));
84 const double rate = track->GetRate();
85 const double spacing = std::max(repair_deltat * 2, 128. / rate);
86 const double t0 = std::max(repair_t0 - spacing, trackStart);
87 const double t1 =
std::min(repair_t1 + spacing, trackEnd);
89 const auto s0 = track->TimeToLongSamples(t0);
90 const auto s1 = track->TimeToLongSamples(t1);
92 const auto repairStart = (repair0 - s0).as_size_t();
93 const auto len = s1 - s0;
95 if (s0 == repair0 && s1 == repair1)
98 "Repair works by using audio data outside the selection region.\n\nPlease select a region that has audio touching at least one side of it.\n\nThe more surrounding audio, the better it performs."));
106 for (
const auto pChannel : track->Channels())
108 count++, *pChannel, s0,
110 len.as_size_t(), repairStart,
112 repairLen.as_size_t()))
129 size_t repairStart,
size_t repairLen)
132 track.
GetFloats(buffer.get(), start, len);
135 &buffer[repairStart], start + repairStart, repairLen,
Toolkit-neutral facade for basic user interface services.
void InterpolateAudio(float *buffer, const size_t len, size_t firstBad, size_t numBad)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
std::shared_ptr< TrackList > mTracks
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Performs effect computation.
Use this object to copy the input tracks to tentative outputTracks.
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
static const ComponentInterfaceSymbol Symbol
ComponentInterfaceSymbol GetSymbol() const override
TranslatableString GetDescription() const override
bool Process(EffectInstance &instance, EffectSettings &settings) override
bool ProcessOne(int count, WaveChannel &track, sampleCount start, size_t len, size_t repairStart, size_t repairLen)
EffectType GetType() const override
Type determines how it behaves.
bool NeedsDither() const override
Holds a msgid for the translation catalog; may also bind format arguments.
bool SetFloats(const float *buffer, sampleCount start, size_t len, sampleFormat effectiveFormat=widestSampleFormat)
Random-access assignment of a range of samples.
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
"narrow" overload fetches from the unique channel
A Track that contains audio waveform data.
Positions or offsets within audio files need a wide type.
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
WAVE_TRACK_API bool HasPitchOrSpeed(const WaveTrack &track, double t0, double t1)
Externalized state of a plug-in.