From 277f64c4ca041fa01dec04412ed80c34f1fcf495 Mon Sep 17 00:00:00 2001 From: Max Maisel Date: Sun, 8 Mar 2020 10:00:59 +0100 Subject: [PATCH] Imprement progress dialog. Signed-off-by: Max Maisel --- src/effects/Compressor2.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/effects/Compressor2.cpp b/src/effects/Compressor2.cpp index 5c70ede44..c389f0080 100644 --- a/src/effects/Compressor2.cpp +++ b/src/effects/Compressor2.cpp @@ -995,7 +995,6 @@ void EffectCompressor2::SwapPipeline() std::cerr << "\n" << std::flush; #endif - ++mProgressVal; for(size_t i = 0; i < PIPELINE_DEPTH-1; ++i) mPipeline[i].swap(mPipeline[i+1]); #ifdef DEBUG_COMPRESSOR2_TRACE @@ -1063,6 +1062,9 @@ bool EffectCompressor2::ProcessOne(TrackIterRange range) // Increment s one blockfull of samples pos += blockLen; + + if(!UpdateProgress()) + return false; } // Handle short selections @@ -1079,6 +1081,8 @@ bool EffectCompressor2::ProcessOne(TrackIterRange range) #endif SwapPipeline(); FillPipeline(); + if(!UpdateProgress()) + return false; } while(PipelineHasData()) @@ -1086,6 +1090,8 @@ bool EffectCompressor2::ProcessOne(TrackIterRange range) StorePipeline(range); SwapPipeline(); DrainPipeline(); + if(!UpdateProgress()) + return false; } #ifdef DEBUG_COMPRESSOR2_TRACE std::cerr << "StoreLastBlock\n" << std::flush; @@ -1289,6 +1295,14 @@ void EffectCompressor2::StorePipeline(TrackIterRange range) mPipeline[0].size = 0; } +bool EffectCompressor2::UpdateProgress() +{ + mProgressVal += + (double(1+mProcStereo) * mPipeline[PIPELINE_DEPTH-1].trackSize) + / (double(GetNumWaveTracks()) * mTrackLen); + return !TotalProgress(mProgressVal); +} + void EffectCompressor2::OnUpdateUI(wxCommandEvent & WXUNUSED(evt)) { if(!mIgnoreGuiEvents)