Save/restore effect state during batch processing
This commit is contained in:
parent
e41db0e4b4
commit
7407243e25
|
@ -193,17 +193,10 @@ void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
|
|||
wxString command = mCommand->GetValue();
|
||||
wxString params = mParameters->GetValue();
|
||||
|
||||
if (BatchCommands::SetCurrentParametersFor( command, params ))
|
||||
{
|
||||
if( BatchCommands::PromptForParamsFor( command, this ))
|
||||
{
|
||||
// we've just prompted for the parameters, so the values
|
||||
// that are current have changed.
|
||||
params = BatchCommands::GetCurrentParamsFor( command );
|
||||
mParameters->SetValue( params.Strip(wxString::trailing) );
|
||||
mParameters->Refresh();
|
||||
}
|
||||
}
|
||||
params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
|
||||
|
||||
mParameters->SetValue(params);
|
||||
mParameters->Refresh();
|
||||
}
|
||||
|
||||
void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
|
||||
|
@ -211,12 +204,10 @@ void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
|
|||
wxString command = mCommand->GetValue();
|
||||
wxString params = mParameters->GetValue();
|
||||
|
||||
wxString preset = BatchCommands::PromptForPresetFor(command, params, this);
|
||||
if (!preset.IsEmpty())
|
||||
{
|
||||
mParameters->SetValue(preset);
|
||||
mParameters->Refresh();
|
||||
}
|
||||
wxString preset = BatchCommands::PromptForPresetFor(command, params, this).Trim();
|
||||
|
||||
mParameters->SetValue(preset);
|
||||
mParameters->Refresh();
|
||||
}
|
||||
|
||||
void BatchCommandDialog::SetCommandAndParams(const wxString &Command, const wxString &Params)
|
||||
|
|
|
@ -308,7 +308,7 @@ wxArrayString BatchCommands::GetAllCommands()
|
|||
wxString BatchCommands::GetCurrentParamsFor(const wxString & command)
|
||||
{
|
||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||
if( ID.empty() )
|
||||
if (ID.empty())
|
||||
{
|
||||
return wxEmptyString; // effect not found.
|
||||
}
|
||||
|
@ -316,22 +316,34 @@ wxString BatchCommands::GetCurrentParamsFor(const wxString & command)
|
|||
return EffectManager::Get().GetEffectParameters(ID);
|
||||
}
|
||||
|
||||
bool BatchCommands::PromptForParamsFor(const wxString & command, wxWindow *parent)
|
||||
wxString BatchCommands::PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent)
|
||||
{
|
||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||
|
||||
if (ID.empty())
|
||||
{
|
||||
return false;
|
||||
return wxEmptyString; // effect not found
|
||||
}
|
||||
|
||||
return EffectManager::Get().PromptUser(ID, parent);
|
||||
wxString res = params;
|
||||
|
||||
EffectManager::Get().SetBatchProcessing(ID, true);
|
||||
|
||||
if (EffectManager::Get().SetEffectParameters(ID, params))
|
||||
{
|
||||
if (EffectManager::Get().PromptUser(ID, parent))
|
||||
{
|
||||
res = EffectManager::Get().GetEffectParameters(ID);
|
||||
}
|
||||
}
|
||||
|
||||
EffectManager::Get().SetBatchProcessing(ID, false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
wxString BatchCommands::PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent)
|
||||
{
|
||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||
|
||||
if (ID.empty())
|
||||
{
|
||||
return wxEmptyString; // effect not found.
|
||||
|
@ -564,23 +576,6 @@ bool BatchCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString &
|
|||
}
|
||||
// end CLEANSPEECH remnant
|
||||
|
||||
bool BatchCommands::SetCurrentParametersFor(const wxString & command, const wxString & params)
|
||||
{
|
||||
if (params.IsEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// transfer the parameters to the effect...
|
||||
const PluginID & ID = EffectManager::Get().GetEffectByIdentifier(command);
|
||||
if (ID.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return EffectManager::Get().SetEffectParameters(ID, params);
|
||||
}
|
||||
|
||||
bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & command, const wxString & params)
|
||||
{
|
||||
//Possibly end processing here, if in batch-debug
|
||||
|
@ -594,13 +589,21 @@ bool BatchCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com
|
|||
// (most effects require that you have something selected).
|
||||
project->SelectAllIfNone();
|
||||
|
||||
if (!SetCurrentParametersFor(command, params))
|
||||
return false;
|
||||
|
||||
// NOW actually apply the effect.
|
||||
return project->OnEffect(ID, AudacityProject::OnEffectFlags::kConfigured |
|
||||
AudacityProject::OnEffectFlags::kSkipState |
|
||||
AudacityProject::OnEffectFlags::kIsBatch );
|
||||
bool res = false;
|
||||
|
||||
EffectManager::Get().SetBatchProcessing(ID, true);
|
||||
|
||||
// transfer the parameters to the effect...
|
||||
if (EffectManager::Get().SetEffectParameters(ID, params))
|
||||
{
|
||||
// and apply the effect...
|
||||
res = project->OnEffect(ID, AudacityProject::OnEffectFlags::kConfigured |
|
||||
AudacityProject::OnEffectFlags::kSkipState);
|
||||
}
|
||||
|
||||
EffectManager::Get().SetBatchProcessing(ID, false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool BatchCommands::ApplyCommand(const wxString & command, const wxString & params)
|
||||
|
|
|
@ -39,14 +39,13 @@ class BatchCommands {
|
|||
bool IsMono();
|
||||
|
||||
// These commands do not depend on the command list.
|
||||
wxArrayString GetNames();
|
||||
static bool PromptForParamsFor(const wxString & command, wxWindow *parent );
|
||||
static wxString GetCurrentParamsFor(const wxString & command);
|
||||
static bool SetCurrentParametersFor(const wxString & command, const wxString & params);
|
||||
static wxString PromptForPresetFor( const wxString & command, const wxString & params, wxWindow *parent );
|
||||
static bool SetCurrentPresetFor(const wxString & command, const wxString & preset);
|
||||
static wxArrayString GetNames();
|
||||
static wxArrayString GetAllCommands();
|
||||
|
||||
static wxString GetCurrentParamsFor(const wxString & command);
|
||||
static wxString PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent);
|
||||
static wxString PromptForPresetFor(const wxString & command, const wxString & params, wxWindow *parent);
|
||||
|
||||
// These commands do depend on the command list.
|
||||
void ResetChain();
|
||||
|
||||
|
|
|
@ -3216,8 +3216,7 @@ bool AudacityProject::OnEffect(const PluginID & ID, int flags)
|
|||
bool success = em.DoEffect(ID, this, mRate,
|
||||
mTracks, mTrackFactory,
|
||||
&mViewInfo.selectedRegion,
|
||||
(flags & OnEffectFlags::kConfigured) == 0,
|
||||
(flags & OnEffectFlags::kIsBatch) != 0);
|
||||
(flags & OnEffectFlags::kConfigured) == 0);
|
||||
|
||||
if (!success) {
|
||||
if (newTrack) {
|
||||
|
|
|
@ -367,8 +367,6 @@ public:
|
|||
static const int kConfigured = 0x01;
|
||||
// Flag used to disable saving the state after processing.
|
||||
static const int kSkipState = 0x02;
|
||||
// Flag used to designate batch processing is active.
|
||||
static const int kIsBatch = 0x04;
|
||||
};
|
||||
|
||||
bool OnEffect(const PluginID & ID, int flags = OnEffectFlags::kNone);
|
||||
|
|
|
@ -808,6 +808,11 @@ wxString Effect::GetFactoryDefaultsGroup()
|
|||
return wxT("FactoryDefaults");
|
||||
}
|
||||
|
||||
wxString Effect::GetSavedStateGroup()
|
||||
{
|
||||
return wxT("SavedState");
|
||||
}
|
||||
|
||||
// ConfigClientInterface implementation
|
||||
bool Effect::HasSharedConfigGroup(const wxString & group)
|
||||
{
|
||||
|
@ -1125,9 +1130,18 @@ bool Effect::IsBatchProcessing()
|
|||
return mIsBatch;
|
||||
}
|
||||
|
||||
void Effect::SetBatchProcessing(bool enable)
|
||||
void Effect::SetBatchProcessing(bool start)
|
||||
{
|
||||
mIsBatch = enable;
|
||||
mIsBatch = start;
|
||||
|
||||
if (start)
|
||||
{
|
||||
SaveUserPreset(GetSavedStateGroup());
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadUserPreset(GetSavedStateGroup());
|
||||
}
|
||||
}
|
||||
|
||||
bool Effect::DoEffect(wxWindow *parent,
|
||||
|
|
|
@ -155,6 +155,7 @@ class AUDACITY_DLL_API Effect : public wxEvtHandler,
|
|||
virtual wxString GetUserPresetsGroup(const wxString & name);
|
||||
virtual wxString GetCurrentSettingsGroup();
|
||||
virtual wxString GetFactoryDefaultsGroup();
|
||||
virtual wxString GetSavedStateGroup();
|
||||
|
||||
// ConfigClientInterface implementation
|
||||
|
||||
|
@ -214,7 +215,7 @@ class AUDACITY_DLL_API Effect : public wxEvtHandler,
|
|||
virtual wxString GetPreset(wxWindow * parent, const wxString & parms);
|
||||
|
||||
virtual bool IsBatchProcessing();
|
||||
virtual void SetBatchProcessing(bool enable);
|
||||
virtual void SetBatchProcessing(bool start);
|
||||
|
||||
void SetPresetParameters( const wxArrayString * Names, const wxArrayString * Values ){
|
||||
if( Names ) mPresetNames = *Names;
|
||||
|
|
|
@ -77,8 +77,7 @@ bool EffectManager::DoEffect(const PluginID & ID,
|
|||
TrackList *list,
|
||||
TrackFactory *factory,
|
||||
SelectedRegion *selectedRegion,
|
||||
bool shouldPrompt /* = true */,
|
||||
bool isBatch /* = false */)
|
||||
bool shouldPrompt /* = true */)
|
||||
|
||||
{
|
||||
Effect *effect = GetEffect(ID);
|
||||
|
@ -95,8 +94,6 @@ bool EffectManager::DoEffect(const PluginID & ID,
|
|||
}
|
||||
#endif
|
||||
|
||||
effect->SetBatchProcessing(isBatch);
|
||||
|
||||
bool res = effect->DoEffect(parent,
|
||||
projectRate,
|
||||
list,
|
||||
|
@ -104,8 +101,6 @@ bool EffectManager::DoEffect(const PluginID & ID,
|
|||
selectedRegion,
|
||||
shouldPrompt);
|
||||
|
||||
effect->SetBatchProcessing(false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -205,11 +200,7 @@ bool EffectManager::PromptUser(const PluginID & ID, wxWindow *parent)
|
|||
|
||||
if (effect)
|
||||
{
|
||||
effect->SetBatchProcessing(true);
|
||||
|
||||
result = effect->PromptUser(parent);
|
||||
|
||||
effect->SetBatchProcessing(false);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -291,6 +282,18 @@ wxString EffectManager::GetDefaultPreset(const PluginID & ID)
|
|||
return preset;
|
||||
}
|
||||
|
||||
void EffectManager::SetBatchProcessing(const PluginID & ID, bool start)
|
||||
{
|
||||
Effect *effect = GetEffect(ID);
|
||||
|
||||
if (!effect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
effect->SetBatchProcessing(start);
|
||||
}
|
||||
|
||||
#if defined(EXPERIMENTAL_EFFECTS_RACK)
|
||||
EffectRack *EffectManager::GetRack()
|
||||
{
|
||||
|
|
|
@ -71,8 +71,7 @@ public:
|
|||
TrackList *list,
|
||||
TrackFactory *factory,
|
||||
SelectedRegion *selectedRegion,
|
||||
bool shouldPrompt = true,
|
||||
bool isBatch = false);
|
||||
bool shouldPrompt = true);
|
||||
|
||||
wxString GetEffectName(const PluginID & ID);
|
||||
wxString GetEffectIdentifier(const PluginID & ID);
|
||||
|
@ -86,6 +85,7 @@ public:
|
|||
bool HasPresets(const PluginID & ID);
|
||||
wxString GetPreset(const PluginID & ID, const wxString & params, wxWindow * parent);
|
||||
wxString GetDefaultPreset(const PluginID & ID);
|
||||
void SetBatchProcessing(const PluginID & ID, bool start);
|
||||
|
||||
// Realtime effect processing
|
||||
bool RealtimeIsActive();
|
||||
|
|
Loading…
Reference in New Issue