Audacity 3.2.0
Classes | Namespaces | Macros | Enumerations | Functions | Variables
Nyquist.cpp File Reference
#include "Nyquist.h"
#include "EffectOutputTracks.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 "../../LabelTrack.h"
#include "NoteTrack.h"
#include "../../ShuttleGetDefinition.h"
#include "../../prefs/GUIPrefs.h"
#include "../../prefs/SpectrogramSettings.h"
#include "../../tracks/playabletrack/wavetrack/ui/WaveChannelView.h"
#include "../../tracks/playabletrack/wavetrack/ui/WaveChannelViewConstants.h"
#include "../../widgets/NumericTextCtrl.h"
#include "../../widgets/valnum.h"
#include "../EffectEditor.h"
#include "../EffectManager.h"
#include "AudacityMessageBox.h"
#include "BasicUI.h"
#include "FileNames.h"
#include "Languages.h"
#include "PluginManager.h"
#include "Prefs.h"
#include "ProgressDialog.h"
#include "Project.h"
#include "ProjectRate.h"
#include "ShuttleAutomation.h"
#include "ShuttleGui.h"
#include "SyncLock.h"
#include "TempDirectory.h"
#include "TimeTrack.h"
#include "TimeWarper.h"
#include "ViewInfo.h"
#include "WaveChannelUtilities.h"
#include "WaveClip.h"
#include "WaveTrack.h"
#include "wxFileNameWrapper.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.

Classes

struct  NyquistEffect::NyxContext
 

Namespaces

namespace  anonymous_namespace{Nyquist.cpp}
 

Macros

#define NYQUIST_WORKER_ID   wxT("Nyquist Worker")
 
#define NYQ_MAX_LEN   (std::numeric_limits<int64_t>::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 ()
 
wxString anonymous_namespace{Nyquist.cpp}::GetClipBoundaries (const Track *t)
 
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<int64_t>::max())

Definition at line 116 of file Nyquist.cpp.

◆ NYQUIST_WORKER_ID

#define NYQUIST_WORKER_ID   wxT("Nyquist Worker")

Definition at line 98 of file Nyquist.cpp.

◆ UNINITIALIZED_CONTROL

#define UNINITIALIZED_CONTROL   ((double)99999999.99)

Definition at line 118 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 102 of file Nyquist.cpp.

103{
104 ID_Editor = 10000,
105 ID_Load,
106 ID_Save,
107
108 ID_Slider = 11000,
109 ID_Text = 12000,
110 ID_Choice = 13000,
111 ID_Time = 14000,
112 ID_FILE = 15000
113};
@ ID_Editor
Definition: Nyquist.cpp:104
@ ID_Load
Definition: Nyquist.cpp:105
@ ID_FILE
Definition: Nyquist.cpp:112
@ ID_Choice
Definition: Nyquist.cpp:110
@ ID_Slider
Definition: Nyquist.cpp:108
@ ID_Save
Definition: Nyquist.cpp:106
ID_Text
Definition: Nyquist.cpp:135
NyquistEffect::OnText ID_Time
Definition: Nyquist.cpp:139

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 141 of file Nyquist.cpp.

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

3506{
3507 auto string = UTF8CTOWX(getstring(xlgastring()));
3508#if !HAS_I18N_CONTEXTS
3509 // allow ignored context argument
3510 if ( moreargs() )
3511 nextarg();
3512#endif
3513 xllastarg();
3514 return cvstring(GetCustomTranslation(string).mb_str(wxConvUTF8));
3515}
STRINGS_API const wxString & GetCustomTranslation(const wxString &str1)
Definition: Internat.cpp:46
#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 3517 of file Nyquist.cpp.

3518{
3519#if HAS_I18N_CONTEXTS
3520 auto string = UTF8CTOWX(getstring(xlgastring()));
3521 auto context = UTF8CTOWX(getstring(xlgastring()));
3522 xllastarg();
3523 return cvstring(wxGetTranslation( string, "", 0, "", context )
3524 .mb_str(wxConvUTF8));
3525#else
3526 return gettext();
3527#endif
3528}
static LVAL gettext()
Definition: Nyquist.cpp:3505

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 3530 of file Nyquist.cpp.

3531{
3532 auto string1 = UTF8CTOWX(getstring(xlgastring()));
3533 auto string2 = UTF8CTOWX(getstring(xlgastring()));
3534 auto number = getfixnum(xlgafixnum());
3535#if !HAS_I18N_CONTEXTS
3536 // allow ignored context argument
3537 if ( moreargs() )
3538 nextarg();
3539#endif
3540 xllastarg();
3541 return cvstring(
3542 wxGetTranslation(string1, string2, number).mb_str(wxConvUTF8));
3543}

References UTF8CTOWX.

Referenced by ngettextc(), and RegisterFunctions().

Here is the caller graph for this function:

◆ ngettextc()

static LVAL ngettextc ( )
static

Definition at line 3545 of file Nyquist.cpp.

3546{
3547#if HAS_I18N_CONTEXTS
3548 auto string1 = UTF8CTOWX(getstring(xlgastring()));
3549 auto string2 = UTF8CTOWX(getstring(xlgastring()));
3550 auto number = getfixnum(xlgafixnum());
3551 auto context = UTF8CTOWX(getstring(xlgastring()));
3552 xllastarg();
3553 return cvstring(wxGetTranslation( string1, string2, number, "", context )
3554 .mb_str(wxConvUTF8));
3555#else
3556 return ngettext();
3557#endif
3558}
static LVAL ngettext()
Definition: Nyquist.cpp:3530

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 3560 of file Nyquist.cpp.

3560 {
3561 LVAL dst;
3562 unsigned char * dstp;
3563 dst = new_string((int)(size+2));
3564 dstp = getstring(dst);
3565
3566 /* copy the source to the destination */
3567 while (size-- > 0)
3568 *dstp++ = *src++;
3569 *dstp = '\0';
3570
3571 return (void*)dst;
3572}

References size.

◆ nyq_reformat_aud_do_response()

void * nyq_reformat_aud_do_response ( const wxString &  Str)

Definition at line 3574 of file Nyquist.cpp.

3574 {
3575 LVAL dst;
3576 LVAL message;
3577 LVAL success;
3578 wxString Left = Str.BeforeLast('\n').BeforeLast('\n').ToAscii();
3579 wxString Right = Str.BeforeLast('\n').AfterLast('\n').ToAscii();
3580 message = cvstring(Left);
3581 success = Right.EndsWith("OK") ? s_true : nullptr;
3582 dst = cons(message, success);
3583 return (void *)dst;
3584}

Referenced by ExecForLisp().

Here is the caller graph for this function:

◆ RegisterFunctions()

static void RegisterFunctions ( )
static

Definition at line 3612 of file Nyquist.cpp.

3613{
3614 // Add functions to XLisp. Do this only once,
3615 // before the first call to nyx_init.
3616 static bool firstTime = true;
3617 if (firstTime) {
3618 firstTime = false;
3619
3620 // All function names must be UP-CASED
3621 static const FUNDEF functions[] = {
3622 { "_", SUBR, gettext },
3623 { "_C", SUBR, gettextc },
3624 { "NGETTEXT", SUBR, ngettext },
3625 { "NGETTEXTC", SUBR, ngettextc },
3626 { "AUD-DO", SUBR, xlc_aud_do },
3627 };
3628
3629 xlbindfunctions( functions, WXSIZEOF( functions ) );
3630 }
3631}
static LVAL gettextc()
Definition: Nyquist.cpp:3517
LVAL xlc_aud_do(void)
Definition: Nyquist.cpp:3591
static LVAL ngettextc()
Definition: Nyquist.cpp:3545

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 3591 of file Nyquist.cpp.

3592{
3593// Based on string-trim...
3594 unsigned char *leftp;
3595 LVAL src,dst;
3596
3597 /* get the string */
3598 src = xlgastring();
3599 xllastarg();
3600
3601 /* setup the string pointer */
3602 leftp = getstring(src);
3603
3604 // Go call my real function here...
3605 dst = (LVAL)ExecForLisp( (char *)leftp );
3606
3607 //dst = cons(dst, (LVAL)1);
3608 /* return the new string */
3609 return (dst);
3610}
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 3114 of file Nyquist.cpp.

◆ NyquistScripts

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

Definition at line 3112 of file Nyquist.cpp.

◆ wxEVT_COMMAND_TEXT_UPDATED

NyquistEffect::OnText wxEVT_COMMAND_TEXT_UPDATED

Definition at line 136 of file Nyquist.cpp.

Referenced by LadspaEditor::PopulateUI(), and NumericTextCtrl::Updated().