Audacity  3.0.3
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
EffectTruncSilence Class Referencefinal

Truncate Silence automatically reduces the length of passages where the volume is below a set threshold level. More...

#include <TruncSilence.h>

Inheritance diagram for EffectTruncSilence:
[legend]
Collaboration diagram for EffectTruncSilence:
[legend]

Public Member Functions

 EffectTruncSilence ()
 
virtual ~EffectTruncSilence ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
ManualPageID ManualPage () override
 
EffectType GetType () override
 
bool DefineParams (ShuttleParams &S) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
double CalcPreviewInputLength (double previewLength) override
 
bool Startup () override
 
bool Analyze (RegionList &silenceList, RegionList &trackSilences, const WaveTrack *wt, sampleCount *silentFrame, sampleCount *index, int whichTrack, double *inputLength=NULL, double *minInputLength=NULL)
 
bool Process () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
EffectFamilySymbol GetFamily () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
bool LoadUserPreset (const RegistryPath &name) override
 
bool SaveUserPreset (const RegistryPath &name) override
 
RegistryPaths GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (ShuttleGui &S) final
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
double GetDefaultDuration () override
 
double GetDuration () override
 
NumericFormatSymbol GetDurationFormat () override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
void SetDuration (double duration) override
 
RegistryPath GetUserPresetsGroup (const RegistryPath &name) override
 
RegistryPath GetCurrentSettingsGroup () override
 
RegistryPath GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const RegistryPath &group) override
 
bool GetSharedConfigSubgroups (const RegistryPath &group, RegistryPaths &subgroups) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const RegistryPath &group) override
 
bool RemoveSharedConfig (const RegistryPath &group, const RegistryPath &key) override
 
bool HasPrivateConfigGroup (const RegistryPath &group) override
 
bool GetPrivateConfigSubgroups (const RegistryPath &group, RegistryPaths &paths) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const RegistryPath &group) override
 
bool RemovePrivateConfig (const RegistryPath &group, const RegistryPath &key) override
 
virtual PluginID GetID ()
 
virtual bool Startup (EffectClientInterface *client)
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
virtual RegistryPaths GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual FilePath HelpPage ()
 
virtual void SetUIFlags (unsigned flags)
 
virtual unsigned TestUIFlags (unsigned mask)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
virtual bool IsHidden ()
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Truncate Silence") }
 
- Static Public Attributes inherited from Effect
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 

Private Member Functions

void Intersect (RegionList &dest, const RegionList &src)
 
void OnControlChange (wxCommandEvent &evt)
 
void UpdateUI ()
 
bool ProcessIndependently ()
 
bool ProcessAll ()
 
bool FindSilences (RegionList &silences, const TrackList *list, const Track *firstTrack, const Track *lastTrack)
 
bool DoRemoval (const RegionList &silences, unsigned iGroup, unsigned nGroups, Track *firstTrack, Track *lastTrack, double &totalCutLen)
 

Private Attributes

double mThresholdDB {}
 
int mActionIndex
 
double mInitialAllowedSilence
 
double mTruncLongestAllowedSilence
 
double mSilenceCompressPercent
 
bool mbIndependent
 
size_t mBlendFrameCount
 
wxTextCtrl * mThresholdText
 
wxChoice * mActionChoice
 
wxTextCtrl * mInitialAllowedSilenceT
 
wxTextCtrl * mTruncLongestAllowedSilenceT
 
wxTextCtrl * mSilenceCompressPercentT
 
wxCheckBox * mIndependent
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 
- Static Public Member Functions inherited from Effect
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
static CommandID GetSquashedName (wxString name)
 
static void IncEffectCounter ()
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual void Preview (bool dryOnly)
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
bool TotalProgress (double frac, const TranslatableString &={})
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={})
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={})
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
wxWeakRef< NotifyingSelectedRegionmpSelectedRegion {}
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
unsigned mUIFlags
 
sampleCount mSampleCnt
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

Detailed Description

Truncate Silence automatically reduces the length of passages where the volume is below a set threshold level.

Definition at line 29 of file TruncSilence.h.

Constructor & Destructor Documentation

◆ EffectTruncSilence()

EffectTruncSilence::EffectTruncSilence ( )

Definition at line 133 of file TruncSilence.cpp.

134 {
135  mInitialAllowedSilence = DEF_Minimum;
136  mTruncLongestAllowedSilence = DEF_Truncate;
137  mSilenceCompressPercent = DEF_Compress;
138  mThresholdDB = DEF_Threshold;
139  mActionIndex = DEF_ActIndex;
140  mbIndependent = DEF_Independent;
141 
142  SetLinearEffectFlag(false);
143 
144  // This used to be changeable via the audacity.cfg/registry. Doubtful that was
145  // ever done.
146  //
147  // Original comment:
148  //
149  // mBlendFrameCount only retrieved from prefs ... not using dialog
150  // Only way to change (for windows) is thru registry
151  // The values should be figured dynamically ... too many frames could be invalid
153 }

References DEF_BlendFrameCount.

◆ ~EffectTruncSilence()

EffectTruncSilence::~EffectTruncSilence ( )
virtual

Definition at line 155 of file TruncSilence.cpp.

156 {
157 }

Member Function Documentation

◆ Analyze()

bool EffectTruncSilence::Analyze ( RegionList silenceList,
RegionList trackSilences,
const WaveTrack wt,
sampleCount silentFrame,
sampleCount index,
int  whichTrack,
double *  inputLength = NULL,
double *  minInputLength = NULL 
)

Definition at line 597 of file TruncSilence.cpp.

605 {
606  // Smallest silent region to detect in frames
607  auto minSilenceFrames = sampleCount(std::max( mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
608 
609  double truncDbSilenceThreshold = DB_TO_LINEAR( mThresholdDB );
610  auto blockLen = wt->GetMaxBlockSize();
611  auto start = wt->TimeToLongSamples(mT0);
612  auto end = wt->TimeToLongSamples(mT1);
613  sampleCount outLength = 0;
614 
615  double previewLength;
616  gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &previewLength, 6.0);
617  // Minimum required length in samples.
618  const sampleCount previewLen( previewLength * wt->GetRate() );
619 
620  // Keep position in overall silences list for optimization
621  RegionList::iterator rit(silenceList.begin());
622 
623  // Allocate buffer
624  Floats buffer{ blockLen };
625 
626  // Loop through current track
627  while (*index < end) {
628  if (inputLength && ((outLength >= previewLen) || (*index - start > wt->TimeToLongSamples(*minInputLength)))) {
629  *inputLength = std::min<double>(*inputLength, *minInputLength);
630  if (outLength >= previewLen) {
631  *minInputLength = *inputLength;
632  }
633  return true;
634  }
635 
636  if (!inputLength) {
637  // Show progress dialog, test for cancellation
638  bool cancelled = TotalProgress(
639  detectFrac * (whichTrack +
640  (*index - start).as_double() /
641  (end - start).as_double()) /
642  (double)GetNumWaveTracks());
643  if (cancelled)
644  return false;
645  }
646 
647  // Optimization: if not in a silent region skip ahead to the next one
648 
649  double curTime = wt->LongSamplesToTime(*index);
650  for ( ; rit != silenceList.end(); ++rit) {
651  // Find the first silent region ending after current time
652  if (rit->end >= curTime) {
653  break;
654  }
655  }
656 
657  if (rit == silenceList.end()) {
658  // No more regions -- no need to process the rest of the track
659  if (inputLength) {
660  // Add available samples up to previewLength.
661  auto remainingTrackSamples = wt->TimeToLongSamples(wt->GetEndTime()) - *index;
662  auto requiredTrackSamples = previewLen - outLength;
663  outLength += (remainingTrackSamples > requiredTrackSamples)? requiredTrackSamples : remainingTrackSamples;
664  }
665 
666  break;
667  }
668  else if (rit->start > curTime) {
669  // End current silent region, skip ahead
670  if (*silentFrame >= minSilenceFrames) {
671  trackSilences.push_back(Region(
672  wt->LongSamplesToTime(*index - *silentFrame),
673  wt->LongSamplesToTime(*index)
674  ));
675  }
676  *silentFrame = 0;
677  auto newIndex = wt->TimeToLongSamples(rit->start);
678  if (inputLength) {
679  auto requiredTrackSamples = previewLen - outLength;
680  // Add non-silent sample to outLength
681  outLength += ((newIndex - *index) > requiredTrackSamples)? requiredTrackSamples : newIndex - *index;
682  }
683 
684  *index = newIndex;
685  }
686  // End of optimization
687 
688  // Limit size of current block if we've reached the end
689  auto count = limitSampleBufferSize( blockLen, end - *index );
690 
691  // Fill buffer
692  wt->GetFloats((buffer.get()), *index, count);
693 
694  // Look for silenceList in current block
695  for (decltype(count) i = 0; i < count; ++i) {
696  if (inputLength && ((outLength >= previewLen) || (outLength > wt->TimeToLongSamples(*minInputLength)))) {
697  *inputLength = wt->LongSamplesToTime(*index + i) - wt->LongSamplesToTime(start);
698  break;
699  }
700 
701  if (fabs(buffer[i]) < truncDbSilenceThreshold) {
702  (*silentFrame)++;
703  }
704  else {
705  sampleCount allowed = 0;
706  if (*silentFrame >= minSilenceFrames) {
707  if (inputLength) {
708  switch (mActionIndex) {
709  case kTruncate:
711  break;
712  case kCompress:
714  outLength += sampleCount(
715  allowed.as_double() +
716  (*silentFrame - allowed).as_double()
717  * mSilenceCompressPercent / 100.0
718  );
719  break;
720  // default: // Not currently used.
721  }
722  }
723 
724  // Record the silent region
725  trackSilences.push_back(Region(
726  wt->LongSamplesToTime(*index + i - *silentFrame),
727  wt->LongSamplesToTime(*index + i)
728  ));
729  }
730  else if (inputLength) { // included as part of non-silence
731  outLength += *silentFrame;
732  }
733  *silentFrame = 0;
734  if (inputLength) {
735  ++outLength; // Add non-silent sample to outLength
736  }
737  }
738  }
739  // Next block
740  *index += count;
741  }
742 
743  if (inputLength) {
744  *inputLength = std::min<double>(*inputLength, *minInputLength);
745  if (outLength >= previewLen) {
746  *minInputLength = *inputLength;
747  }
748  }
749 
750  return true;
751 }

References sampleCount::as_double(), DB_TO_LINEAR(), DEF_MinTruncMs, detectFrac, WaveTrack::GetEndTime(), WaveTrack::GetFloats(), WaveTrack::GetMaxBlockSize(), Effect::GetNumWaveTracks(), WaveTrack::GetRate(), gPrefs, kCompress, kTruncate, limitSampleBufferSize(), WaveTrack::LongSamplesToTime(), mActionIndex, mInitialAllowedSilence, mSilenceCompressPercent, Effect::mT0, Effect::mT1, mThresholdDB, mTruncLongestAllowedSilence, Region, WaveTrack::TimeToLongSamples(), and Effect::TotalProgress().

Referenced by CalcPreviewInputLength(), and FindSilences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalcPreviewInputLength()

double EffectTruncSilence::CalcPreviewInputLength ( double  previewLength)
overridevirtual

Reimplemented from Effect.

Definition at line 243 of file TruncSilence.cpp.

244 {
245  double inputLength = mT1 - mT0;
246  double minInputLength = inputLength;
247 
248  // Master list of silent regions
249  RegionList silences;
250 
251  // Start with the whole selection silent
252  silences.push_back(Region(mT0, mT1));
253 
254  int whichTrack = 0;
255 
256  for (auto wt : inputTracks()->Selected< const WaveTrack >()) {
257  RegionList trackSilences;
258 
259  auto index = wt->TimeToLongSamples(mT0);
260  sampleCount silentFrame = 0; // length of the current silence
261 
262  Analyze(silences, trackSilences, wt, &silentFrame, &index, whichTrack, &inputLength, &minInputLength);
263 
264  whichTrack++;
265  }
266  return inputLength;
267 }

References Analyze(), Effect::inputTracks(), Effect::mT0, Effect::mT1, and Region.

Here is the call graph for this function:

◆ DefineParams()

bool EffectTruncSilence::DefineParams ( ShuttleParams S)
override

Definition at line 185 of file TruncSilence.cpp.

185  {
186  S.SHUTTLE_PARAM( mThresholdDB, Threshold );
187  S.SHUTTLE_ENUM_PARAM( mActionIndex, ActIndex, kActionStrings, nActions );
188  S.SHUTTLE_PARAM( mInitialAllowedSilence, Minimum );
189  S.SHUTTLE_PARAM( mTruncLongestAllowedSilence, Truncate );
190  S.SHUTTLE_PARAM( mSilenceCompressPercent, Compress );
191  S.SHUTTLE_PARAM( mbIndependent, Independent );
192  return true;
193 }

References kActionStrings, mActionIndex, mbIndependent, mInitialAllowedSilence, mSilenceCompressPercent, mThresholdDB, mTruncLongestAllowedSilence, and nActions.

◆ DoRemoval()

bool EffectTruncSilence::DoRemoval ( const RegionList silences,
unsigned  iGroup,
unsigned  nGroups,
Track firstTrack,
Track lastTrack,
double &  totalCutLen 
)
private

Definition at line 483 of file TruncSilence.cpp.

486 {
487  //
488  // Now remove the silent regions from all selected / sync-lock selected tracks.
489  //
490 
491  // Loop over detected regions in reverse (so cuts don't change time values
492  // down the line)
493  int whichReg = 0;
494  RegionList::const_reverse_iterator rit;
495  for (rit = silences.rbegin(); rit != silences.rend(); ++rit)
496  {
497  const Region &region = *rit;
498  const Region *const r = &region;
499 
500  // Progress dialog and cancellation. Do additional cleanup before return.
501  const double frac = detectFrac +
502  (1 - detectFrac) * (iGroup + whichReg / double(silences.size())) / nGroups;
503  if (TotalProgress(frac))
504  {
505  ReplaceProcessedTracks(false);
506  return false;
507  }
508 
509  // Intersection may create regions smaller than allowed; ignore them.
510  // Allow one nanosecond extra for consistent results with exact milliseconds of allowed silence.
511  if ((r->end - r->start) < (mInitialAllowedSilence - 0.000000001))
512  continue;
513 
514  // Find NEW silence length as requested
515  double inLength = r->end - r->start;
516  double outLength;
517 
518  switch (mActionIndex)
519  {
520  case kTruncate:
521  outLength = std::min(mTruncLongestAllowedSilence, inLength);
522  break;
523  case kCompress:
524  outLength = mInitialAllowedSilence +
525  (inLength - mInitialAllowedSilence) * mSilenceCompressPercent / 100.0;
526  break;
527  default: // Not currently used.
528  outLength = std::min(mInitialAllowedSilence +
529  (inLength - mInitialAllowedSilence) * mSilenceCompressPercent / 100.0,
531  }
532 
533  const double cutLen = std::max(0.0, inLength - outLength);
534  // Don't waste time cutting nothing.
535  if( cutLen == 0.0 )
536  continue;
537 
538  totalCutLen += cutLen;
539 
540  double cutStart = (r->start + r->end - cutLen) / 2;
541  double cutEnd = cutStart + cutLen;
542  (mOutputTracks->Any()
543  .StartingWith(firstTrack).EndingAfter(lastTrack)
545  - [&](const Track *pTrack) { return
546  // Don't waste time past the end of a track
547  pTrack->GetEndTime() < r->start;
548  }
549  ).Visit(
550  [&](WaveTrack *wt) {
551 
552  // In WaveTracks, clear with a cross-fade
553  auto blendFrames = mBlendFrameCount;
554  // Round start/end times to frame boundaries
555  cutStart = wt->LongSamplesToTime(wt->TimeToLongSamples(cutStart));
556  cutEnd = wt->LongSamplesToTime(wt->TimeToLongSamples(cutEnd));
557 
558  // Make sure the cross-fade does not affect non-silent frames
559  if (wt->LongSamplesToTime(blendFrames) > inLength)
560  {
561  // Result is not more than blendFrames:
562  blendFrames = wt->TimeToLongSamples(inLength).as_size_t();
563  }
564 
565  // Perform cross-fade in memory
566  Floats buf1{ blendFrames };
567  Floats buf2{ blendFrames };
568  auto t1 = wt->TimeToLongSamples(cutStart) - blendFrames / 2;
569  auto t2 = wt->TimeToLongSamples(cutEnd) - blendFrames / 2;
570 
571  wt->GetFloats(buf1.get(), t1, blendFrames);
572  wt->GetFloats(buf2.get(), t2, blendFrames);
573 
574  for (decltype(blendFrames) i = 0; i < blendFrames; ++i)
575  {
576  buf1[i] = ((blendFrames-i) * buf1[i] + i * buf2[i]) /
577  (double)blendFrames;
578  }
579 
580  // Perform the cut
581  wt->Clear(cutStart, cutEnd);
582 
583  // Write cross-faded data
584  wt->Set((samplePtr)buf1.get(), floatSample, t1, blendFrames);
585  },
586  [&](Track *t) {
587  // Non-wave tracks: just do a sync-lock adjust
588  t->SyncLockAdjust(cutEnd, cutStart);
589  }
590  );
591  ++whichReg;
592  }
593 
594  return true;
595 }

References sampleCount::as_size_t(), WaveTrack::Clear(), detectFrac, Region::end, floatSample, WaveTrack::GetFloats(), Track::IsSelectedOrSyncLockSelected(), kCompress, kTruncate, WaveTrack::LongSamplesToTime(), mActionIndex, mBlendFrameCount, min(), mInitialAllowedSilence, Effect::mOutputTracks, mSilenceCompressPercent, mTruncLongestAllowedSilence, Effect::ReplaceProcessedTracks(), WaveTrack::Set(), Region::start, WaveTrack::TimeToLongSamples(), Effect::TotalProgress(), and Registry::Visit().

Referenced by ProcessAll(), and ProcessIndependently().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindSilences()

bool EffectTruncSilence::FindSilences ( RegionList silences,
const TrackList list,
const Track firstTrack,
const Track lastTrack 
)
private

Definition at line 431 of file TruncSilence.cpp.

434 {
435  // Start with the whole selection silent
436  silences.push_back(Region(mT0, mT1));
437 
438  // Remove non-silent regions in each track
439  int whichTrack = 0;
440  for (auto wt :
441  list->Selected< const WaveTrack >()
442  .StartingWith( firstTrack ).EndingAfter( lastTrack ) )
443  {
444  // Smallest silent region to detect in frames
445  auto minSilenceFrames =
446  sampleCount(std::max(mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
447 
448  //
449  // Scan the track for silences
450  //
451  RegionList trackSilences;
452 
453  auto index = wt->TimeToLongSamples(mT0);
454  sampleCount silentFrame = 0;
455 
456  // Detect silences
457  bool cancelled = !(Analyze(silences, trackSilences, wt, &silentFrame, &index, whichTrack));
458 
459  // Buffer has been freed, so we're OK to return if cancelled
460  if (cancelled)
461  {
462  ReplaceProcessedTracks(false);
463  return false;
464  }
465 
466  if (silentFrame >= minSilenceFrames)
467  {
468  // Track ended in silence -- record region
469  trackSilences.push_back(Region(
470  wt->LongSamplesToTime(index - silentFrame),
471  wt->LongSamplesToTime(index)
472  ));
473  }
474 
475  // Intersect with the overall silent region list
476  Intersect(silences, trackSilences);
477  whichTrack++;
478  }
479 
480  return true;
481 }

References Analyze(), DEF_MinTruncMs, Intersect(), mInitialAllowedSilence, Effect::mT0, Effect::mT1, Region, Effect::ReplaceProcessedTracks(), and TrackList::Selected().

Referenced by ProcessAll(), and ProcessIndependently().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAutomationParameters()

bool EffectTruncSilence::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Reimplemented from Effect.

Definition at line 195 of file TruncSilence.cpp.

196 {
197  parms.Write(KEY_Threshold, mThresholdDB);
198  parms.Write(KEY_ActIndex, kActionStrings[mActionIndex].Internal());
199  parms.Write(KEY_Minimum, mInitialAllowedSilence);
200  parms.Write(KEY_Truncate, mTruncLongestAllowedSilence);
201  parms.Write(KEY_Compress, mSilenceCompressPercent);
202  parms.Write(KEY_Independent, mbIndependent);
203 
204  return true;
205 }

References Internal, kActionStrings, mActionIndex, mbIndependent, mInitialAllowedSilence, mSilenceCompressPercent, mThresholdDB, and mTruncLongestAllowedSilence.

◆ GetDescription()

TranslatableString EffectTruncSilence::GetDescription ( )
overridevirtual

Reimplemented from Effect.

Definition at line 166 of file TruncSilence.cpp.

167 {
168  return XO("Automatically reduces the length of passages where the volume is below a specified level");
169 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectTruncSilence::GetSymbol ( )
overridevirtual

Reimplemented from Effect.

Definition at line 161 of file TruncSilence.cpp.

162 {
163  return Symbol;
164 }

References Symbol.

◆ GetType()

EffectType EffectTruncSilence::GetType ( )
overridevirtual

Reimplemented from Effect.

Definition at line 178 of file TruncSilence.cpp.

179 {
180  return EffectTypeProcess;
181 }

References EffectTypeProcess.

◆ Intersect()

void EffectTruncSilence::Intersect ( RegionList dest,
const RegionList src 
)
private

Definition at line 860 of file TruncSilence.cpp.

861 {
862  RegionList::iterator destIter;
863  destIter = dest.begin();
864  // Any time we reach the end of the dest list we're finished
865  if (destIter == dest.end())
866  return;
867  RegionList::iterator curDest = destIter;
868 
869  // Operation: find non-silent regions in src, remove them from dest.
870  double nsStart = curDest->start;
871  double nsEnd;
872  bool lastRun = false; // must run the loop one extra time
873 
874  RegionList::const_iterator srcIter = src.begin();
875 
876  // This logic, causing the loop to run once after end of src, must occur
877  // each time srcIter is updated
878  if (srcIter == src.end())
879  {
880  lastRun = true;
881  }
882 
883  while (srcIter != src.end() || lastRun)
884  {
885  // Don't use curSrc unless lastRun is false!
886  RegionList::const_iterator curSrc;
887 
888  if (lastRun)
889  {
890  // The last non-silent region extends as far as possible
891  nsEnd = std::numeric_limits<double>::max();
892  }
893  else
894  {
895  curSrc = srcIter;
896  nsEnd = curSrc->start;
897  }
898 
899  if (nsEnd > nsStart)
900  {
901  // Increment through dest until we have a region that could be affected
902  while (curDest->end <= nsStart)
903  {
904  ++destIter;
905  if (destIter == dest.end())
906  {
907  return;
908  }
909  curDest = destIter;
910  }
911 
912  // Check for splitting dest region in two
913  if (nsStart > curDest->start && nsEnd < curDest->end)
914  {
915  // The second region
916  Region r(nsEnd, curDest->end);
917 
918  // The first region
919  curDest->end = nsStart;
920 
921  // Insert second region after first
922  RegionList::iterator nextIt(destIter);
923  ++nextIt;
924 
925  // This should just read: destIter = dest.insert(nextIt, r); but we
926  // work around two two wxList::insert() bugs. First, in some
927  // versions it returns the wrong value. Second, in some versions,
928  // it crashes when you insert at list end.
929  if (nextIt == dest.end())
930  dest.push_back(r);
931  else
932  dest.insert(nextIt, r);
933  ++destIter; // (now points at the newly-inserted region)
934 
935  curDest = destIter;
936  }
937 
938  // Check for truncating the end of dest region
939  if (nsStart > curDest->start && nsStart < curDest->end &&
940  nsEnd >= curDest->end)
941  {
942  curDest->end = nsStart;
943 
944  ++destIter;
945  if (destIter == dest.end())
946  {
947  return;
948  }
949  curDest = destIter;
950  }
951 
952  // Check for all dest regions that need to be removed completely
953  while (nsStart <= curDest->start && nsEnd >= curDest->end)
954  {
955  destIter = dest.erase(destIter);
956  if (destIter == dest.end())
957  {
958  return;
959  }
960  curDest = destIter;
961  }
962 
963  // Check for truncating the beginning of dest region
964  if (nsStart <= curDest->start &&
965  nsEnd > curDest->start && nsEnd < curDest->end)
966  {
967  curDest->start = nsEnd;
968  }
969  }
970 
971  if (lastRun)
972  {
973  // done
974  lastRun = false;
975  }
976  else
977  {
978  // Next non-silent region starts at the end of this silent region
979  nsStart = curSrc->end;
980  ++srcIter;
981  if (srcIter == src.end())
982  {
983  lastRun = true;
984  }
985  }
986  }
987 }

Referenced by FindSilences().

Here is the caller graph for this function:

◆ ManualPage()

ManualPageID EffectTruncSilence::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 171 of file TruncSilence.cpp.

172 {
173  return L"Truncate_Silence";
174 }

◆ OnControlChange()

void EffectTruncSilence::OnControlChange ( wxCommandEvent &  evt)
private

Definition at line 1021 of file TruncSilence.cpp.

1022 {
1023  mActionChoice->GetValidator()->TransferFromWindow();
1024 
1025  UpdateUI();
1026 
1027  if (!EnableApply(mUIParent->TransferDataFromWindow()))
1028  {
1029  return;
1030  }
1031 }

References Effect::EnableApply(), mActionChoice, Effect::mUIParent, and UpdateUI().

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectTruncSilence::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 754 of file TruncSilence.cpp.

755 {
756  wxASSERT(nActions == WXSIZEOF(kActionStrings));
757 
758  S.AddSpace(0, 5);
759 
760  S.StartStatic(XO("Detect Silence"));
761  {
762  S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL);
763  {
764  // Threshold
765  mThresholdText = S
766  .Validator<FloatingPointValidator<double>>(
767  3, &mThresholdDB, NumValidatorStyle::NO_TRAILING_ZEROES,
768  MIN_Threshold, MAX_Threshold
769  )
770  .NameSuffix(XO("db"))
771  .AddTextBox(XXO("&Threshold:"), wxT(""), 0);
772  S.AddUnits(XO("dB"));
773 
774  // Ignored silence
775  mInitialAllowedSilenceT = S.Validator<FloatingPointValidator<double>>(
777  NumValidatorStyle::NO_TRAILING_ZEROES,
778  MIN_Minimum, MAX_Minimum)
779  .NameSuffix(XO("seconds"))
780  .AddTextBox(XXO("&Duration:"), wxT(""), 12);
781  S.AddUnits(XO("seconds"));
782  }
783  S.EndMultiColumn();
784  }
785  S.EndStatic();
786 
787  S.StartStatic(XO("Action"));
788  {
789  S.StartHorizontalLay();
790  {
791  // Action choices
792  auto actionChoices = Msgids( kActionStrings, nActions );
793  mActionChoice = S
794  .Validator<wxGenericValidator>(&mActionIndex)
795  .MinSize( { -1, -1 } )
796  .AddChoice( {}, actionChoices );
797  }
798  S.EndHorizontalLay();
799  S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL);
800  {
801  // Truncation / Compression factor
802 
803  mTruncLongestAllowedSilenceT = S.Validator<FloatingPointValidator<double>>(
805  NumValidatorStyle::NO_TRAILING_ZEROES,
806  MIN_Truncate, MAX_Truncate
807  )
808  .NameSuffix(XO("seconds"))
809  .AddTextBox(XXO("Tr&uncate to:"), wxT(""), 12);
810  S.AddUnits(XO("seconds"));
811 
812  mSilenceCompressPercentT = S.Validator<FloatingPointValidator<double>>(
814  NumValidatorStyle::NO_TRAILING_ZEROES,
815  MIN_Compress, MAX_Compress
816  )
817  .NameSuffix(XO("%"))
818  .AddTextBox(XXO("C&ompress to:"), wxT(""), 12);
819  S.AddUnits(XO("%"));
820  }
821  S.EndMultiColumn();
822 
823  S.StartMultiColumn(2, wxALIGN_CENTER_HORIZONTAL);
824  {
825  mIndependent = S.AddCheckBox(XXO("Trunc&ate tracks independently"),
826  mbIndependent);
827  }
828  S.EndMultiColumn();
829 }
830  S.EndStatic();
831 
832  UpdateUI();
833 }

References ShuttleGuiBase::AddCheckBox(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddUnits(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), kActionStrings, mActionChoice, mActionIndex, mbIndependent, mIndependent, mInitialAllowedSilence, mInitialAllowedSilenceT, Msgids(), mSilenceCompressPercent, mSilenceCompressPercentT, mThresholdDB, mThresholdText, mTruncLongestAllowedSilence, mTruncLongestAllowedSilenceT, nActions, ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), UpdateUI(), ShuttleGui::Validator(), XO, and XXO.

Here is the call graph for this function:

◆ Process()

bool EffectTruncSilence::Process ( )
overridevirtual

Reimplemented from Effect.

Definition at line 321 of file TruncSilence.cpp.

322 {
323  const bool success =
326  : ProcessAll();
327 
328  if (success)
330 
331  return success;
332 }

References mbIndependent, ProcessAll(), ProcessIndependently(), and Effect::ReplaceProcessedTracks().

Here is the call graph for this function:

◆ ProcessAll()

bool EffectTruncSilence::ProcessAll ( )
private

Definition at line 407 of file TruncSilence.cpp.

408 {
409  // Copy tracks
410  CopyInputTracks(true);
411 
412  // Master list of silent regions.
413  // This list should always be kept in order.
414  RegionList silences;
415 
416  auto trackRange0 = inputTracks()->Selected< const WaveTrack >();
417  if (FindSilences(
418  silences, inputTracks(), *trackRange0.begin(), *trackRange0.rbegin())) {
419  auto trackRange = mOutputTracks->Any();
420  double totalCutLen = 0.0;
421  if (DoRemoval(silences, 0, 1,
422  *trackRange.begin(), *trackRange.rbegin(), totalCutLen)) {
423  mT1 -= totalCutLen;
424  return true;
425  }
426  }
427 
428  return false;
429 }

References TrackList::begin(), Effect::CopyInputTracks(), DoRemoval(), FindSilences(), Effect::inputTracks(), Effect::mOutputTracks, Effect::mT1, and TrackList::Selected().

Referenced by Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessIndependently()

bool EffectTruncSilence::ProcessIndependently ( )
private

Definition at line 334 of file TruncSilence.cpp.

335 {
336  unsigned nGroups = 0;
337 
338  const auto &settings = ProjectSettings::Get( *FindProject() );
339  const bool syncLock = settings.IsSyncLocked();
340 
341  // Check if it's permissible
342  {
343  for (auto track : inputTracks()->SelectedLeaders< const WaveTrack >() ) {
344  if (syncLock) {
345  auto channels = TrackList::Channels(track);
346  auto otherTracks =
347  TrackList::SyncLockGroup(track).Filter<const WaveTrack>()
349  - [&](const Track *pTrack){
350  return channels.contains(pTrack); };
351  if (otherTracks) {
353  XO(
354 "When truncating independently, there may only be one selected audio track in each Sync-Locked Track Group.") );
355  return false;
356  }
357  }
358 
359  ++nGroups;
360  }
361  }
362 
363  if (nGroups == 0)
364  // nothing to do
365  return true;
366 
367  // Now do the work
368 
369  // Copy tracks
370  CopyInputTracks(true);
371  double newT1 = 0.0;
372 
373  {
374  unsigned iGroup = 0;
375  for (auto track : mOutputTracks->SelectedLeaders< WaveTrack >() ) {
376  Track *const last = *TrackList::Channels(track).rbegin();
377 
378  RegionList silences;
379 
380  if (!FindSilences(silences, mOutputTracks.get(), track, last))
381  return false;
382  // Treat tracks in the sync lock group only
383  Track *groupFirst, *groupLast;
384  if (syncLock) {
385  auto trackRange = TrackList::SyncLockGroup(track);
386  groupFirst = *trackRange.begin();
387  groupLast = *trackRange.rbegin();
388  }
389  else {
390  groupFirst = track;
391  groupLast = last;
392  }
393  double totalCutLen = 0.0;
394  if (!DoRemoval(silences, iGroup, nGroups, groupFirst, groupLast, totalCutLen))
395  return false;
396  newT1 = std::max(newT1, mT1 - totalCutLen);
397 
398  ++iGroup;
399  }
400  }
401 
402  mT1 = newT1;
403 
404  return true;
405 }

References TrackList::Channels(), Effect::CopyInputTracks(), DoRemoval(), Effect::FindProject(), FindSilences(), ProjectSettings::Get(), Effect::inputTracks(), Track::IsSelected(), Effect::MessageBox(), Effect::mOutputTracks, Effect::mT1, settings(), TrackList::SyncLockGroup(), and XO.

Referenced by Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAutomationParameters()

bool EffectTruncSilence::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Reimplemented from Effect.

Definition at line 207 of file TruncSilence.cpp.

208 {
209  ReadAndVerifyDouble(Minimum);
210  ReadAndVerifyDouble(Truncate);
211  ReadAndVerifyDouble(Compress);
212 
213  // This control migrated from a choice to a text box in version 2.3.0
214  double myThreshold {};
215  bool newParams = [&] {
216  ReadAndVerifyDouble(Threshold); // macro may return false
217  myThreshold = Threshold;
218  return true;
219  } ();
220 
221  if ( !newParams ) {
222  // Use legacy param:
224  myThreshold = enumToDB( DbIndex );
225  }
226 
229  ReadAndVerifyBool(Independent);
230 
231  mInitialAllowedSilence = Minimum;
232  mTruncLongestAllowedSilence = Truncate;
233  mSilenceCompressPercent = Compress;
234  mThresholdDB = myThreshold;
235  mActionIndex = ActIndex;
236  mbIndependent = Independent;
237 
238  return true;
239 }

References Enums::DbChoices, enumToDB(), kActionStrings, kObsoleteActions, mActionIndex, mbIndependent, mInitialAllowedSilence, mSilenceCompressPercent, mThresholdDB, mTruncLongestAllowedSilence, nActions, nObsoleteActions, Enums::NumDbChoices, ReadAndVerifyBool, ReadAndVerifyDouble, ReadAndVerifyEnum, and ReadAndVerifyEnumWithObsoletes.

Here is the call graph for this function:

◆ Startup()

bool EffectTruncSilence::Startup ( )
overridevirtual

Reimplemented from Effect.

Definition at line 270 of file TruncSilence.cpp.

271 {
272  wxString base = wxT("/Effects/TruncateSilence/");
273 
274  // Migrate settings from 2.1.0 or before
275 
276  // Already migrated, so bail
277  if (gPrefs->Exists(base + wxT("Migrated")))
278  {
279  return true;
280  }
281 
282  // Load the old "current" settings
283  if (gPrefs->Exists(base))
284  {
285  int truncDbChoiceIndex = gPrefs->Read(base + wxT("DbChoiceIndex"), 4L);
286  if ((truncDbChoiceIndex < 0) || (truncDbChoiceIndex >= Enums::NumDbChoices))
287  { // corrupted Prefs?
288  truncDbChoiceIndex = 4L;
289  }
290  mThresholdDB = enumToDB( truncDbChoiceIndex );
291  mActionIndex = gPrefs->Read(base + wxT("ProcessChoice"), 0L);
292  if ((mActionIndex < 0) || (mActionIndex > 1))
293  { // corrupted Prefs?
294  mActionIndex = 0L;
295  }
296  gPrefs->Read(base + wxT("InitialAllowedSilence"), &mInitialAllowedSilence, 0.5);
297  if ((mInitialAllowedSilence < 0.001) || (mInitialAllowedSilence > 10000.0))
298  { // corrupted Prefs?
300  }
301  gPrefs->Read(base + wxT("LongestAllowedSilence"), &mTruncLongestAllowedSilence, 0.5);
302  if ((mTruncLongestAllowedSilence < 0.0) || (mTruncLongestAllowedSilence > 10000.0))
303  { // corrupted Prefs?
305  }
306  gPrefs->Read(base + wxT("CompressPercent"), &mSilenceCompressPercent, 50.0);
307  if ((mSilenceCompressPercent < 0.0) || (mSilenceCompressPercent > 100.0))
308  { // corrupted Prefs?
310  }
311 
313  }
314 
315  // Do not migrate again
316  gPrefs->Write(base + wxT("Migrated"), true);
317 
318  return true;
319 }

References enumToDB(), Effect::GetCurrentSettingsGroup(), gPrefs, mActionIndex, mInitialAllowedSilence, mSilenceCompressPercent, mThresholdDB, mTruncLongestAllowedSilence, Enums::NumDbChoices, and Effect::SaveUserPreset().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectTruncSilence::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 845 of file TruncSilence.cpp.

846 {
847  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
848  {
849  return false;
850  }
851 
852  mbIndependent = mIndependent->IsChecked();
853 
854  return true;
855 }

References mbIndependent, mIndependent, and Effect::mUIParent.

◆ TransferDataToWindow()

bool EffectTruncSilence::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 835 of file TruncSilence.cpp.

836 {
837  if (!mUIParent->TransferDataToWindow())
838  {
839  return false;
840  }
841 
842  return true;
843 }

References Effect::mUIParent.

◆ UpdateUI()

void EffectTruncSilence::UpdateUI ( void  )
private

Definition at line 1007 of file TruncSilence.cpp.

1008 {
1009  switch (mActionIndex)
1010  {
1011  case kTruncate:
1012  mTruncLongestAllowedSilenceT->Enable(true);
1013  mSilenceCompressPercentT->Enable(false);
1014  break;
1015  case kCompress:
1016  mTruncLongestAllowedSilenceT->Enable(false);
1017  mSilenceCompressPercentT->Enable(true);
1018  }
1019 }

References kCompress, kTruncate, mActionIndex, mSilenceCompressPercentT, and mTruncLongestAllowedSilenceT.

Referenced by OnControlChange(), and PopulateOrExchange().

Here is the caller graph for this function:

Member Data Documentation

◆ mActionChoice

wxChoice* EffectTruncSilence::mActionChoice
private

Definition at line 106 of file TruncSilence.h.

Referenced by OnControlChange(), and PopulateOrExchange().

◆ mActionIndex

int EffectTruncSilence::mActionIndex
private

◆ mbIndependent

bool EffectTruncSilence::mbIndependent
private

◆ mBlendFrameCount

size_t EffectTruncSilence::mBlendFrameCount
private

Definition at line 103 of file TruncSilence.h.

Referenced by DoRemoval().

◆ mIndependent

wxCheckBox* EffectTruncSilence::mIndependent
private

Definition at line 110 of file TruncSilence.h.

Referenced by PopulateOrExchange(), and TransferDataFromWindow().

◆ mInitialAllowedSilence

double EffectTruncSilence::mInitialAllowedSilence
private

◆ mInitialAllowedSilenceT

wxTextCtrl* EffectTruncSilence::mInitialAllowedSilenceT
private

Definition at line 107 of file TruncSilence.h.

Referenced by PopulateOrExchange().

◆ mSilenceCompressPercent

double EffectTruncSilence::mSilenceCompressPercent
private

◆ mSilenceCompressPercentT

wxTextCtrl* EffectTruncSilence::mSilenceCompressPercentT
private

Definition at line 109 of file TruncSilence.h.

Referenced by PopulateOrExchange(), and UpdateUI().

◆ mThresholdDB

double EffectTruncSilence::mThresholdDB {}
private

◆ mThresholdText

wxTextCtrl* EffectTruncSilence::mThresholdText
private

Definition at line 105 of file TruncSilence.h.

Referenced by PopulateOrExchange().

◆ mTruncLongestAllowedSilence

double EffectTruncSilence::mTruncLongestAllowedSilence
private

◆ mTruncLongestAllowedSilenceT

wxTextCtrl* EffectTruncSilence::mTruncLongestAllowedSilenceT
private

Definition at line 108 of file TruncSilence.h.

Referenced by PopulateOrExchange(), and UpdateUI().

◆ Symbol

const ComponentInterfaceSymbol EffectTruncSilence::Symbol { XO("Truncate Silence") }
static

Definition at line 32 of file TruncSilence.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
DEF_MinTruncMs
static const double DEF_MinTruncMs
Definition: TruncSilence.cpp:118
EffectTruncSilence::mTruncLongestAllowedSilence
double mTruncLongestAllowedSilence
Definition: TruncSilence.h:99
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2272
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, bool Selected)
Definition: ShuttleGui.cpp:309
EffectTruncSilence::mThresholdText
wxTextCtrl * mThresholdText
Definition: TruncSilence.h:105
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:2001
Effect::EnableApply
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1926
Enums::DbChoices
static const EnumValueSymbol DbChoices[]
Definition: TruncSilence.cpp:43
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
kObsoleteActions
static CommandParameters::ObsoleteMap kObsoleteActions[]
Definition: TruncSilence.cpp:86
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2482
WaveTrack::GetEndTime
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1895
EffectTruncSilence::mTruncLongestAllowedSilenceT
wxTextCtrl * mTruncLongestAllowedSilenceT
Definition: TruncSilence.h:108
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2071
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
nObsoleteActions
static const size_t nObsoleteActions
Definition: TruncSilence.cpp:92
EffectTruncSilence::mInitialAllowedSilenceT
wxTextCtrl * mInitialAllowedSilenceT
Definition: TruncSilence.h:107
Effect::mT1
double mT1
Definition: Effect.h:467
kTruncate
@ kTruncate
Definition: TruncSilence.cpp:75
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
EffectTruncSilence::mSilenceCompressPercent
double mSilenceCompressPercent
Definition: TruncSilence.h:100
EffectTruncSilence::mbIndependent
bool mbIndependent
Definition: TruncSilence.h:101
XO
#define XO(s)
Definition: Internat.h:31
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:41
Region::start
double start
Definition: WaveTrack.h:56
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
RegionList
Definition: TruncSilence.cpp:71
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:570
enumToDB
static double enumToDB(int val)
Definition: TruncSilence.cpp:66
EffectTruncSilence::Analyze
bool Analyze(RegionList &silenceList, RegionList &trackSilences, const WaveTrack *wt, sampleCount *silentFrame, sampleCount *index, int whichTrack, double *inputLength=NULL, double *minInputLength=NULL)
Definition: TruncSilence.cpp:597
WaveTrack::Set
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:2076
floatSample
@ floatSample
Definition: SampleFormat.h:34
EffectTruncSilence::ProcessIndependently
bool ProcessIndependently()
Definition: TruncSilence.cpp:334
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:621
ReadAndVerifyEnumWithObsoletes
#define ReadAndVerifyEnumWithObsoletes(name, list, listSize, obsoleteList, nObsolete)
Definition: Effect.h:626
XXO
#define XXO(s)
Definition: Internat.h:44
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:751
Effect::inputTracks
const TrackList * inputTracks() const
Definition: Effect.h:463
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
kCompress
@ kCompress
Definition: TruncSilence.cpp:76
Effect::mT0
double mT0
Definition: Effect.h:466
sampleCount::as_double
double as_double() const
Definition: SampleCount.h:45
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1870
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
TrackList::begin
iterator begin()
Definition: Track.h:1324
EffectTruncSilence::ProcessAll
bool ProcessAll()
Definition: TruncSilence.cpp:407
ShuttleGuiBase::AddUnits
void AddUnits(const TranslatableString &Prompt, int wrapWidth=0)
Left aligned text string.
Definition: ShuttleGui.cpp:263
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2193
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:373
nActions
@ nActions
Definition: TruncSilence.cpp:77
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:678
EffectTruncSilence::mActionIndex
int mActionIndex
Definition: TruncSilence.h:97
Region::end
double end
Definition: WaveTrack.h:56
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
sampleCount::as_size_t
size_t as_size_t() const
Definition: SampleCount.cpp:17
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:633
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:866
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1669
EffectTruncSilence::Intersect
void Intersect(RegionList &dest, const RegionList &src)
Definition: TruncSilence.cpp:860
EffectTruncSilence::mActionChoice
wxChoice * mActionChoice
Definition: TruncSilence.h:106
EffectTruncSilence::mInitialAllowedSilence
double mInitialAllowedSilence
Definition: TruncSilence.h:98
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1865
DEF_BlendFrameCount
static const size_t DEF_BlendFrameCount
Definition: TruncSilence.cpp:114
Registry::Visit
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:478
EffectTruncSilence::UpdateUI
void UpdateUI()
Definition: TruncSilence.cpp:1007
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
EffectTruncSilence::FindSilences
bool FindSilences(RegionList &silences, const TrackList *list, const Track *firstTrack, const Track *lastTrack)
Definition: TruncSilence.cpp:432
EffectTruncSilence::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: TruncSilence.h:32
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
Effect::TotalProgress
bool TotalProgress(double frac, const TranslatableString &={})
Definition: Effect.cpp:2017
Effect::GetNumWaveTracks
int GetNumWaveTracks()
Definition: Effect.h:345
EffectTruncSilence::DoRemoval
bool DoRemoval(const RegionList &silences, unsigned iGroup, unsigned nGroups, Track *firstTrack, Track *lastTrack, double &totalCutLen)
Definition: TruncSilence.cpp:484
Region
#define Region
Definition: VSTControlGTK.h:16
Track::IsSelectedOrSyncLockSelected
bool IsSelectedOrSyncLockSelected() const
Definition: Track.cpp:376
detectFrac
const double detectFrac
Definition: TruncSilence.cpp:121
EffectTruncSilence::mThresholdDB
double mThresholdDB
Definition: TruncSilence.h:96
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
TrackList::SyncLockGroup
static TrackIterRange< Track > SyncLockGroup(Track *pTrack)
Definition: Track.cpp:650
Region
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:52
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
EffectTruncSilence::mIndependent
wxCheckBox * mIndependent
Definition: TruncSilence.h:110
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
WaveTrack::GetFloats
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: WaveTrack.h:265
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1388
ArrayOf< float >
kActionStrings
static const EnumValueSymbol kActionStrings[nActions]
Definition: TruncSilence.cpp:80
EffectTruncSilence::mSilenceCompressPercentT
wxTextCtrl * mSilenceCompressPercentT
Definition: TruncSilence.h:109
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:635
EffectTruncSilence::mBlendFrameCount
size_t mBlendFrameCount
Definition: TruncSilence.h:103
Enums::NumDbChoices
static const size_t NumDbChoices
Definition: TruncSilence.cpp:42
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:452