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 "Effect.h" 21 22 class ShuttleGui; 23 class wxChoice; 24 class wxTextCtrl; 25 class wxCheckBox; 26 27 class RegionList; 28 29 class EffectTruncSilence final : public Effect 30 { 31 public: 32 static const ComponentInterfaceSymbol Symbol; 33 34 EffectTruncSilence(); 35 virtual ~EffectTruncSilence(); 36 37 // ComponentInterface implementation 38 39 ComponentInterfaceSymbol GetSymbol() override; 40 TranslatableString GetDescription() override; 41 ManualPageID ManualPage() override; 42 43 // EffectDefinitionInterface implementation 44 45 EffectType GetType() override; 46 47 // EffectClientInterface implementation 48 49 bool DefineParams( ShuttleParams & S ) override; 50 bool GetAutomationParameters(CommandParameters & parms) override; 51 bool SetAutomationParameters(CommandParameters & parms) override; 52 53 // Effect implementation 54 55 double CalcPreviewInputLength(double previewLength) override; 56 bool Startup() override; 57 58 // Analyze a single track to find silences 59 // If inputLength is not NULL we are calculating the minimum 60 // amount of input for previewing. 61 bool Analyze(RegionList &silenceList, 62 RegionList &trackSilences, 63 const WaveTrack *wt, 64 sampleCount* silentFrame, 65 sampleCount* index, 66 int whichTrack, 67 double* inputLength = NULL, 68 double* minInputLength = NULL); 69 70 bool Process() override; 71 void PopulateOrExchange(ShuttleGui & S) override; 72 bool TransferDataToWindow() override; 73 bool TransferDataFromWindow() override; 74 75 private: 76 // EffectTruncSilence implementation 77 78 //ToDo ... put BlendFrames in Effects, Project, or other class 79 // void BlendFrames(float* buffer, int leftIndex, int rightIndex, int blendFrameCount); 80 void Intersect(RegionList &dest, const RegionList & src); 81 82 void OnControlChange(wxCommandEvent & evt); 83 void UpdateUI(); 84 85 bool ProcessIndependently(); 86 bool ProcessAll(); 87 bool FindSilences 88 (RegionList &silences, const TrackList *list, 89 const Track *firstTrack, const Track *lastTrack); 90 bool DoRemoval 91 (const RegionList &silences, unsigned iGroup, unsigned nGroups, Track *firstTrack, Track *lastTrack, 92 double &totalCutLen); 93 94 private: 95 96 double mThresholdDB {} ; 97 int mActionIndex; 98 double mInitialAllowedSilence; 99 double mTruncLongestAllowedSilence; 100 double mSilenceCompressPercent; 101 bool mbIndependent; 102 103 size_t mBlendFrameCount; 104 105 wxTextCtrl *mThresholdText; 106 wxChoice *mActionChoice; 107 wxTextCtrl *mInitialAllowedSilenceT; 108 wxTextCtrl *mTruncLongestAllowedSilenceT; 109 wxTextCtrl *mSilenceCompressPercentT; 110 wxCheckBox *mIndependent; 111 112 DECLARE_EVENT_TABLE() 113 }; 114 115 #endif 116