Audacity  3.2.0
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
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () override
 Type determines how it behaves. More...
 
bool GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. More...
 
bool DefineParams (ShuttleParams &S) 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
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () override
 Whether the effect sorts "above the line" in the menus. More...
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 Whether the effect supports realtime previewing (while audio is playing). More...
 
bool SupportsAutomation () override
 Whether the effect can be used without the UI, in a macro. More...
 
bool LoadUserPreset (const RegistryPath &name) override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name) override
 Save current settings as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id) override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults () override
 Change settings back to "factory default". More...
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 Called for destructive, non-realtime effect computation. More...
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 Called for destructive, non-realtime effect computation. More...
 
bool ProcessFinalize () override
 Called for destructive, non-realtime effect computation. More...
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 Called for destructive, non-realtime effect computation. More...
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () noexcept override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () noexcept override
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
bool PopulateUI (ShuttleGui &S) final
 Adds controls to a panel that is given as the parent window of S More...
 
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
 
EffectDefinitionInterfaceGetDefinition () 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 ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
unsigned TestUIFlags (unsigned mask)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
virtual bool Startup (EffectUIClientInterface *client)
 
virtual bool GetAutomationParametersAsString (wxString &parms)
 
virtual bool SetAutomationParametersFromString (const wxString &parms)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectProcessor
virtual ~EffectProcessor ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 Determines which menu it appears in; default same as GetType(). More...
 
virtual bool EnablesDebug ()
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual FilePath HelpPage ()
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus ()
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIHostInterface
virtual ~EffectUIHostInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 

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 }
 
- Static Public Member Functions inherited from Effect
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Protected Member Functions inherited from Effect
bool EnableApply (bool enable=true)
 
bool EnablePreview (bool enable=true)
 
virtual bool Init ()
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual void End ()
 
virtual void Preview (bool dryOnly)
 
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
BasicUI::ProgressDialogmProgress = nullptr
 
double mProjectRate
 
double mSampleRate
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWeakRef< wxDialog > mUIDialog
 This weak pointer may be the same as the above, or null. More...
 
wxWindow * mUIParent
 
unsigned mUIFlags { 0 }
 
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 134 of file TruncSilence.cpp.

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

References DEF_BlendFrameCount.

◆ ~EffectTruncSilence()

EffectTruncSilence::~EffectTruncSilence ( )
virtual

Definition at line 156 of file TruncSilence.cpp.

157 {
158 }

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 598 of file TruncSilence.cpp.

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

References sampleCount::as_double(), DB_TO_LINEAR(), DEF_MinTruncMs, detectFrac, WaveTrack::GetEndTime(), SampleTrack::GetFloats(), WaveTrack::GetMaxBlockSize(), Effect::GetNumWaveTracks(), WaveTrack::GetRate(), gPrefs, kCompress, kTruncate, limitSampleBufferSize(), SampleTrack::LongSamplesToTime(), mActionIndex, mInitialAllowedSilence, mSilenceCompressPercent, Effect::mT0, Effect::mT1, mThresholdDB, mTruncLongestAllowedSilence, Region, SampleTrack::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 244 of file TruncSilence.cpp.

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

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 186 of file TruncSilence.cpp.

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

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

◆ DoRemoval()

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

Definition at line 484 of file TruncSilence.cpp.

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

References sampleCount::as_size_t(), WaveTrack::Clear(), detectFrac, Region::end, floatSample, SampleTrack::GetFloats(), SyncLock::IsSelectedOrSyncLockSelected(), kCompress, kTruncate, SampleTrack::LongSamplesToTime(), mActionIndex, mBlendFrameCount, min(), mInitialAllowedSilence, Effect::mOutputTracks, mSilenceCompressPercent, mTruncLongestAllowedSilence, Effect::ReplaceProcessedTracks(), WaveTrack::Set(), Region::start, SampleTrack::TimeToLongSamples(), Effect::TotalProgress(), and 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 432 of file TruncSilence.cpp.

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

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

Save current settings into parms.

Reimplemented from Effect.

Definition at line 196 of file TruncSilence.cpp.

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

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

◆ GetDescription()

TranslatableString EffectTruncSilence::GetDescription ( )
overridevirtual

Reimplemented from Effect.

Definition at line 167 of file TruncSilence.cpp.

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

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectTruncSilence::GetSymbol ( )
overridevirtual

Reimplemented from Effect.

Definition at line 162 of file TruncSilence.cpp.

163 {
164  return Symbol;
165 }

References Symbol.

◆ GetType()

EffectType EffectTruncSilence::GetType ( )
overridevirtual

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 179 of file TruncSilence.cpp.

180 {
181  return EffectTypeProcess;
182 }

References EffectTypeProcess.

◆ Intersect()

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

Definition at line 861 of file TruncSilence.cpp.

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

Referenced by FindSilences().

Here is the caller graph for this function:

◆ ManualPage()

ManualPageID EffectTruncSilence::ManualPage ( )
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 172 of file TruncSilence.cpp.

173 {
174  return L"Truncate_Silence";
175 }

◆ OnControlChange()

void EffectTruncSilence::OnControlChange ( wxCommandEvent &  evt)
private

Definition at line 1022 of file TruncSilence.cpp.

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

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 755 of file TruncSilence.cpp.

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

References kActionStrings, mActionChoice, mActionIndex, mbIndependent, mIndependent, mInitialAllowedSilence, mInitialAllowedSilenceT, Msgids(), mSilenceCompressPercent, mSilenceCompressPercentT, mThresholdDB, mThresholdText, mTruncLongestAllowedSilence, mTruncLongestAllowedSilenceT, nActions, S, UpdateUI(), XO, and XXO.

Here is the call graph for this function:

◆ Process()

bool EffectTruncSilence::Process ( )
overridevirtual

If Process() is not overridden, it uses ProcessInitialize(), ProcessBlock(), and ProcessFinalize() methods of EffectProcessor, and also GetLatency() to determine how many leading output samples to discard and how many extra samples to produce.

Reimplemented from Effect.

Definition at line 322 of file TruncSilence.cpp.

323 {
324  const bool success =
327  : ProcessAll();
328 
329  if (success)
331 
332  return success;
333 }

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

Here is the call graph for this function:

◆ ProcessAll()

bool EffectTruncSilence::ProcessAll ( )
private

Definition at line 408 of file TruncSilence.cpp.

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

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 335 of file TruncSilence.cpp.

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

References TrackList::Channels(), Effect::CopyInputTracks(), DoRemoval(), Effect::FindProject(), FindSilences(), ProjectSettings::Get(), SyncLock::Group(), Effect::inputTracks(), Track::IsSelected(), Effect::MessageBox(), Effect::mOutputTracks, Effect::mT1, settings(), 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

Change settings to those stored in parms.

Reimplemented from Effect.

Definition at line 208 of file TruncSilence.cpp.

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

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 271 of file TruncSilence.cpp.

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

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 846 of file TruncSilence.cpp.

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

References mbIndependent, mIndependent, and Effect::mUIParent.

◆ TransferDataToWindow()

bool EffectTruncSilence::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 836 of file TruncSilence.cpp.

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

References Effect::mUIParent.

◆ UpdateUI()

void EffectTruncSilence::UpdateUI ( void  )
private

Definition at line 1008 of file TruncSilence.cpp.

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

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:
Visit
auto Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: MemoryX.h:570
DEF_MinTruncMs
static const double DEF_MinTruncMs
Definition: TruncSilence.cpp:119
EffectTruncSilence::mTruncLongestAllowedSilence
double mTruncLongestAllowedSilence
Definition: TruncSilence.h:99
Effect::FindProject
const AudacityProject * FindProject() const
Definition: Effect.cpp:2035
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:56
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
EffectTruncSilence::mThresholdText
wxTextCtrl * mThresholdText
Definition: TruncSilence.h:105
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1764
Effect::EnableApply
bool EnableApply(bool enable=true)
Definition: Effect.cpp:1694
S
#define S(N)
Definition: ToChars.cpp:64
Enums::DbChoices
static const EnumValueSymbol DbChoices[]
Definition: TruncSilence.cpp:44
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:71
kObsoleteActions
static CommandParameters::ObsoleteMap kObsoleteActions[]
Definition: TruncSilence.cpp:87
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2238
WaveTrack::GetEndTime
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:2014
EffectTruncSilence::mTruncLongestAllowedSilenceT
wxTextCtrl * mTruncLongestAllowedSilenceT
Definition: TruncSilence.h:108
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:1834
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1483
nObsoleteActions
static const size_t nObsoleteActions
Definition: TruncSilence.cpp:93
EffectTruncSilence::mInitialAllowedSilenceT
wxTextCtrl * mInitialAllowedSilenceT
Definition: TruncSilence.h:107
Effect::mT1
double mT1
Definition: Effect.h:424
kTruncate
@ kTruncate
Definition: TruncSilence.cpp:76
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:45
Region::start
double start
Definition: WaveTrack.h:61
RegionList
Definition: TruncSilence.cpp:72
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Save current settings as a user-named preset.
Definition: Effect.cpp:547
enumToDB
static double enumToDB(int val)
Definition: TruncSilence.cpp:67
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:598
WaveTrack::Set
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:2194
floatSample
@ floatSample
Definition: SampleFormat.h:34
EffectTruncSilence::ProcessIndependently
bool ProcessIndependently()
Definition: TruncSilence.cpp:335
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:580
ReadAndVerifyEnumWithObsoletes
#define ReadAndVerifyEnumWithObsoletes(name, list, listSize, obsoleteList, nObsolete)
Definition: Effect.h:585
XXO
#define XXO(s)
Definition: Internat.h:44
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:790
Effect::inputTracks
const TrackList * inputTracks() const
Definition: Effect.h:420
kCompress
@ kCompress
Definition: TruncSilence.cpp:77
Effect::mT0
double mT0
Definition: Effect.h:423
sampleCount::as_double
double as_double() const
Definition: SampleCount.h:45
TrackList::begin
iterator begin()
Definition: Track.h:1332
SampleTrack::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: SampleTrack.h:64
EffectTruncSilence::ProcessAll
bool ProcessAll()
Definition: TruncSilence.cpp:408
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:1956
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:295
nActions
@ nActions
Definition: TruncSilence.cpp:78
EffectTruncSilence::mActionIndex
int mActionIndex
Definition: TruncSilence.h:97
SyncLock::IsSelectedOrSyncLockSelected
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:73
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const override
This returns a nonnegative number of samples meant to size a memory buffer.
Definition: WaveTrack.cpp:1811
Region::end
double end
Definition: WaveTrack.h:61
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:422
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2523
sampleCount::as_size_t
size_t as_size_t() const
Definition: SampleCount.cpp:17
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:592
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:820
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectTruncSilence::Intersect
void Intersect(RegionList &dest, const RegionList &src)
Definition: TruncSilence.cpp:861
EffectTruncSilence::mActionChoice
wxChoice * mActionChoice
Definition: TruncSilence.h:106
EffectTruncSilence::mInitialAllowedSilence
double mInitialAllowedSilence
Definition: TruncSilence.h:98
DEF_BlendFrameCount
static const size_t DEF_BlendFrameCount
Definition: TruncSilence.cpp:115
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:438
EffectTruncSilence::UpdateUI
void UpdateUI()
Definition: TruncSilence.cpp:1008
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:433
WaveTrack::GetRate
double GetRate() const override
Definition: WaveTrack.cpp:495
SyncLock::Group
static TrackIterRange< Track > Group(Track *pTrack)
Definition: SyncLock.cpp:122
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:1780
SampleTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:35
Effect::GetNumWaveTracks
int GetNumWaveTracks()
Definition: Effect.h:304
EffectTruncSilence::DoRemoval
bool DoRemoval(const RegionList &silences, unsigned iGroup, unsigned nGroups, Track *firstTrack, Track *lastTrack, double &totalCutLen)
Definition: TruncSilence.cpp:485
Region
#define Region
Definition: VSTControlGTK.h:16
detectFrac
const double detectFrac
Definition: TruncSilence.cpp:122
EffectTruncSilence::mThresholdDB
double mThresholdDB
Definition: TruncSilence.h:96
Region
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:57
settings
static Settings & settings()
Definition: TrackInfo.cpp:87
EffectTruncSilence::mIndependent
wxCheckBox * mIndependent
Definition: TruncSilence.h:110
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
SampleTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:40
TrackList::Selected
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1396
ArrayOf< float >
kActionStrings
static const EnumValueSymbol kActionStrings[nActions]
Definition: TruncSilence.cpp:81
EffectTruncSilence::mSilenceCompressPercentT
wxTextCtrl * mSilenceCompressPercentT
Definition: TruncSilence.h:109
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:594
EffectTruncSilence::mBlendFrameCount
size_t mBlendFrameCount
Definition: TruncSilence.h:103
Enums::NumDbChoices
static const size_t NumDbChoices
Definition: TruncSilence.cpp:43