Audacity 3.2.0
TruncSilenceBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 TruncSilenceBase.h
6
7 Lynn Allan (from DM's Normalize)
8 //ToDo ... put BlendFrames in Effects, Project, or other class
9 //ToDo ... Use ZeroCrossing logic to improve blend
10 //ToDo ... BlendFrames on "fade-out"
11 //ToDo ... BlendFrameCount is a user-selectable parameter
12 //ToDo ... Detect transient signals that are too short to interrupt the TruncatableSilence
13 Philip Van Baren (more options and boundary fixes)
14
15**********************************************************************/
16#pragma once
17
18#include "ShuttleAutomation.h"
19#include "StatefulEffect.h"
20#include "Track.h"
21
22class RegionList;
23
24class BUILTIN_EFFECTS_API TruncSilenceBase : public StatefulEffect
25{
26public:
27 static inline TruncSilenceBase*
29 {
30 return &e;
31 }
33
35 virtual ~TruncSilenceBase();
36
37 // ComponentInterface implementation
38
39 ComponentInterfaceSymbol GetSymbol() const override;
40 TranslatableString GetDescription() const override;
41 ManualPageID ManualPage() const override;
42
43 // EffectDefinitionInterface implementation
44
45 EffectType GetType() const override;
46 bool LoadSettings(
47 const CommandParameters& parms, EffectSettings& settings) const override;
48
49 // Effect implementation
50
52 const EffectSettings& settings, double previewLength) const override;
53
54 // Analyze a single track to find silences
55 // If inputLength is not NULL we are calculating the minimum
56 // amount of input for previewing.
57 bool Analyze(
58 RegionList& silenceList, RegionList& trackSilences, const WaveTrack& wt,
59 sampleCount* silentFrame, sampleCount* index, int whichTrack,
60 double* inputLength = nullptr, double* minInputLength = nullptr) const;
61
62 bool Process(EffectInstance& instance, EffectSettings& settings) override;
63
64 bool NeedsDither() const override;
65
66protected:
67 // TruncSilenceBase implementation
68
69 // ToDo ... put BlendFrames in Effects, Project, or other class
70 // void BlendFrames(float* buffer, int leftIndex, int rightIndex, int
71 // blendFrameCount);
72 void Intersect(RegionList& dest, const RegionList& src);
73
74 bool ProcessIndependently();
75 bool ProcessAll();
76 bool FindSilences(
77 RegionList& silences, const TrackIterRange<const WaveTrack>& range);
78 bool DoRemoval(
79 const RegionList& silences, const TrackIterRange<Track>& range,
80 unsigned iGroup, unsigned nGroups, double& totalCutLen);
81
82 double mThresholdDB {};
88
90
91 const EffectParameterMethods& Parameters() const override;
92
94 {
97 nActions
98 };
99
100 static const EnumValueSymbol kActionStrings[nActions];
101
102 static constexpr EffectParameter Threshold {
103 &TruncSilenceBase::mThresholdDB, L"Threshold", -20.0, -80.0, -20.0, 1
104 };
105 static constexpr EnumParameter ActIndex { &TruncSilenceBase::mActionIndex,
106 L"Action",
107 (int)kTruncate,
108 0,
109 nActions - 1,
110 1,
111 kActionStrings,
112 nActions };
113 static constexpr EffectParameter Minimum {
115 L"Minimum",
116 0.5,
117 0.001,
118 10000.0,
119 1
120 };
121 static constexpr EffectParameter Truncate {
123 L"Truncate",
124 0.5,
125 0.0,
126 10000.0,
127 1
128 };
129 static constexpr EffectParameter Compress {
131 L"Compress",
132 50.0,
133 0.0,
134 99.9,
135 1
136 };
137 static constexpr EffectParameter Independent {
138 &TruncSilenceBase::mbIndependent, L"Independent", false, false, true, 1
139 };
140};
EffectType
declares abstract base class Track, TrackList, and iterators over TrackList
static Settings & settings()
Definition: TrackInfo.cpp:51
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual ManualPageID ManualPage() const
Name of a page in the Audacity alpha manual, default is empty.
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
Definition: Effect.cpp:122
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
TranslatableString GetDescription() const override
Definition: Effect.cpp:64
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
Definition: Effect.cpp:384
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49
Performs effect computation.
Interface for manipulations of an Effect's settings.
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
virtual bool NeedsDither() const
Holds a msgid for the translation catalog; may also bind format arguments.
Truncate Silence automatically reduces the length of passages where the volume is below a set thresho...
double mSilenceCompressPercent
static TruncSilenceBase * FetchParameters(TruncSilenceBase &e, EffectSettings &)
double mInitialAllowedSilence
double mTruncLongestAllowedSilence
static const ComponentInterfaceSymbol Symbol
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:682