Audacity 3.2.0
TruncSilence.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 TruncSilence.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
17#ifndef __AUDACITY_EFFECT_TRUNC_SILENCE__
18#define __AUDACITY_EFFECT_TRUNC_SILENCE__
19
20#include "StatefulEffect.h"
21#include "ShuttleAutomation.h"
22#include "Track.h"
23#include <wx/weakref.h>
24
25class ShuttleGui;
26class wxChoice;
27class wxTextCtrl;
28class wxCheckBox;
29
30class RegionList;
31
33{
34public:
35 static inline EffectTruncSilence *
38
40 virtual ~EffectTruncSilence();
41
42 // ComponentInterface implementation
43
44 ComponentInterfaceSymbol GetSymbol() const override;
45 TranslatableString GetDescription() const override;
46 ManualPageID ManualPage() const override;
47
48 // EffectDefinitionInterface implementation
49
50 EffectType GetType() const override;
51 bool LoadSettings(
52 const CommandParameters & parms, EffectSettings &settings) const override;
53
54 // Effect implementation
55
57 const EffectSettings &settings, double previewLength) const override;
58
59 // Analyze a single track to find silences
60 // If inputLength is not NULL we are calculating the minimum
61 // amount of input for previewing.
62 bool Analyze(RegionList &silenceList, RegionList &trackSilences,
63 const WaveTrack &wt, sampleCount* silentFrame, sampleCount* index,
64 int whichTrack, double* inputLength = nullptr,
65 double* minInputLength = nullptr) const;
66
67 bool Process(EffectInstance &instance, EffectSettings &settings) override;
68 std::unique_ptr<EffectEditor> PopulateOrExchange(
69 ShuttleGui & S, EffectInstance &instance,
70 EffectSettingsAccess &access, const EffectOutputs *pOutputs) override;
71 bool TransferDataToWindow(const EffectSettings &settings) override;
73
74 bool NeedsDither() const override;
75
76private:
77 // EffectTruncSilence implementation
78
79 //ToDo ... put BlendFrames in Effects, Project, or other class
80 // void BlendFrames(float* buffer, int leftIndex, int rightIndex, int blendFrameCount);
81 void Intersect(RegionList &dest, const RegionList & src);
82
83 void OnControlChange(wxCommandEvent & evt);
84 void UpdateUI();
85
87 bool ProcessAll();
88 bool FindSilences(RegionList &silences,
90 bool DoRemoval(const RegionList &silences,
91 const TrackIterRange<Track> &range,
92 unsigned iGroup, unsigned nGroups,
93 double &totalCutLen);
94
95 wxWeakRef<wxWindow> mUIParent{};
96
97 double mThresholdDB {} ;
103
105
106 wxTextCtrl *mThresholdText;
107 wxChoice *mActionChoice;
111 wxCheckBox *mIndependent;
112
113 const EffectParameterMethods& Parameters() const override;
114 DECLARE_EVENT_TABLE()
115
117 {
121 };
122
124
126 L"Threshold", -20.0, -80.0, -20.0, 1 };
128 L"Action", (int)kTruncate, 0, nActions - 1, 1, kActionStrings, nActions };
130 L"Minimum", 0.5, 0.001, 10000.0, 1 };
132 L"Truncate", 0.5, 0.0, 10000.0, 1 };
134 L"Compress", 50.0, 0.0, 99.9, 1 };
136 L"Independent", false, false, true, 1 };
137};
138
139#endif
EffectType
#define S(N)
Definition: ToChars.cpp:64
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,...
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
Truncate Silence automatically reduces the length of passages where the volume is below a set thresho...
Definition: TruncSilence.h:33
wxChoice * mActionChoice
Definition: TruncSilence.h:107
bool TransferDataToWindow(const EffectSettings &settings) override
static EffectTruncSilence * FetchParameters(EffectTruncSilence &e, EffectSettings &)
Definition: TruncSilence.h:36
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
bool Process(EffectInstance &instance, EffectSettings &settings) override
static constexpr EnumParameter ActIndex
Definition: TruncSilence.h:127
static constexpr EffectParameter Independent
Definition: TruncSilence.h:135
wxWeakRef< wxWindow > mUIParent
Definition: TruncSilence.h:95
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
wxTextCtrl * mThresholdText
Definition: TruncSilence.h:106
double mInitialAllowedSilence
Definition: TruncSilence.h:99
bool NeedsDither() const override
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
void OnControlChange(wxCommandEvent &evt)
static constexpr EffectParameter Minimum
Definition: TruncSilence.h:129
bool FindSilences(RegionList &silences, const TrackIterRange< const WaveTrack > &range)
bool Analyze(RegionList &silenceList, RegionList &trackSilences, const WaveTrack &wt, sampleCount *silentFrame, sampleCount *index, int whichTrack, double *inputLength=nullptr, double *minInputLength=nullptr) const
virtual ~EffectTruncSilence()
wxCheckBox * mIndependent
Definition: TruncSilence.h:111
bool TransferDataFromWindow(EffectSettings &settings) override
double mSilenceCompressPercent
Definition: TruncSilence.h:101
static constexpr EffectParameter Truncate
Definition: TruncSilence.h:131
EffectType GetType() const override
Type determines how it behaves.
static const EnumValueSymbol kActionStrings[nActions]
Definition: TruncSilence.h:123
double mTruncLongestAllowedSilence
Definition: TruncSilence.h:100
static constexpr EffectParameter Threshold
Definition: TruncSilence.h:125
wxTextCtrl * mTruncLongestAllowedSilenceT
Definition: TruncSilence.h:109
static const ComponentInterfaceSymbol Symbol
Definition: TruncSilence.h:37
const EffectParameterMethods & Parameters() const override
TranslatableString GetDescription() const override
ComponentInterfaceSymbol GetSymbol() const override
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
wxTextCtrl * mInitialAllowedSilenceT
Definition: TruncSilence.h:108
wxTextCtrl * mSilenceCompressPercentT
Definition: TruncSilence.h:110
static constexpr EffectParameter Compress
Definition: TruncSilence.h:133
bool DoRemoval(const RegionList &silences, const TrackIterRange< Track > &range, unsigned iGroup, unsigned nGroups, double &totalCutLen)
void Intersect(RegionList &dest, const RegionList &src)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
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