Audacity 3.2.0
Macros | Enumerations | Functions | Variables
Nyquist.cpp File Reference
#include "Nyquist.h"
#include <algorithm>
#include <cmath>
#include <cstring>
#include <locale.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/datetime.h>
#include <wx/log.h>
#include <wx/scrolwin.h>
#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/sstream.h>
#include <wx/stattext.h>
#include <wx/textdlg.h>
#include <wx/tokenzr.h>
#include <wx/txtstrm.h>
#include <wx/valgen.h>
#include <wx/wfstream.h>
#include <wx/numformatter.h>
#include <wx/stdpaths.h>
#include "BasicUI.h"
#include "../EffectEditor.h"
#include "../EffectManager.h"
#include "FileNames.h"
#include "../../LabelTrack.h"
#include "Languages.h"
#include "../../NoteTrack.h"
#include "TimeTrack.h"
#include "../../prefs/SpectrogramSettings.h"
#include "PluginManager.h"
#include "Project.h"
#include "ProjectRate.h"
#include "ShuttleAutomation.h"
#include "../../ShuttleGetDefinition.h"
#include "ShuttleGui.h"
#include "TempDirectory.h"
#include "SyncLock.h"
#include "ViewInfo.h"
#include "WaveClip.h"
#include "WaveTrack.h"
#include "../../widgets/valnum.h"
#include "AudacityMessageBox.h"
#include "Prefs.h"
#include "wxFileNameWrapper.h"
#include "../../prefs/GUIPrefs.h"
#include "../../tracks/playabletrack/wavetrack/ui/WaveTrackView.h"
#include "../../tracks/playabletrack/wavetrack/ui/WaveTrackViewConstants.h"
#include "../../widgets/NumericTextCtrl.h"
#include "ProgressDialog.h"
#include "FileDialog/FileDialog.h"
#include <iostream>
#include <ostream>
#include <sstream>
#include <float.h>
#include "../../../lib-src/libnyquist/nyquist/xlisp/xlisp.h"
#include "../../commands/ScriptCommandRelay.h"

Go to the source code of this file.

Macros

#define NYQUIST_WORKER_ID   wxT("Nyquist Worker")
 
#define NYQ_MAX_LEN   (std::numeric_limits<long>::max())
 
#define UNINITIALIZED_CONTROL   ((double)99999999.99)
 

Enumerations

enum  {
  ID_Editor = 10000 , ID_Load , ID_Save , ID_Slider = 11000 ,
  ID_Choice = 13000 , ID_FILE = 15000
}
 

Functions

 EVT_COMMAND_RANGE (ID_Slider, ID_Slider+99, wxEVT_COMMAND_SLIDER_UPDATED, NyquistEffect::OnSlider) EVT_COMMAND_RANGE(ID_Text
 
NyquistEffect::OnText EVT_COMMAND_RANGE (ID_Choice, ID_Choice+99, wxEVT_COMMAND_CHOICE_SELECTED, NyquistEffect::OnChoice) EVT_COMMAND_RANGE(ID_Time
 
NyquistEffect::OnText NyquistEffect::OnTime EVT_COMMAND_RANGE (ID_FILE, ID_FILE+99, wxEVT_COMMAND_BUTTON_CLICKED, NyquistEffect::OnFileButton) NyquistEffect
 
static void RegisterFunctions ()
 
static LVAL gettext ()
 
static LVAL gettextc ()
 
static LVAL ngettext ()
 
static LVAL ngettextc ()
 
void * nyq_make_opaque_string (int size, unsigned char *src)
 
void * nyq_reformat_aud_do_response (const wxString &Str)
 
LVAL xlc_aud_do (void)
 

Variables

static const wxChar * KEY_Command = wxT("Command")
 
static const wxChar * KEY_Parameters = wxT("Parameters")
 
 ID_Text = 12000
 
 wxEVT_COMMAND_TEXT_UPDATED
 
NyquistEffect::OnText ID_Time = 14000
 
static const FileNames::FileType NyquistScripts = { XO("Nyquist scripts"), { wxT("ny") }, true }
 
static const FileNames::FileType LispScripts = { XO("Lisp scripts"), { wxT("lsp") }, true }
 

Macro Definition Documentation

◆ NYQ_MAX_LEN

#define NYQ_MAX_LEN   (std::numeric_limits<long>::max())

Definition at line 113 of file Nyquist.cpp.

◆ NYQUIST_WORKER_ID

#define NYQUIST_WORKER_ID   wxT("Nyquist Worker")

Definition at line 95 of file Nyquist.cpp.

◆ UNINITIALIZED_CONTROL

#define UNINITIALIZED_CONTROL   ((double)99999999.99)

Definition at line 115 of file Nyquist.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ID_Editor 
ID_Load 
ID_Save 
ID_Slider 
ID_Choice 
ID_FILE 

Definition at line 99 of file Nyquist.cpp.

100{
101 ID_Editor = 10000,
102 ID_Load,
103 ID_Save,
104
105 ID_Slider = 11000,
106 ID_Text = 12000,
107 ID_Choice = 13000,
108 ID_Time = 14000,
109 ID_FILE = 15000
110};
@ ID_Editor
Definition: Nyquist.cpp:101
@ ID_Load
Definition: Nyquist.cpp:102
@ ID_FILE
Definition: Nyquist.cpp:109
@ ID_Choice
Definition: Nyquist.cpp:107
@ ID_Slider
Definition: Nyquist.cpp:105
@ ID_Save
Definition: Nyquist.cpp:103
ID_Text
Definition: Nyquist.cpp:132
NyquistEffect::OnText ID_Time
Definition: Nyquist.cpp:136

Function Documentation

◆ EVT_COMMAND_RANGE() [1/3]

NyquistEffect::OnText EVT_COMMAND_RANGE ( ID_Choice  ,
ID_Choice 99,
wxEVT_COMMAND_CHOICE_SELECTED  ,
NyquistEffect::OnChoice   
)

◆ EVT_COMMAND_RANGE() [2/3]

Definition at line 138 of file Nyquist.cpp.

143 : mIsPrompt{ fName == NYQUIST_PROMPT_ID }
144{
145 mOutputTrack[0] = mOutputTrack[1] = nullptr;
146
147 mAction = XO("Applying Nyquist Effect...");
148 mExternal = false;
149 mCompiler = false;
150 mTrace = false;
151 mRedirectOutput = false;
152 mDebug = false;
153 mIsSal = false;
154 mOK = false;
155 mAuthor = XO("n/a");
156 mReleaseVersion = XO("n/a");
157 mCopyright = XO("n/a");
158
159 // set clip/split handling when applying over clip boundary.
160 mRestoreSplits = true; // Default: Restore split lines.
161 mMergeClips = -1; // Default (auto): Merge if length remains unchanged.
162
163 mVersion = 4;
164
165 mStop = false;
166 mBreak = false;
167 mCont = false;
168 mIsTool = false;
169
170 mMaxLen = NYQ_MAX_LEN;
171
172 // Interactive Nyquist
173 if (mIsPrompt) {
174 mName = NYQUIST_PROMPT_NAME;
175 mType = EffectTypeTool;
176 mIsTool = true;
177 mPromptName = mName;
178 mPromptType = mType;
179 mOK = true;
180 return;
181 }
182
183 if (fName == NYQUIST_WORKER_ID) {
184 // Effect spawned from Nyquist Prompt
185/* i18n-hint: It is acceptable to translate this the same as for "Nyquist Prompt" */
186 mName = XO("Nyquist Worker");
187 return;
188 }
189
190 mFileName = fName;
191 // Use the file name verbatim as effect name.
192 // This is only a default name, overridden if we find a $name line:
193 mName = Verbatim( mFileName.GetName() );
194 mFileModified = mFileName.GetModificationTime();
195 ParseFile();
196
197 if (!mOK && mInitError.empty())
198 mInitError = XO("Ill-formed Nyquist plug-in header");
199}
@ EffectTypeTool
XO("Cut/Copy/Paste")
#define NYQUIST_WORKER_ID
Definition: Nyquist.cpp:95
#define NYQ_MAX_LEN
Definition: Nyquist.cpp:113
#define NYQUIST_PROMPT_ID
#define NYQUIST_PROMPT_NAME
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References NYQUIST_PROMPT_ID.

◆ EVT_COMMAND_RANGE() [3/3]

EVT_COMMAND_RANGE ( ID_Slider  ,
ID_Slider 99,
wxEVT_COMMAND_SLIDER_UPDATED  ,
NyquistEffect::OnSlider   
)

◆ gettext()

static LVAL gettext ( )
static

Definition at line 3472 of file Nyquist.cpp.

3473{
3474 auto string = UTF8CTOWX(getstring(xlgastring()));
3475#if !HAS_I18N_CONTEXTS
3476 // allow ignored context argument
3477 if ( moreargs() )
3478 nextarg();
3479#endif
3480 xllastarg();
3481 return cvstring(GetCustomTranslation(string).mb_str(wxConvUTF8));
3482}
STRINGS_API const wxString & GetCustomTranslation(const wxString &str1)
Definition: Internat.cpp:70
#define UTF8CTOWX(X)
Definition: Internat.h:157

References GetCustomTranslation(), and UTF8CTOWX.

Referenced by gettextc(), and RegisterFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gettextc()

static LVAL gettextc ( )
static

Definition at line 3484 of file Nyquist.cpp.

3485{
3486#if HAS_I18N_CONTEXTS
3487 auto string = UTF8CTOWX(getstring(xlgastring()));
3488 auto context = UTF8CTOWX(getstring(xlgastring()));
3489 xllastarg();
3490 return cvstring(wxGetTranslation( string, "", 0, "", context )
3491 .mb_str(wxConvUTF8));
3492#else
3493 return gettext();
3494#endif
3495}
static LVAL gettext()
Definition: Nyquist.cpp:3472

References gettext(), and UTF8CTOWX.

Referenced by RegisterFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ngettext()

static LVAL ngettext ( )
static

Definition at line 3497 of file Nyquist.cpp.

3498{
3499 auto string1 = UTF8CTOWX(getstring(xlgastring()));
3500 auto string2 = UTF8CTOWX(getstring(xlgastring()));
3501 auto number = getfixnum(xlgafixnum());
3502#if !HAS_I18N_CONTEXTS
3503 // allow ignored context argument
3504 if ( moreargs() )
3505 nextarg();
3506#endif
3507 xllastarg();
3508 return cvstring(
3509 wxGetTranslation(string1, string2, number).mb_str(wxConvUTF8));
3510}

References UTF8CTOWX.

Referenced by ngettextc(), and RegisterFunctions().

Here is the caller graph for this function:

◆ ngettextc()

static LVAL ngettextc ( )
static

Definition at line 3512 of file Nyquist.cpp.

3513{
3514#if HAS_I18N_CONTEXTS
3515 auto string1 = UTF8CTOWX(getstring(xlgastring()));
3516 auto string2 = UTF8CTOWX(getstring(xlgastring()));
3517 auto number = getfixnum(xlgafixnum());
3518 auto context = UTF8CTOWX(getstring(xlgastring()));
3519 xllastarg();
3520 return cvstring(wxGetTranslation( string1, string2, number, "", context )
3521 .mb_str(wxConvUTF8));
3522#else
3523 return ngettext();
3524#endif
3525}
static LVAL ngettext()
Definition: Nyquist.cpp:3497

References ngettext(), and UTF8CTOWX.

Referenced by RegisterFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nyq_make_opaque_string()

void * nyq_make_opaque_string ( int  size,
unsigned char *  src 
)

Definition at line 3527 of file Nyquist.cpp.

3527 {
3528 LVAL dst;
3529 unsigned char * dstp;
3530 dst = new_string((int)(size+2));
3531 dstp = getstring(dst);
3532
3533 /* copy the source to the destination */
3534 while (size-- > 0)
3535 *dstp++ = *src++;
3536 *dstp = '\0';
3537
3538 return (void*)dst;
3539}

References size.

◆ nyq_reformat_aud_do_response()

void * nyq_reformat_aud_do_response ( const wxString &  Str)

Definition at line 3541 of file Nyquist.cpp.

3541 {
3542 LVAL dst;
3543 LVAL message;
3544 LVAL success;
3545 wxString Left = Str.BeforeLast('\n').BeforeLast('\n').ToAscii();
3546 wxString Right = Str.BeforeLast('\n').AfterLast('\n').ToAscii();
3547 message = cvstring(Left);
3548 success = Right.EndsWith("OK") ? s_true : nullptr;
3549 dst = cons(message, success);
3550 return (void *)dst;
3551}

Referenced by ExecForLisp().

Here is the caller graph for this function:

◆ RegisterFunctions()

static void RegisterFunctions ( )
static

Definition at line 3579 of file Nyquist.cpp.

3580{
3581 // Add functions to XLisp. Do this only once,
3582 // before the first call to nyx_init.
3583 static bool firstTime = true;
3584 if (firstTime) {
3585 firstTime = false;
3586
3587 // All function names must be UP-CASED
3588 static const FUNDEF functions[] = {
3589 { "_", SUBR, gettext },
3590 { "_C", SUBR, gettextc },
3591 { "NGETTEXT", SUBR, ngettext },
3592 { "NGETTEXTC", SUBR, ngettextc },
3593 { "AUD-DO", SUBR, xlc_aud_do },
3594 };
3595
3596 xlbindfunctions( functions, WXSIZEOF( functions ) );
3597 }
3598}
static LVAL gettextc()
Definition: Nyquist.cpp:3484
LVAL xlc_aud_do(void)
Definition: Nyquist.cpp:3558
static LVAL ngettextc()
Definition: Nyquist.cpp:3512

References gettext(), gettextc(), ngettext(), ngettextc(), and xlc_aud_do().

Referenced by NyquistEffect::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xlc_aud_do()

LVAL xlc_aud_do ( void  )

Definition at line 3558 of file Nyquist.cpp.

3559{
3560// Based on string-trim...
3561 unsigned char *leftp;
3562 LVAL src,dst;
3563
3564 /* get the string */
3565 src = xlgastring();
3566 xllastarg();
3567
3568 /* setup the string pointer */
3569 leftp = getstring(src);
3570
3571 // Go call my real function here...
3572 dst = (LVAL)ExecForLisp( (char *)leftp );
3573
3574 //dst = cons(dst, (LVAL)1);
3575 /* return the new string */
3576 return (dst);
3577}
void * ExecForLisp(char *pIn)

References ExecForLisp().

Referenced by RegisterFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ID_Text

ID_Text = 12000

◆ ID_Time

ID_Time = 14000

◆ KEY_Command

const wxChar* KEY_Command = wxT("Command")
static

◆ KEY_Parameters

const wxChar* KEY_Parameters = wxT("Parameters")
static

◆ LispScripts

const FileNames::FileType LispScripts = { XO("Lisp scripts"), { wxT("lsp") }, true }
static

Definition at line 3081 of file Nyquist.cpp.

◆ NyquistScripts

const FileNames::FileType NyquistScripts = { XO("Nyquist scripts"), { wxT("ny") }, true }
static

Definition at line 3079 of file Nyquist.cpp.

◆ wxEVT_COMMAND_TEXT_UPDATED

NyquistEffect::OnText wxEVT_COMMAND_TEXT_UPDATED

Definition at line 133 of file Nyquist.cpp.

Referenced by LadspaEffect::Editor::PopulateUI(), and NumericTextCtrl::Updated().