Audacity  2.2.0
Nyquist.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Nyquist.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_EFFECT_NYQUIST__
12 #define __AUDACITY_EFFECT_NYQUIST__
13 
14 #include <wx/button.h>
15 #include <wx/datetime.h>
16 #include <wx/dialog.h>
17 #include <wx/filename.h>
18 #include <wx/intl.h>
19 #include <wx/sizer.h>
20 #include <wx/slider.h>
21 #include <wx/stattext.h>
22 #include <wx/textbuf.h>
23 #include <wx/textctrl.h>
24 #include <wx/tokenzr.h>
25 
26 #include "../Effect.h"
27 
28 #include "nyx.h"
29 
30 #define NYQUISTEFFECTS_VERSION wxT("1.0.0.0")
31 #define NYQUISTEFFECTS_FAMILY wxT("Nyquist")
32 
33 #define NYQUIST_PROMPT_ID wxT("Nyquist Prompt")
34 #define NYQUIST_WORKER_ID wxT("Nyquist Worker")
35 
37 {
44 };
45 
47 {
48 public:
49  int type;
50  wxString var;
51  wxString name;
52  wxString label;
53  wxString valStr;
54  wxString lowStr;
55  wxString highStr;
56  double val;
57  double low;
58  double high;
59  int ticks;
60 };
61 
62 WX_DECLARE_USER_EXPORTED_OBJARRAY(NyqControl, NyqControlArray, AUDACITY_DLL_API);
63 
64 class AUDACITY_DLL_API NyquistEffect final : public Effect
65 {
66 public:
67 
71  NyquistEffect(const wxString &fName);
72  virtual ~NyquistEffect();
73 
74  // IdentInterface implementation
75 
76  wxString GetPath() override;
77  wxString GetSymbol() override;
78  wxString GetName() override;
79  wxString GetVendor() override;
80  wxString GetVersion() override;
81  wxString GetDescription() override;
82 
83  wxString ManualPage() override;
84  wxString HelpPage() override;
85 
86  // EffectIdentInterface implementation
87 
88  EffectType GetType() override;
89  wxString GetFamily() override;
90  bool IsInteractive() override;
91  bool IsDefault() override;
92 
93  // EffectClientInterface implementation
94 
95  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
96  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
97 
98  // Effect implementation
99 
100  bool Init() override;
101  bool CheckWhetherSkipEffect() override;
102  bool Process() override;
103  bool ShowInterface(wxWindow *parent, bool forceModal = false) override;
104  void PopulateOrExchange(ShuttleGui & S) override;
105  bool TransferDataToWindow() override;
106  bool TransferDataFromWindow() override;
107 
108  // NyquistEffect implementation
109 
110  // For Nyquist Workbench support
111  void RedirectOutput();
112  void SetCommand(const wxString &cmd);
113  void Continue();
114  void Break();
115  void Stop();
116 
117 private:
118  // NyquistEffect implementation
119 
120  bool ProcessOne();
121 
122  void BuildPromptWindow(ShuttleGui & S);
123  void BuildEffectWindow(ShuttleGui & S);
124 
125  bool TransferDataToPromptWindow();
126  bool TransferDataToEffectWindow();
127 
128  bool TransferDataFromPromptWindow();
129  bool TransferDataFromEffectWindow();
130 
131  bool IsOk();
132 
133  static wxArrayString GetNyquistSearchPath();
134 
135  static wxString NyquistToWxString(const char *nyqString);
136  wxString EscapeString(const wxString & inStr);
137  wxArrayString ParseChoice(const NyqControl & ctrl);
138 
139  static int StaticGetCallback(float *buffer, int channel,
140  long start, long len, long totlen,
141  void *userdata);
142  static int StaticPutCallback(float *buffer, int channel,
143  long start, long len, long totlen,
144  void *userdata);
145  static void StaticOutputCallback(int c, void *userdata);
146  static void StaticOSCallback(void *userdata);
147 
148  int GetCallback(float *buffer, int channel,
149  long start, long len, long totlen);
150  int PutCallback(float *buffer, int channel,
151  long start, long len, long totlen);
152  void OutputCallback(int c);
153  void OSCallback();
154 
155  void ParseFile();
156  bool ParseCommand(const wxString & cmd);
157  bool ParseProgram(wxInputStream & stream);
158  void Parse(const wxString &line);
159 
160  wxString UnQuote(const wxString &s);
161  double GetCtrlValue(const wxString &s);
162 
163  void OnLoad(wxCommandEvent & evt);
164  void OnSave(wxCommandEvent & evt);
165  void OnDebug(wxCommandEvent & evt);
166 
167  void OnText(wxCommandEvent & evt);
168  void OnSlider(wxCommandEvent & evt);
169  void OnChoice(wxCommandEvent & evt);
170 
171 private:
172 
173  wxString mXlispPath;
174 
175  wxFileName mFileName;
176  wxDateTime mFileModified;
177 
178  bool mStop;
179  bool mBreak;
180  bool mCont;
181 
183  bool mCompiler;
184  bool mTrace; // True when *tracenable* or *sal-traceback* are enabled
185  bool mIsSal;
186  bool mExternal;
192  bool mIsPrompt;
193  bool mOK;
194  wxString mInputCmd; // history: exactly what the user typed
195  wxString mCmd; // the command to be processed
196  wxString mName;
197  wxString mAction;
198  wxString mInfo;
199  wxString mAuthor;
200  wxString mCopyright;
201  wxString mManPage; // ONLY use if a help page exists in the manual.
202  wxString mHelpFile;
204  EffectType mType;
205 
207  bool mDebugButton; // Set to false to disable Debug button.
208 
209  bool mDebug; // When true, debug window is shown.
212  wxString mDebugOutput;
213 
214  int mVersion;
215  NyqControlArray mControls;
216 
217  unsigned mCurNumChannels;
218  WaveTrack *mCurTrack[2];
219  sampleCount mCurStart[2];
220  sampleCount mCurLen;
221  sampleCount mMaxLen;
224  double mOutputTime;
225  unsigned mCount;
227  double mProgressIn;
228  double mProgressOut;
229  double mProgressTot;
230  double mScale;
231 
232  SampleBuffer mCurBuffer[2];
233  sampleCount mCurBufferStart[2];
234  size_t mCurBufferLen[2];
235 
236  WaveTrack *mOutputTrack[2];
237 
238  wxArrayString mCategories;
239 
240  wxString mProps;
241  wxString mPerTrackProps;
242 
245 
246  wxTextCtrl *mCommandText;
247  wxCheckBox *mVersionCheckBox;
248 
249  bool mError{ false };
250  wxFileName mFailedFileName;
251 
252  DECLARE_EVENT_TABLE()
253 
254  friend class NyquistEffectsModule;
255 };
256 
258 {
259 public:
260  NyquistOutputDialog(wxWindow * parent, wxWindowID id,
261  const wxString & title,
262  const wxString & prompt,
263  const wxString &message);
264 
265 private:
266  void OnOk(wxCommandEvent & event);
267 
268 private:
269  DECLARE_EVENT_TABLE()
270 };
271 
272 
273 #endif
wxString highStr
Definition: Nyquist.h:55
wxString mDebugOutput
Definition: Nyquist.h:212
bool mTrace
Definition: Nyquist.h:184
sampleCount mCurLen
Definition: Nyquist.h:220
double mProgressIn
Definition: Nyquist.h:227
bool mStop
Definition: Nyquist.h:178
wxString GetSymbol() override
Definition: Effect.cpp:163
wxString mName
Name of the Effect (untranslated)
Definition: Nyquist.h:196
wxString mXlispPath
Definition: Nyquist.h:173
NyqControlType
Definition: Nyquist.h:36
virtual bool TransferDataFromWindow()
Definition: Effect.cpp:1858
bool mIsSal
Definition: Nyquist.h:185
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: Effect.cpp:567
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:369
bool mProjectChanged
Definition: Nyquist.h:211
wxString mHelpFile
Definition: Nyquist.h:202
wxFileName mFailedFileName
Definition: Nyquist.h:250
unsigned mNumSelectedChannels
Definition: Nyquist.h:226
int type
Definition: Nyquist.h:49
virtual bool Init()
Definition: Effect.cpp:1245
virtual bool TransferDataToWindow()
Definition: Effect.cpp:1853
wxString mManPage
Definition: Nyquist.h:201
wxTextCtrl * mCommandText
Definition: Nyquist.h:246
wxString GetFamily() override
Definition: Effect.cpp:213
Definition: Nyquist.h:39
double mProgressOut
Definition: Nyquist.h:228
virtual wxString ManualPage()
Definition: Effect.cpp:1110
A control on a NyquistDialog.
Definition: Nyquist.h:46
bool mExternal
Definition: Nyquist.h:186
wxString GetName() override
Definition: Effect.cpp:173
wxString valStr
Definition: Nyquist.h:53
bool mHelpFileExists
Definition: Nyquist.h:203
NyqControlArray mControls
Definition: Nyquist.h:215
Base class for many of the effects in Audacity.
Definition: Effect.h:62
An Effect that calls up a Nyquist (XLISP) plug-in, i.e. many possible effects from this one class...
Definition: Nyquist.h:64
EffectType mType
Definition: Nyquist.h:204
virtual bool Process()
Definition: Effect.cpp:1271
Definition: Nyquist.h:42
wxString lowStr
Definition: Nyquist.h:54
wxString label
Definition: Nyquist.h:52
Definition: wxPanelWrapper.h:19
wxString GetDescription() override
Definition: Effect.cpp:203
wxString var
Definition: Nyquist.h:50
bool mDebugButton
Definition: Nyquist.h:207
bool mBreak
Definition: Nyquist.h:179
double mOutputTime
Definition: Nyquist.h:224
EffectType GetType() override
Definition: Effect.cpp:143
int mVersion
Definition: Nyquist.h:214
wxString GetVersion() override
Definition: Effect.cpp:193
unsigned mCount
Definition: Nyquist.h:225
bool mFoundType
Definition: Nyquist.h:182
double low
Definition: Nyquist.h:57
Definition: SampleFormat.h:52
wxDateTime mFileModified
When the script was last modified on disk.
Definition: Nyquist.h:176
double mScale
Definition: Nyquist.h:230
bool mFirstInGroup
Definition: Nyquist.h:223
WX_DECLARE_USER_EXPORTED_OBJARRAY(NyqControl, NyqControlArray, AUDACITY_DLL_API)
A Track that contains audio waveform data.
Definition: WaveTrack.h:76
wxString GetVendor() override
Definition: Effect.cpp:183
bool mCompiler
Definition: Nyquist.h:183
wxString name
Definition: Nyquist.h:51
bool mIsSpectral
Definition: Nyquist.h:187
wxCheckBox * mVersionCheckBox
Definition: Nyquist.h:247
Definition: Nyquist.h:40
wxString mCmd
Definition: Nyquist.h:195
Definition: Nyquist.h:43
wxString mAction
Definition: Nyquist.h:197
Dialog used with NyquistEffect.
Definition: Nyquist.h:257
bool IsInteractive() override
Definition: Effect.cpp:223
bool mRestoreSplits
Definition: Nyquist.h:243
Definition: Nyquist.h:41
bool mCont
Definition: Nyquist.h:180
Definition: LoadNyquist.h:21
wxString mCopyright
Definition: Nyquist.h:200
bool mRedirectOutput
Definition: Nyquist.h:210
double val
Definition: Nyquist.h:56
bool IsDefault() override
Definition: Effect.cpp:233
bool mOK
Definition: Nyquist.h:193
wxString mProps
Definition: Nyquist.h:240
unsigned mCurNumChannels
Definition: Nyquist.h:217
wxFileName mFileName
Name of the Nyquist script file this effect is loaded from.
Definition: Nyquist.h:175
wxString mInputCmd
Definition: Nyquist.h:194
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: Effect.cpp:577
bool mIsPrompt
Definition: Nyquist.h:192
bool ShowInterface(wxWindow *parent, bool forceModal=false) override
Definition: Effect.cpp:517
bool mEnablePreview
Definition: Nyquist.h:206
void OnSave()
int mTrackIndex
Definition: Nyquist.h:222
wxString mPerTrackProps
Definition: Nyquist.h:241
bool mDebug
Definition: Nyquist.h:209
double high
Definition: Nyquist.h:58
int mMergeClips
Definition: Nyquist.h:244
double mProgressTot
Definition: Nyquist.h:229
virtual void PopulateOrExchange(ShuttleGui &S)
Definition: Effect.cpp:1848
wxString mInfo
Definition: Nyquist.h:198
virtual bool CheckWhetherSkipEffect()
Definition: Effect.h:297
Definition: Nyquist.h:38
int ticks
Definition: Nyquist.h:59
sampleCount mMaxLen
Definition: Nyquist.h:221
wxString GetPath() override
Definition: Effect.cpp:153
wxArrayString mCategories
Definition: Nyquist.h:238
wxString mAuthor
Definition: Nyquist.h:199
virtual wxString HelpPage()
Definition: Effect.cpp:1115