24#include "../AudioIO.h"
27#include "../MixAndRender.h"
29#include "../ProjectAudioManager.h"
33#include "../WaveTrack.h"
34#include "../widgets/ProgressDialog.h"
35#include "../widgets/NumericTextCtrl.h"
70 wxASSERT(selectedRegion.
duration() >= 0.0);
85 bool isSelection =
false;
95 auto oldDuration = duration;
97 auto cleanup =
finally( [&] {
103 settings.extra.SetDuration(oldDuration);
118 newTrack->SetSelected(
true);
121 mT0 = selectedRegion.
t0();
122 mT1 = selectedRegion.
t1();
130 duration = quantMT1 - quantMT0;
136 auto newFormat = isSelection
140 settings.extra.SetDuration(duration);
141 settings.extra.SetDurationFormat( newFormat );
147 pAccess->ModifySettings(updater);
149#ifdef EXPERIMENTAL_SPECTRAL_EDITING
150 mF0 = selectedRegion.
f0();
151 mF1 = selectedRegion.
f1();
162 if (!pInstance->Init())
168 if ( pParent && dialogFactory && pAccess &&
181 bool returnVal =
true;
183 if (skipFlag ==
false)
194 returnVal = pInstance->Process(
settings);
197 if (returnVal && (
mT1 >=
mT0 ))
247 size_t cnt =
mOMap.size();
250 for (; iterOut != iterEnd; ++i) {
251 ListOfTracks::value_type o = *iterOut;
254 while (i < cnt &&
mOMap[i] != o.get()) {
255 const auto t =
mIMap[i];
268 const auto t =
mIMap[i];
284 const auto t =
mIMap[i];
323 if (gAudioIO->IsBusy()) {
327 wxWindow *FocusDialog = wxWindow::FindFocus();
329 double previewDuration;
335 gPrefs->Read(wxT(
"/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
340 if (isNyquist && isGenerator)
346 double t1 =
mT0 + previewDuration;
348 if ((t1 >
mT1) && !isGenerator) {
357 auto cleanup =
finally( [&] {
386 auto cleanup2 =
finally( [&] {
389 FocusDialog->SetFocus();
398 const auto pProject = saveTracks->
GetOwner();
413 mixLeft->Offset(-mixLeft->GetStartTime());
414 mixLeft->SetSelected(
true);
418 mixRight->
Offset(-mixRight->GetStartTime());
419 mixRight->SetSelected(
true);
427 auto dest = src->Copy(
mT0, t1);
428 dest->SetSelected(src->GetSelected());
448 XO(
"Preparing preview"),
470 int token = gAudioIO->StartStream(tracks,
mT0, t1, t1, options);
482 using namespace std::chrono;
483 std::this_thread::sleep_for(100ms);
484 previewing = progress.Update(gAudioIO->GetStreamTime() -
mT0, t1 -
mT0);
488 gAudioIO->StopStream();
490 while (gAudioIO->IsBusy()) {
491 using namespace std::chrono;
492 std::this_thread::sleep_for(100ms);
499 XO(
"Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
500 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< wxDialog *(wxWindow &parent, EffectPlugin &, EffectUIClientInterface &, EffectInstance &, 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
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
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 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.
virtual int ShowHostInterface(wxWindow &parent, const EffectDialogFactory &factory, EffectInstance &instance, EffectSettingsAccess &access, bool forceModal=false)=0
Usually applies factory to self and given access.
std::shared_ptr< EffectSettingsAccess > EffectSettingsAccessPtr
virtual const EffectSettingsManager & GetDefinition() const =0
virtual bool IsBatchProcessing() 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 TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool nonWaveToo=false)
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
Options for variations of error dialogs; the default is for modal dialogs.
Externalized state of a plug-in.