1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 00:20:06 +02:00

Adding preview to Nyquist effects as requested by STF

He also added a new Nyquist control header that gives each
effect the ability to control the presentation of the Preview
button.  This will be used by effects are time based and, therefore,
do not produce the same results in preview as they do when applied.

I expect Steve will be committing changes to the effects that can
take advantage of this shortly.

Testing of this can be accomplished by adding:

;preview enabled

to the "tremelo.ny" effect, just after the ";action" line.

Adding that line will cause the "Preview" button to be shown and
you will then be able to preview, adjust, preview, apply...
This commit is contained in:
lllucius 2014-10-05 18:22:41 +00:00
parent f5e593cc4c
commit 8ecd6b538d
2 changed files with 70 additions and 26 deletions

View File

@ -282,6 +282,13 @@ void EffectNyquist::Parse(wxString line)
return; return;
} }
if (len >= 2 && tokens[0] == wxT("preview")) {
if (tokens[1] == wxT("enabled") || tokens[1] == wxT("true")) {
mEnablePreview = true;
}
return;
}
if (len >= 6 && tokens[0] == wxT("control")) { if (len >= 6 && tokens[0] == wxT("control")) {
NyqControl ctrl; NyqControl ctrl;
@ -346,6 +353,7 @@ void EffectNyquist::ParseFile()
mCmd = wxT(""); mCmd = wxT("");
SetEffectFlags(PROCESS_EFFECT | PLUGIN_EFFECT); SetEffectFlags(PROCESS_EFFECT | PLUGIN_EFFECT);
mOK = false; mOK = false;
mEnablePreview = false;
mIsSal = false; mIsSal = false;
mControls.Clear(); mControls.Clear();
mDebug = false; mDebug = false;
@ -499,7 +507,7 @@ bool EffectNyquist::TransferParameters( Shuttle & shuttle )
bool EffectNyquist::PromptUser() bool EffectNyquist::PromptUser()
{ {
if (mInteractive) { while (mInteractive) {
NyquistInputDialog dlog(wxGetTopLevelParent(NULL), -1, NyquistInputDialog dlog(wxGetTopLevelParent(NULL), -1,
_("Nyquist Prompt"), _("Nyquist Prompt"),
_("Enter Nyquist Command: "), _("Enter Nyquist Command: "),
@ -563,7 +571,12 @@ bool EffectNyquist::PromptUser()
} }
} }
return true; if (result != ePreviewID)
{
return true;
}
Preview();
} }
if (!mExternal) { if (!mExternal) {
@ -614,7 +627,7 @@ bool EffectNyquist::PromptUser()
} }
} }
NyquistDialog dlog(mParent, -1, mName, mInfo, &mControls); NyquistDialog dlog(mParent, -1, mName, mInfo, mEnablePreview, this);
dlog.CentreOnParent(); dlog.CentreOnParent();
int result = dlog.ShowModal(); int result = dlog.ShowModal();
@ -1156,6 +1169,7 @@ BEGIN_EVENT_TABLE(NyquistDialog, wxDialog)
EVT_BUTTON(wxID_OK, NyquistDialog::OnOk) EVT_BUTTON(wxID_OK, NyquistDialog::OnOk)
EVT_BUTTON(wxID_CANCEL, NyquistDialog::OnCancel) EVT_BUTTON(wxID_CANCEL, NyquistDialog::OnCancel)
EVT_BUTTON(eDebugID, NyquistDialog::OnDebug) EVT_BUTTON(eDebugID, NyquistDialog::OnDebug)
EVT_BUTTON(ePreviewID, NyquistDialog::OnPreview)
EVT_COMMAND_RANGE(ID_NYQ_SLIDER, ID_NYQ_SLIDER+99, EVT_COMMAND_RANGE(ID_NYQ_SLIDER, ID_NYQ_SLIDER+99,
wxEVT_COMMAND_SLIDER_UPDATED, NyquistDialog::OnSlider) wxEVT_COMMAND_SLIDER_UPDATED, NyquistDialog::OnSlider)
EVT_COMMAND_RANGE(ID_NYQ_TEXT, ID_NYQ_TEXT+99, EVT_COMMAND_RANGE(ID_NYQ_TEXT, ID_NYQ_TEXT+99,
@ -1167,10 +1181,12 @@ END_EVENT_TABLE()
NyquistDialog::NyquistDialog(wxWindow * parent, wxWindowID id, NyquistDialog::NyquistDialog(wxWindow * parent, wxWindowID id,
const wxString & title, const wxString & title,
wxString info, wxString info,
NyqControlArray *controlArray) bool preview,
EffectNyquist *effect)
: wxDialog(parent, id, title) : wxDialog(parent, id, title)
{ {
mControls = controlArray; mEffect = effect;
mControls = &mEffect->mControls;
mInHandler = true; // prevents race condition on MSW mInHandler = true; // prevents race condition on MSW
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
@ -1279,9 +1295,15 @@ NyquistDialog::NyquistDialog(wxWindow * parent, wxWindowID id,
} }
mainSizer->Add(grid, 0, wxALIGN_CENTRE | wxALL, 5); mainSizer->Add(grid, 0, wxALIGN_CENTRE | wxALL, 5);
mainSizer->Add(CreateStdButtonSizer(this, eDebugButton | eCancelButton | eOkButton), if (preview) {
0, mainSizer->Add(CreateStdButtonSizer(this, ePreviewButton | eDebugButton | eCancelButton | eOkButton),
wxEXPAND); 0,
wxEXPAND);
} else {
mainSizer->Add(CreateStdButtonSizer(this, eDebugButton | eCancelButton | eOkButton),
0,
wxEXPAND);
}
mInHandler = false; mInHandler = false;
@ -1420,39 +1442,49 @@ void NyquistDialog::OnDebug(wxCommandEvent & /* event */)
EndModal(eDebugID); EndModal(eDebugID);
} }
void NyquistDialog::OnPreview(wxCommandEvent & /* event */)
{
mEffect->Preview();
}
/**********************************************************/ /**********************************************************/
BEGIN_EVENT_TABLE(NyquistInputDialog, wxDialog) BEGIN_EVENT_TABLE(NyquistInputDialog, wxDialog)
EVT_BUTTON(wxID_OK, NyquistInputDialog::OnOk) EVT_BUTTON(wxID_OK, NyquistInputDialog::OnOk)
EVT_BUTTON(wxID_CANCEL, NyquistInputDialog::OnCancel) EVT_BUTTON(wxID_CANCEL, NyquistInputDialog::OnCancel)
EVT_BUTTON(eDebugID, NyquistInputDialog::OnDebug) EVT_BUTTON(eDebugID, NyquistInputDialog::OnDebug)
EVT_BUTTON(ePreviewID, NyquistInputDialog::OnPreview)
END_EVENT_TABLE() END_EVENT_TABLE()
NyquistInputDialog::NyquistInputDialog(wxWindow * parent, wxWindowID id, NyquistInputDialog::NyquistInputDialog(wxWindow * parent, wxWindowID id,
const wxString & title, const wxString & title,
const wxString & prompt, const wxString & prompt,
wxString initialCommand) wxString initialCommand)
: wxDialog(parent, id, title) : wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{ {
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); ShuttleGui S(this, eIsCreating);
wxControl *item;
item = new wxStaticText(this, -1, prompt); S.StartVerticalLay();
item->SetName(prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) {
mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); S.StartHorizontalLay(wxEXPAND, 0);
{
S.AddVariableText(prompt);
}
S.EndHorizontalLay();
mCommandText = new wxTextCtrl(this, -1, initialCommand, S.StartHorizontalLay(wxEXPAND, 1);
wxDefaultPosition, wxSize(400, 200), {
wxTE_MULTILINE); mCommandText = S.AddTextWindow(initialCommand);
mainSizer->Add(mCommandText, 0, wxALIGN_LEFT | wxALL, 10); mCommandText->SetMinSize(wxSize(500, 200));
}
S.EndHorizontalLay();
}
S.EndVerticalLay();
// Debug, OK, & Cancel buttons // Debug, OK, & Cancel buttons
mainSizer->Add(CreateStdButtonSizer(this, eDebugButton|eCancelButton|eOkButton), 0, wxEXPAND); S.AddStandardButtons(ePreviewButton|eDebugButton|eCancelButton|eOkButton);
SetAutoLayout(true); GetSizer()->SetSizeHints(this);
SetSizer(mainSizer);
mainSizer->Fit(this);
mainSizer->SetSizeHints(this);
mCommandText->SetFocus(); mCommandText->SetFocus();
} }
@ -1479,6 +1511,11 @@ void NyquistInputDialog::OnDebug(wxCommandEvent & /* event */)
EndModal(eDebugID); EndModal(eDebugID);
} }
void NyquistInputDialog::OnPreview(wxCommandEvent & /* event */)
{
EndModal(ePreviewID);
}
/**********************************************************/ /**********************************************************/

View File

@ -172,6 +172,7 @@ class AUDACITY_DLL_API EffectNyquist:public Effect
wxString mName; ///< Name of the Effect wxString mName; ///< Name of the Effect
wxString mAction; wxString mAction;
wxString mInfo; wxString mInfo;
bool mEnablePreview;
bool mDebug; bool mDebug;
std::string mDebugOutput; std::string mDebugOutput;
@ -196,6 +197,8 @@ class AUDACITY_DLL_API EffectNyquist:public Effect
WaveTrack *mOutputTrack[2]; WaveTrack *mOutputTrack[2];
wxArrayString mCategories; wxArrayString mCategories;
friend class NyquistDialog;
}; };
class NyquistDialog:public wxDialog class NyquistDialog:public wxDialog
@ -205,17 +208,20 @@ class NyquistDialog:public wxDialog
NyquistDialog(wxWindow * parent, wxWindowID id, NyquistDialog(wxWindow * parent, wxWindowID id,
const wxString & title, const wxString & title,
wxString info, wxString info,
NyqControlArray *controlArray); bool preview,
EffectNyquist *effect);
private: private:
EffectNyquist *mEffect;
NyqControlArray *mControls; NyqControlArray *mControls;
bool mInHandler; bool mInHandler;
void OnText(wxCommandEvent & event); void OnText(wxCommandEvent & event);
void OnSlider(wxCommandEvent & event); void OnSlider(wxCommandEvent & event);
void OnChoice( wxCommandEvent &event ); void OnChoice( wxCommandEvent &event );
void OnOk(wxCommandEvent & event); void OnPreview(wxCommandEvent & event);
void OnDebug(wxCommandEvent & event); void OnDebug(wxCommandEvent & event);
void OnOk(wxCommandEvent & event);
void OnCancel(wxCommandEvent & event); void OnCancel(wxCommandEvent & event);
private: private:
@ -237,8 +243,9 @@ class NyquistInputDialog:public wxDialog
wxTextCtrl *mCommandText; wxTextCtrl *mCommandText;
void OnOk(wxCommandEvent & event); void OnOk(wxCommandEvent & event);
void OnDebug(wxCommandEvent & event);
void OnCancel(wxCommandEvent & event); void OnCancel(wxCommandEvent & event);
void OnDebug(wxCommandEvent & event);
void OnPreview(wxCommandEvent & event);
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()