mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Bring back the Nyquist debug button
This commit is contained in:
parent
f8b9cd69e2
commit
e8b0ca8707
@ -1354,6 +1354,7 @@ void NyqBench::OnLargeIcons(wxCommandEvent & e)
|
||||
void NyqBench::OnGo(wxCommandEvent & e)
|
||||
{
|
||||
mEffect->SetCommand(mScript->GetValue());
|
||||
mEffect->RedirectOutput();
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
wxASSERT(p != NULL);
|
||||
|
@ -2213,13 +2213,6 @@ wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra)
|
||||
bs->Add( 20, 0 );
|
||||
}
|
||||
|
||||
if( buttons & eDebugButton )
|
||||
{
|
||||
b = new wxButton( parent, eDebugID, _("Debu&g") );
|
||||
bs->Add( b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
|
||||
bs->Add( 40, 0 );
|
||||
}
|
||||
|
||||
if( extra )
|
||||
{
|
||||
bs->Add( extra, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
|
||||
@ -2228,6 +2221,24 @@ wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra)
|
||||
|
||||
bs->AddStretchSpacer();
|
||||
bs->Realize();
|
||||
|
||||
// Add any buttons that need to cuddle up to the right hand cluster
|
||||
if( buttons & eDebugButton )
|
||||
{
|
||||
size_t lastSpacer = 0;
|
||||
wxSizerItemList & list = bs->GetChildren();
|
||||
for ( size_t i = 0, cnt = list.GetCount(); i < cnt; i++ )
|
||||
{
|
||||
if ( list[i]->IsSpacer() )
|
||||
{
|
||||
lastSpacer = i;
|
||||
}
|
||||
}
|
||||
|
||||
b = new wxButton( parent, eDebugID, _("Debu&g") );
|
||||
bs->Insert( lastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
|
||||
}
|
||||
|
||||
wxSizer * s;
|
||||
s = new wxBoxSizer( wxVERTICAL );
|
||||
s->Add( bs, 1, wxEXPAND | wxALL, 7 );
|
||||
|
@ -106,6 +106,8 @@ Effect::Effect()
|
||||
mBlockSize = 0;
|
||||
mNumChannels = 0;
|
||||
|
||||
mUIDebug = false;
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
mProjectRate = p ? p->GetRate() : 44100;
|
||||
}
|
||||
@ -1781,6 +1783,11 @@ bool Effect::EnablePreview(bool enable)
|
||||
return enable;
|
||||
}
|
||||
|
||||
void Effect::EnableDebug(bool enable)
|
||||
{
|
||||
mUIDebug = enable;
|
||||
}
|
||||
|
||||
bool Effect::TotalProgress(double frac)
|
||||
{
|
||||
int updateResult = (mProgress ?
|
||||
@ -2492,6 +2499,7 @@ BEGIN_EVENT_TABLE(EffectUIHost, wxDialog)
|
||||
EVT_CLOSE(EffectUIHost::OnClose)
|
||||
EVT_BUTTON(wxID_APPLY, EffectUIHost::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, EffectUIHost::OnCancel)
|
||||
EVT_BUTTON(eDebugID, EffectUIHost::OnDebug)
|
||||
EVT_BUTTON(kMenuID, EffectUIHost::OnMenu)
|
||||
EVT_CHECKBOX(kEnableID, EffectUIHost::OnEnable)
|
||||
EVT_BUTTON(kPlayID, EffectUIHost::OnPlay)
|
||||
@ -2756,7 +2764,7 @@ bool EffectUIHost::Initialize()
|
||||
|
||||
bar->SetSizerAndFit(bs);
|
||||
|
||||
wxSizer *s = CreateStdButtonSizer(this, eApplyButton | eCloseButton, bar);
|
||||
wxSizer *s = CreateStdButtonSizer(this, eApplyButton | eCloseButton | (mEffect->mUIDebug ? eDebugButton : 0), bar);
|
||||
vs->Add(s, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
SetSizer(vs);
|
||||
@ -2807,7 +2815,7 @@ void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt))
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void EffectUIHost::OnApply(wxCommandEvent & WXUNUSED(evt))
|
||||
void EffectUIHost::OnApply(wxCommandEvent & evt)
|
||||
{
|
||||
// On wxGTK (wx2.8.12), the default action is still executed even if
|
||||
// the button is disabled. This appears to affect all wxDialogs, not
|
||||
@ -2836,6 +2844,8 @@ void EffectUIHost::OnApply(wxCommandEvent & WXUNUSED(evt))
|
||||
return;
|
||||
}
|
||||
|
||||
mEffect->mUIResultID = evt.GetId();
|
||||
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(true);
|
||||
@ -2850,8 +2860,10 @@ void EffectUIHost::OnApply(wxCommandEvent & WXUNUSED(evt))
|
||||
return;
|
||||
}
|
||||
|
||||
void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
|
||||
void EffectUIHost::OnCancel(wxCommandEvent & evt)
|
||||
{
|
||||
mEffect->mUIResultID = evt.GetId();
|
||||
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(false);
|
||||
@ -2868,6 +2880,15 @@ void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
|
||||
return;
|
||||
}
|
||||
|
||||
void EffectUIHost::OnDebug(wxCommandEvent & evt)
|
||||
{
|
||||
OnApply(evt);
|
||||
|
||||
mEffect->mUIResultID = evt.GetId();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
wxMenu *menu = new wxMenu();
|
||||
|
@ -277,6 +277,7 @@ protected:
|
||||
virtual bool TransferDataFromWindow();
|
||||
virtual bool EnableApply(bool enable = true);
|
||||
virtual bool EnablePreview(bool enable = true);
|
||||
virtual void EnableDebug(bool enable = true);
|
||||
|
||||
// The Progress methods all return true if the user has cancelled;
|
||||
// you should exit immediately if this happens (cleaning up memory
|
||||
@ -343,11 +344,12 @@ protected:
|
||||
// UI
|
||||
wxDialog *mUIDialog;
|
||||
wxWindow *mUIParent;
|
||||
int mUIResultID;
|
||||
|
||||
sampleCount mSampleCnt;
|
||||
sampleCount mSampleCnt;
|
||||
|
||||
// type of the tracks on mOutputTracks
|
||||
int mOutputTracksType;
|
||||
int mOutputTracksType;
|
||||
|
||||
// Used only by the base Effect class
|
||||
//
|
||||
@ -374,6 +376,8 @@ private:
|
||||
|
||||
double mDuration;
|
||||
|
||||
bool mUIDebug;
|
||||
|
||||
wxArrayPtrVoid mIMap;
|
||||
wxArrayPtrVoid mOMap;
|
||||
|
||||
@ -469,6 +473,7 @@ private:
|
||||
void OnClose(wxCloseEvent & evt);
|
||||
void OnApply(wxCommandEvent & evt);
|
||||
void OnCancel(wxCommandEvent & evt);
|
||||
void OnDebug(wxCommandEvent & evt);
|
||||
void OnMenu(wxCommandEvent & evt);
|
||||
void OnEnable(wxCommandEvent & evt);
|
||||
void OnPlay(wxCommandEvent & evt);
|
||||
|
@ -71,7 +71,6 @@ enum
|
||||
ID_Version,
|
||||
ID_Load,
|
||||
ID_Save,
|
||||
ID_Debug,
|
||||
|
||||
ID_Slider = 11000,
|
||||
ID_Text = 12000,
|
||||
@ -95,7 +94,6 @@ WX_DEFINE_OBJARRAY(NyqControlArray);
|
||||
BEGIN_EVENT_TABLE(NyquistEffect, wxEvtHandler)
|
||||
EVT_BUTTON(ID_Load, NyquistEffect::OnLoad)
|
||||
EVT_BUTTON(ID_Save, NyquistEffect::OnSave)
|
||||
EVT_BUTTON(ID_Debug, NyquistEffect::OnDebug)
|
||||
|
||||
EVT_COMMAND_RANGE(ID_Slider, ID_Slider+99,
|
||||
wxEVT_COMMAND_SLIDER_UPDATED, NyquistEffect::OnSlider)
|
||||
@ -113,6 +111,7 @@ NyquistEffect::NyquistEffect(wxString fName)
|
||||
mIsPrompt = false;
|
||||
mExternal = false;
|
||||
mCompiler = false;
|
||||
mRedirectOutput = false;
|
||||
mDebug = false;
|
||||
mIsSal = false;
|
||||
mOK = false;
|
||||
@ -391,8 +390,7 @@ bool NyquistEffect::Process()
|
||||
|
||||
mTrackIndex = 0;
|
||||
|
||||
mDebugOutput = new std::string();
|
||||
mOutput.Clear();
|
||||
mDebugOutput.Clear();
|
||||
|
||||
if (mVersion >= 4)
|
||||
{
|
||||
@ -611,12 +609,19 @@ bool NyquistEffect::Process()
|
||||
|
||||
finish:
|
||||
|
||||
if (mDebug && !mRedirectOutput) {
|
||||
NyquistOutputDialog dlog(mUIParent, -1,
|
||||
_("Nyquist"),
|
||||
_("Nyquist Output: "),
|
||||
mDebugOutput.c_str());
|
||||
dlog.CentreOnParent();
|
||||
dlog.ShowModal();
|
||||
}
|
||||
|
||||
ReplaceProcessedTracks(success);
|
||||
|
||||
mDebug = false;
|
||||
|
||||
delete mDebugOutput;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -625,6 +630,9 @@ bool NyquistEffect::ShowInterface(wxWindow *parent, bool forceModal)
|
||||
// Show the normal (prompt or effect) interface
|
||||
bool res = Effect::ShowInterface(parent, forceModal);
|
||||
|
||||
// Remember if the user clicked debug
|
||||
mDebug = (mUIResultID == eDebugID);
|
||||
|
||||
// We're done if the user clicked "Close", we are not the Nyquist Prompt,
|
||||
// or the program currently loaded into the prompt doesn't have a UI.
|
||||
if (!res || !mIsPrompt || mControls.GetCount() == 0)
|
||||
@ -635,7 +643,7 @@ bool NyquistEffect::ShowInterface(wxWindow *parent, bool forceModal)
|
||||
NyquistEffect effect(NYQUIST_WORKER_ID);
|
||||
|
||||
effect.SetCommand(mInputCmd);
|
||||
effect.mDebug = false;
|
||||
effect.mDebug = (mUIResultID == eDebugID);
|
||||
|
||||
SelectedRegion region(mT0, mT1);
|
||||
effect.DoEffect(parent,
|
||||
@ -658,6 +666,8 @@ void NyquistEffect::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
BuildEffectWindow(S);
|
||||
}
|
||||
|
||||
EnableDebug();
|
||||
}
|
||||
|
||||
bool NyquistEffect::TransferDataToWindow()
|
||||
@ -908,7 +918,6 @@ bool NyquistEffect::ProcessOne()
|
||||
mCurBuffer[i] = NULL;
|
||||
}
|
||||
|
||||
wxLogMessage(wxT("%s"), cmd.c_str());
|
||||
rval = nyx_eval_expression(cmd.mb_str(wxConvUTF8));
|
||||
|
||||
if (!rval) {
|
||||
@ -1576,12 +1585,11 @@ void NyquistEffect::StaticOutputCallback(int c, void *This)
|
||||
|
||||
void NyquistEffect::OutputCallback(int c)
|
||||
{
|
||||
if (mDebug && !mExternal) {
|
||||
mOutput += c;
|
||||
if (mDebug && !mRedirectOutput) {
|
||||
mDebugOutput += (char)c;
|
||||
return;
|
||||
}
|
||||
// mOutput += wxString::FromUTF8((char *) &c, 1);
|
||||
mOutput += c;
|
||||
|
||||
std::cout << (char)c;
|
||||
}
|
||||
|
||||
@ -1785,8 +1793,6 @@ void NyquistEffect::BuildPromptWindow(ShuttleGui & S)
|
||||
{
|
||||
S.Id(ID_Load).AddButton(_("&Load"));
|
||||
S.Id(ID_Save).AddButton(_("&Save"));
|
||||
S.AddSpace(10, 1);
|
||||
S.Id(ID_Debug).AddButton(_("&Debug"));
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
@ -1944,36 +1950,6 @@ void NyquistEffect::OnSave(wxCommandEvent & WXUNUSED(evt))
|
||||
}
|
||||
}
|
||||
|
||||
void NyquistEffect::OnDebug(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
TransferDataFromPromptWindow();
|
||||
|
||||
NyquistEffect effect(NYQUIST_WORKER_ID);
|
||||
|
||||
effect.SetCommand(mInputCmd);
|
||||
effect.mDebug = true;
|
||||
|
||||
SelectedRegion region(mT0, mT1);
|
||||
effect.DoEffect(mUIParent,
|
||||
mProjectRate,
|
||||
mTracks,
|
||||
mFactory,
|
||||
®ion,
|
||||
true);
|
||||
|
||||
NyquistOutputDialog dlog(mUIParent,
|
||||
wxID_ANY,
|
||||
_("Nyquist"),
|
||||
_("Nyquist Output: "),
|
||||
effect.mOutput);
|
||||
dlog.CentreOnParent();
|
||||
dlog.ShowModal();
|
||||
|
||||
SaveUserPreset(GetCurrentSettingsGroup());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void NyquistEffect::OnSlider(wxCommandEvent & evt)
|
||||
{
|
||||
int i = evt.GetId() - ID_Slider;
|
||||
|
@ -27,8 +27,6 @@
|
||||
|
||||
#include "nyx.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#define NYQUISTEFFECTS_VERSION wxT("1.0.0.0")
|
||||
#define NYQUISTEFFECTS_FAMILY wxT("Nyquist")
|
||||
|
||||
@ -103,6 +101,7 @@ public:
|
||||
// NyquistEffect implementation
|
||||
|
||||
// For Nyquist Workbench support
|
||||
void RedirectOutput();
|
||||
void SetCommand(wxString cmd);
|
||||
void Continue();
|
||||
void Break();
|
||||
@ -193,8 +192,8 @@ private:
|
||||
|
||||
bool mEnablePreview;
|
||||
bool mDebug;
|
||||
std::string *mDebugOutput;
|
||||
wxString mOutput;
|
||||
bool mRedirectOutput;
|
||||
wxString mDebugOutput;
|
||||
|
||||
int mVersion;
|
||||
NyqControlArray mControls;
|
||||
|
Loading…
x
Reference in New Issue
Block a user