47 return XO(
"Sets the peak amplitude of one or more tracks");
66 return ((
mGain ==
false) && (
mDC ==
false));
88 bool bGoodResult =
true;
92 topMsg =
XO(
"Removing DC offset and Normalizing...\n");
94 topMsg =
XO(
"Removing DC offset...\n");
96 topMsg =
XO(
"Normalizing without removing DC offset...\n");
98 topMsg =
XO(
"Not doing anything...\n");
100 for (
auto track : outputs.Get().Selected<
WaveTrack>())
103 double trackStart = track->GetStartTime();
104 double trackEnd = track->GetEndTime();
114 wxString trackName = track->GetName();
116 std::vector<float> extents;
117 float maxExtent { std::numeric_limits<float>::lowest() };
118 std::vector<float> offsets;
120 const auto channels = track->Channels();
122 const bool oneChannel = (channels.size() == 1 ||
mStereoInd);
123 auto msg = oneChannel ?
124 topMsg +
XO(
"Analyzing: %s").Format(trackName) :
127 XO(
"Analyzing first track of stereo pair: %s")
130 const auto progressReport = [&](
double fraction) {
136 for (
auto channel : channels)
146 extents.push_back(extent);
147 maxExtent = std::max(maxExtent, extent);
148 offsets.push_back(offset);
151 msg = topMsg +
XO(
"Analyzing second track of stereo pair: %s")
157 if (track->NChannels() == 1)
159 msg = topMsg +
XO(
"Processing: %s").Format(trackName);
163 msg = topMsg +
XO(
"Processing stereo channels independently: %s")
169 XO(
"Processing first track of stereo pair: %s")
173 auto pOffset = offsets.begin();
174 auto pExtent = extents.begin();
175 for (
const auto channel : channels)
177 const auto extent = oneChannel ? *pExtent++ : maxExtent;
178 if ((extent > 0) &&
mGain)
179 mMult = ratio / extent;
184 (bGoodResult =
ProcessOne(*channel, msg, progress, *pOffset++)))
187 msg = topMsg +
XO(
"Processing second track of stereo pair: %s")
203 const bool dc,
const double curT0,
const double curT1,
float& offset,
213 min = pair.first, max = pair.second;
224 min = -1.0, max = 1.0;
231 wxFAIL_MSG(
"Analysing Track when nothing to do!");
232 min = -1.0, max = 1.0;
235 extent = fmax(fabs(
min), fabs(max));
243 const double curT1,
float& offset)
254 auto len = (
end - start).as_double();
278 totalSamples += blockSamples;
287 if (!report((s - start).as_double() / len))
293 if (totalSamples > 0)
295 offset = -sum / totalSamples.
as_double();
320 auto len = (
end - start).as_double();
343 if (!track.
SetFloats(buffer.get(), s, block))
354 progress + ((s - start).as_double() / len) /
371 for (
decltype(len) i = 0; i < len; i++)
372 sum += (
double)buffer[i];
378 for (
decltype(len) i = 0; i < len; i++)
380 float adjFrame = (buffer[i] + offset) *
mMult;
381 buffer[i] = adjFrame;
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Generates EffectParameterMethods overrides from variadic template arguments.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
void SetLinearEffectFlag(bool linearEffectFlag)
std::shared_ptr< TrackList > mTracks
bool TotalProgress(double frac, const TranslatableString &={}) const
int GetNumWaveTracks() const
Performs effect computation.
Use this object to copy the input tracks to tentative outputTracks.
Interface for manipulations of an Effect's settings.
virtual void Reset(Effect &effect) const =0
static constexpr EffectParameter StereoInd
EffectType GetType() const override
Type determines how it behaves.
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
static bool AnalyseTrackData(const WaveChannel &track, const ProgressReport &report, double curT0, double curT1, float &offset)
void ProcessData(float *buffer, size_t len, float offset)
std::function< bool(double fraction)> ProgressReport
TranslatableString GetDescription() const override
const EffectParameterMethods & Parameters() const override
ComponentInterfaceSymbol GetSymbol() const override
static constexpr EffectParameter PeakLevel
static const ComponentInterfaceSymbol Symbol
static bool AnalyseTrack(const WaveChannel &track, const ProgressReport &report, bool gain, bool dc, double curT0, double curT1, float &offset, float &extent)
static double AnalyseDataDC(float *buffer, size_t len, double sum)
bool ProcessOne(WaveChannel &track, const TranslatableString &msg, double &progress, float offset)
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
After Init(), tell whether Process() should be skipped.
static constexpr EffectParameter RemoveDC
bool Process(EffectInstance &instance, EffectSettings &settings) override
static constexpr EffectParameter ApplyVolume
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
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
size_t GetMaxBlockSize() const
A Track that contains audio waveform data.
sampleCount TimeToLongSamples(double t0) const
Positions or offsets within audio files need a wide type.
WAVE_TRACK_API std::pair< float, float > GetMinMax(const WaveChannel &channel, double t0, double t1, bool mayThrow=true)
const char * end(const char *str) noexcept
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.