1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-24 16:01:16 +02:00

Revert r10644.

This commit is contained in:
BusinessmanProgrammerSteve 2010-09-03 05:39:17 +00:00
parent ff93517312
commit 1b8a8cb8bc

View File

@ -10,8 +10,7 @@
*******************************************************************//**
\class EffectTruncSilence
\brief Truncate Silence automatically reduces the length of passages
where the volume is below a set threshold level.
\brief An Effect.
\todo mBlendFrameCount only retrieved from prefs ... not using dialog
Only way to change (for windows) is thru registry
@ -468,10 +467,9 @@ bool EffectTruncSilence::Process()
double truncDbSilenceThreshold = Enums::Db2Signal[mTruncDbChoiceIndex];
// Master list of silent regions; it is responsible for deleting them.
// This list should always be kept in order.
// This list should always be kept in order
RegionList silences;
RegionList trackSilences; // per track list of silent regions
silences.DeleteContents(true);
// Start with the whole selection silent
Region *sel = new Region;
@ -488,15 +486,19 @@ bool EffectTruncSilence::Process()
// Smallest silent region to detect in frames
sampleCount minSilenceFrames =
(sampleCount)((wxMax(mTruncInitialAllowedSilentMs, minTruncMs) * wt->GetRate()) / 1000.0);
sampleCount((wxMax( mTruncInitialAllowedSilentMs, minTruncMs) *
wt->GetRate()) / 1000.0);
//
// Scan the track for silences
//
RegionList trackSilences;
trackSilences.DeleteContents(true);
sampleCount blockLen = wt->GetMaxBlockSize();
sampleCount start = wt->TimeToLongSamples(mT0);
sampleCount end = wt->TimeToLongSamples(mT1);
// Allocate buffer
float *buffer = new float[blockLen];
sampleCount index = start;
@ -507,9 +509,10 @@ bool EffectTruncSilence::Process()
RegionList::iterator rit(silences.begin());
while (index < end) {
// Show progress dialog, test for cancellation.
cancelled =
TotalProgress(detectFrac * (whichTrack + index / (double)end) / (double)GetNumWaveTracks());
// Show progress dialog, test for cancellation
cancelled = TotalProgress(
detectFrac * (whichTrack + index / (double)end) /
(double)GetNumWaveTracks());
if (cancelled)
break;
@ -575,12 +578,10 @@ bool EffectTruncSilence::Process()
index += count;
}
delete [] buffer; // Finished with buffer.
if (cancelled)
{
silences.DeleteContents(true);
trackSilences.DeleteContents(true);
ReplaceProcessedTracks(false);
delete [] buffer;
// Buffer has been freed, so we're OK to return if cancelled
if (cancelled) {
return false;
}
@ -595,8 +596,6 @@ bool EffectTruncSilence::Process()
// Intersect with the overall silent region list
Intersect(silences, trackSilences);
trackSilences.DeleteContents(true);
whichTrack++;
}
@ -612,13 +611,10 @@ bool EffectTruncSilence::Process()
for (rit = silences.rbegin(); rit != silences.rend(); ++rit) {
Region *r = *rit;
// Progress dialog and cancellation.
if (TotalProgress(detectFrac + (1 - detectFrac) * whichReg / (double)silences.size()))
{
silences.DeleteContents(true);
ReplaceProcessedTracks(false);
// Progress dialog and cancellation; at this point it's safe to return
if (TotalProgress(detectFrac +
(1 - detectFrac) * whichReg / (double)silences.size()))
return false;
}
// Intersection may create regions smaller than allowed; ignore them
if (r->end - r->start < mTruncInitialAllowedSilentMs / 1000.0)
@ -692,7 +688,6 @@ bool EffectTruncSilence::Process()
mT1 -= totalCutLen;
silences.DeleteContents(true);
ReplaceProcessedTracks(true);
return true;