Audacity 3.2.0
WaveTrackUtilities.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 WaveTrackUtilities.cpp
7
8 Paul Licameli
9
10**********************************************************************/
11#include "WaveTrackUtilities.h"
12#include "BasicUI.h"
13#include "UserException.h"
14#include "WaveClip.h"
15#include "WaveTrack.h"
16#include <algorithm>
17
19 XO("Pre-processing");
20
22 const WaveTrack &track, double t0, double t1)
23{
24 auto &clips = track.GetClips();
25 return any_of(clips.begin(), clips.end(), [&](auto& pClip) {
26 return pClip->IntersectsPlayRegion(t0, t1) && pClip->HasPitchOrSpeed();
27 });
28}
29
31 std::function<void(const ProgressReporter&)> action,
33{
34 using namespace BasicUI;
35 auto progress =
36 MakeProgress(std::move(title), std::move(message), ProgressShowCancel);
37 const auto reportProgress = [&](double progressFraction) {
38 const auto result = progress->Poll(progressFraction * 1000, 1000);
39 if (result != ProgressResult::Success)
40 throw UserException {};
41 };
42 action(reportProgress);
43}
Toolkit-neutral facade for basic user interface services.
XO("Cut/Copy/Paste")
static const auto title
std::function< void(double)> ProgressReporter
Definition: Track.h:53
An AudacityException with no visible message.
Holds a msgid for the translation catalog; may also bind format arguments.
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
A Track that contains audio waveform data.
Definition: WaveTrack.h:227
WaveClipHolders & GetClips()
Definition: WaveTrack.h:699
@ ProgressShowCancel
Definition: BasicUI.h:142
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:292
WAVE_TRACK_API const TranslatableString defaultStretchRenderingTitle
WAVE_TRACK_API bool HasPitchOrSpeed(const WaveTrack &track, double t0, double t1)
WAVE_TRACK_API void WithClipRenderingProgress(std::function< void(const ProgressReporter &)> action, TranslatableString title=defaultStretchRenderingTitle, TranslatableString message=XO("Rendering Clip"))