27#include "../MixAndRender.h"
33#include "../WaveTrack.h"
34#include "../widgets/ProgressDialog.h"
35#include "../widgets/NumericTextCtrl.h"
70 wxASSERT(selectedRegion.
duration() >= 0.0);
88 bool isSelection =
false;
98 auto oldDuration = duration;
100 auto cleanup =
finally( [&] {
106 settings.extra.SetDuration(oldDuration);
121 newTrack->SetSelected(
true);
124 mT0 = selectedRegion.
t0();
125 mT1 = selectedRegion.
t1();
133 duration = quantMT1 - quantMT0;
139 auto newFormat = isSelection
143 settings.extra.SetDuration(duration);
144 settings.extra.SetDurationFormat( newFormat );
151 pAccess->ModifySettings(updater);
153#ifdef EXPERIMENTAL_SPECTRAL_EDITING
154 mF0 = selectedRegion.
f0();
155 mF1 = selectedRegion.
f1();
165 std::shared_ptr<EffectInstance> pInstance;
170 if ( pParent && dialogFactory && pAccess &&
173 *pParent, dialogFactory, pInstance, *pAccess,
true ) )
182 auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(pInstance);
187 pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(
MakeInstance());
189 if (!pInstanceEx || !pInstanceEx->Init())
197 bool returnVal =
true;
199 if (skipFlag ==
false)
211 returnVal = pInstanceEx->Process(
settings);
214 if (returnVal && (
mT1 >=
mT0 ))
264 size_t cnt =
mOMap.size();
267 for (; iterOut != iterEnd; ++i) {
268 ListOfTracks::value_type o = *iterOut;
271 while (i < cnt &&
mOMap[i] != o.get()) {
272 const auto t =
mIMap[i];
285 const auto t =
mIMap[i];
301 const auto t =
mIMap[i];
340 if (gAudioIO->IsBusy()) {
344 wxWindow *FocusDialog = wxWindow::FindFocus();
346 double previewDuration;
352 gPrefs->Read(
wxT(
"/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
357 if (isNyquist && isGenerator)
363 double t1 =
mT0 + previewDuration;
365 if ((t1 >
mT1) && !isGenerator) {
374 auto cleanup =
finally( [&] {
383 std::dynamic_pointer_cast<EffectInstanceEx>(
MakeInstance())
406 auto cleanup2 =
finally( [&] {
409 FocusDialog->SetFocus();
418 const auto pProject = saveTracks->
GetOwner();
433 mixLeft->Offset(-mixLeft->GetStartTime());
434 mixLeft->SetSelected(
true);
438 mixRight->
Offset(-mixRight->GetStartTime());
439 mixRight->SetSelected(
true);
447 auto dest = src->Copy(
mT0, t1);
448 dest->SetSelected(src->GetSelected());
468 XO(
"Preparing preview"),
478 std::dynamic_pointer_cast<EffectInstanceEx>(
MakeInstance());
479 success = pInstance && pInstance->Process(
settings);
494 int token = gAudioIO->StartStream(tracks,
mT0, t1, t1, options);
506 using namespace std::chrono;
507 std::this_thread::sleep_for(100ms);
508 previewing = progress.Update(gAudioIO->GetStreamTime() -
mT0, t1 -
mT0);
512 gAudioIO->StopStream();
514 while (gAudioIO->IsBusy()) {
515 using namespace std::chrono;
516 std::this_thread::sleep_for(100ms);
523 XO(
"Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
524 wxT(
"Error_opening_sound_device"),
const TranslatableString name
#define NYQUISTEFFECTS_FAMILY
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
std::function< DialogFactoryResults(wxWindow &parent, EffectPlugin &, EffectUIClientInterface &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
#define QUANTIZED_TIME(time, rate)
void MixAndRender(const TrackIterRange< const WaveTrack > &trackRange, const Mixer::WarpOptions &warpOptions, const wxString &newTrackName, WaveTrackFactory *trackFactory, double rate, sampleFormat format, double startTime, double endTime, WaveTrack::Holder &uLeft, WaveTrack::Holder &uRight)
Mixes together all input tracks, applying any envelopes, amplitude gain, panning, and real-time effec...
#define NYQUIST_PROMPT_ID
static Settings & settings()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Abstraction of a progress dialog with well defined time-to-completion estimate.
virtual PluginPath GetPath() const =0
TranslatableString GetName() const
std::shared_ptr< TrackList > mOutputTracks
bool DoEffect(EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override
Unfortunately complicated dual-use function.
WaveTrackFactory * mFactory
std::vector< Track * > mOMap
void SetPreviewFullSelectionFlag(bool previewDurationFlag)
void SetLinearEffectFlag(bool linearEffectFlag)
const TrackList * inputTracks() const
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
BasicUI::ProgressDialog * mProgress
bool mPreviewWithNotSelected
bool mPreviewFullSelection
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
std::vector< Track * > mIMap
wxArrayString mPresetNames
double GetDefaultDuration()
wxWeakRef< wxDialog > mUIDialog
This weak pointer may be the same as mUIParent, or null.
void IncludeNotSelectedPreviewTracks(bool includeNotSelected)
void SetTracks(TrackList *pTracks)
void ReplaceProcessedTracks(const bool bGoodResult)
bool mIsLinearEffect
This weak pointer may be the same as mHostUIDialog, or null.
void Preview(EffectSettingsAccess &access, bool dryOnly) override
const AudacityProject * FindProject() const
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual bool IsInteractive() const =0
Whether the effect needs a dialog for entry of settings.
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.
std::shared_ptr< EffectSettingsAccess > EffectSettingsAccessPtr
virtual int ShowHostInterface(wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0
Usually applies factory to self and given access.
virtual const EffectSettingsManager & GetDefinition() const =0
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
bool setTimes(double t0, double t1)
static NumericFormatSymbol DefaultSelectionFormat()
static NumericFormatSymbol TimeAndSampleFormat()
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
static const int UndefinedFrequency
bool ReadWithDefault(T *pVar, const T &defaultValue) const
overload of ReadWithDefault returning a boolean that is true if the value was previously defined */
Abstract base class for an object holding data associated with points on a time axis.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
bool MakeMultiChannelTrack(Track &first, int nChannels, bool aligned)
Converts channels to a multichannel track.
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
auto SelectedLeaders() -> TrackIterRange< TrackType >
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
wxString MakeUniqueTrackName(const wxString &baseTrackName) const
Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that...
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
auto Any() -> TrackIterRange< TrackType >
TrackNodePointer Remove(Track *t)
Remove the Track and return an iterator to what followed it.
auto Selected() -> TrackIterRange< TrackType >
AudacityProject * GetOwner()
RAII for a database transaction, possibly nested.
bool Commit()
Commit the transaction.
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
A Track that contains audio waveform data.
static wxString GetDefaultAudioTrackNamePreference()
std::shared_ptr< WaveTrack > Holder
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.
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
PROJECT_RATE_API IntSetting DefaultSampleRate
static RegisteredToolbarFactory factory
Options for variations of error dialogs; the default is for modal dialogs.
Externalized state of a plug-in.
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Immutable structure is an argument to Mixer's constructor.