32#include "../WaveTrack.h"
33#include "../widgets/AudacityMessageBox.h"
59 return XO(
"Sets the peak amplitude of a one or more tracks");
81 bool bGoodResult =
true;
86 double trackStart = track->GetStartTime();
87 const double repair_t0 = std::max(
mT0, trackStart);
89 double trackEnd = track->GetEndTime();
92 double repair_deltat = repair_t1 - repair_t0;
93 if (repair_deltat > 0) {
94 const auto repair0 = track->TimeToLongSamples(repair_t0);
95 const auto repair1 = track->TimeToLongSamples(repair_t1);
96 const auto repairLen = repair1 - repair0;
97 if (repairLen > 128) {
100"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.") );
105 const double rate = track->GetRate();
106 const double spacing = std::max(repair_deltat * 2, 128. / rate);
107 const double t0 = std::max(repair_t0 - spacing, trackStart);
108 const double t1 =
std::min(repair_t1 + spacing, trackEnd);
110 const auto s0 = track->TimeToLongSamples(t0);
111 const auto s1 = track->TimeToLongSamples(t1);
113 const auto repairStart = (repair0 - s0).as_size_t();
114 const auto len = s1 - s0;
116 if (s0 == repair0 && s1 == repair1) {
119"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.") );
130 repairLen.as_size_t() )) {
146 size_t repairStart,
size_t repairLen)
149 track->
GetFloats(buffer.get(), start, len);
152 start + repairStart, repairLen);
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 > mOutputTracks
void ReplaceProcessedTracks(const bool bGoodResult)
void CopyInputTracks(bool allSyncLockSelected=false)
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Performs effect computation.
EffectType GetType() const override
Type determines how it behaves.
ComponentInterfaceSymbol GetSymbol() const override
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
bool Process(EffectInstance &instance, EffectSettings &settings) override
Actually do the effect here.
TranslatableString GetDescription() const override
bool ProcessOne(int count, WaveTrack *track, sampleCount start, size_t len, size_t repairStart, size_t repairLen)
static const ComponentInterfaceSymbol Symbol
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.
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Positions or offsets within audio files need a wide type.
BuiltinEffectsModule::Registration< EffectRepair > reg
Externalized state of a plug-in.