55 return XO(
"Sets the peak amplitude of a one or more tracks");
80 bool bGoodResult =
true;
83 for (
auto track : outputs.Get().Selected<
WaveTrack>()) {
84 const double trackStart = track->GetStartTime();
85 const double repair_t0 = std::max(
mT0, trackStart);
86 const double trackEnd = track->GetEndTime();
88 const double repair_deltat = repair_t1 - repair_t0;
89 if (repair_deltat > 0) {
90 const auto repair0 = track->TimeToLongSamples(repair_t0);
91 const auto repair1 = track->TimeToLongSamples(repair_t1);
92 const auto repairLen = repair1 - repair0;
96"The Repair effect cannot be applied within stretched or shrunk clips") );
100 if (repairLen > 128) {
103"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.") );
108 const double rate = track->GetRate();
109 const double spacing = std::max(repair_deltat * 2, 128. / rate);
110 const double t0 = std::max(repair_t0 - spacing, trackStart);
111 const double t1 =
std::min(repair_t1 + spacing, trackEnd);
113 const auto s0 = track->TimeToLongSamples(t0);
114 const auto s1 = track->TimeToLongSamples(t1);
116 const auto repairStart = (repair0 - s0).as_size_t();
117 const auto len = s1 - s0;
119 if (s0 == repair0 && s1 == repair1) {
122"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.") );
128 for (
const auto pChannel : track->Channels())
134 repairLen.as_size_t())
150 sampleCount start,
size_t len,
size_t repairStart,
size_t repairLen)
153 track.
GetFloats(buffer.get(), start, len);
155 if (!track.
SetFloats(&buffer[repairStart],
156 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 > 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 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.
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
TranslatableString GetDescription() const override
bool NeedsDither() const override
static const ComponentInterfaceSymbol Symbol
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
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.
WAVE_TRACK_API bool HasPitchOrSpeed(const WaveTrack &track, double t0, double t1)
BuiltinEffectsModule::Registration< EffectRepair > reg
Externalized state of a plug-in.