34 auto &mT0 = effect.
mT0;
35 auto &mT1 = effect.
mT1;
49 if (gAudioIO->IsBusy()) {
56 double previewDuration;
62 gPrefs->
Read(
wxT(
"/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
65 if (isNyquist && isGenerator)
71 double t1 = mT0 + previewDuration;
73 if ((t1 > mT1) && !isGenerator) {
82 auto cleanup =
finally( [&] {
91 std::dynamic_pointer_cast<EffectInstanceEx>(effect.
MakeInstance())
99 if (!previewFullSelection)
107 auto saveTracks = mTracks;
109 auto cleanup2 =
finally( [&] {
110 mTracks = saveTracks;
117 const auto pProject = saveTracks->GetOwner();
122 if (isLinearEffect && !isGenerator) {
130 mTracks->Add(newTrack);
133 newTrack->SetSelected(
true);
136 for (
auto src : saveTracks->Selected<
const WaveTrack>()) {
137 auto dest = src->Copy(mT0, t1);
138 dest->SetSelected(
true);
157 XO(
"Preparing preview"),
167 std::dynamic_pointer_cast<EffectInstanceEx>(effect.
MakeInstance());
168 success = pInstance && pInstance->Process(
settings);
179 t1 =
std::min(mT0 + previewLen, mT1);
183 int token = gAudioIO->StartStream(
tracks, mT0, t1, t1, options);
196 using namespace std::chrono;
197 std::this_thread::sleep_for(100ms);
198 previewing = progress->Poll(
199 gAudioIO->GetStreamTime() - mT0, t1 - mT0);
203 gAudioIO->StopStream();
205 while (gAudioIO->IsBusy()) {
206 using namespace std::chrono;
207 std::this_thread::sleep_for(100ms);
213 *FocusDialog,
XO(
"Error"),
214 XO(
"Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
215 wxT(
"Error_opening_sound_device"),
Toolkit-neutral facade for basic user interface services.
#define NYQUISTEFFECTS_FAMILY
void EffectPreview(EffectBase &effect, EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly)
Calculate temporary tracks of limited length with effect applied and play.
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Track::Holder MixAndRender(const TrackIterRange< const WaveTrack > &trackRange, const Mixer::WarpOptions &warpOptions, const wxString &newTrackName, WaveTrackFactory *trackFactory, double rate, sampleFormat format, double startTime, double endTime)
Mixes together all input tracks, applying any envelopes, per-track real-time effects,...
audacity::BasicSettings * gPrefs
static Settings & settings()
TransportSequences MakeTransportTracks(TrackList &trackList, bool selectedOnly, bool nonWaveToo)
TranslatableString GetName() const
Base class for many of the effects in Audacity.
WaveTrackFactory * mFactory
bool PreviewsFullSelection() const
virtual std::any BeginPreview(const EffectSettings &settings)
Called when Preview() starts, to allow temporary effect state changes.
bool IsLinearEffect() const
BasicUI::ProgressDialog * mProgress
std::shared_ptr< TrackList > mTracks
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual EffectFamilySymbol GetFamily() const =0
Report identifier and user-visible name of the effect protocol.
virtual std::shared_ptr< EffectInstance > MakeInstance() const =0
Make an object maintaining short-term state of an Effect.
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
static TrackListHolder Create(AudacityProject *pOwner)
A Track that contains audio waveform data.
virtual bool Read(const wxString &key, bool *value) const =0
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Options for variations of error dialogs; the default is for modal dialogs.
Externalized state of a plug-in.
Immutable structure is an argument to Mixer's constructor.