36#include <wx/checkbox.h>
38#include <wx/datetime.h>
40#include <wx/scrolwin.h>
43#include <wx/sstream.h>
44#include <wx/stattext.h>
45#include <wx/textdlg.h>
46#include <wx/tokenzr.h>
47#include <wx/txtstrm.h>
49#include <wx/wfstream.h>
50#include <wx/numformatter.h>
51#include <wx/stdpaths.h>
54#include "../EffectEditor.h"
55#include "../EffectManager.h"
57#include "../../LabelTrack.h"
59#include "../../NoteTrack.h"
61#include "../../prefs/SpectrogramSettings.h"
66#include "../../ShuttleGetDefinition.h"
73#include "../../widgets/valnum.h"
77#include "../../prefs/GUIPrefs.h"
78#include "../../tracks/playabletrack/wavetrack/ui/WaveTrackView.h"
79#include "../../tracks/playabletrack/wavetrack/ui/WaveTrackViewConstants.h"
80#include "../../widgets/NumericTextCtrl.h"
85#ifndef nyx_returns_start_and_end_time
86#error You need to update lib-src/libnyquist
95#define NYQUIST_WORKER_ID wxT("Nyquist Worker")
113#define NYQ_MAX_LEN (std::numeric_limits<int64_t>::max())
115#define UNINITIALIZED_CONTROL ((double)99999999.99)
145 mOutputTrack[0] = mOutputTrack[1] =
nullptr;
147 mAction =
XO(
"Applying Nyquist Effect...");
151 mRedirectOutput =
false;
156 mReleaseVersion =
XO(
"n/a");
157 mCopyright =
XO(
"n/a");
160 mRestoreSplits =
true;
186 mName =
XO(
"Nyquist Worker");
193 mName =
Verbatim( mFileName.GetName() );
194 mFileModified = mFileName.GetModificationTime();
197 if (!mOK && mInitError.empty())
198 mInitError =
XO(
"Ill-formed Nyquist plug-in header");
227 return XO(
"Audacity");
248 ? wxString(
"Nyquist_Prompt")
258 for (
size_t i = 0, cnt = paths.size(); i < cnt; i++) {
259 fileName = wxFileName(paths[i] +
wxT(
"/") +
mHelpFile).GetFullPath();
260 if (wxFileExists(fileName))
262 return {
true, fileName };
265 return {
false, wxEmptyString };
348 visitor.
Define( d,
static_cast<const wxChar*
>( ctrl.var.c_str() ),
349 (
double)0.0, ctrl.low, ctrl.high, 1.0);
352 visitor.
Define( x,
static_cast<const wxChar*
>( ctrl.var.c_str() ), 0,
353 static_cast<int>(ctrl.low),
static_cast<int>(ctrl.high), 1);
360 visitor.
DefineEnum( x,
static_cast<const wxChar*
>( ctrl.var.c_str() ),
361 0, ctrl.choices.data(), ctrl.choices.size() );
364 visitor.
Define( ctrl.valStr, ctrl.var,
365 wxString{}, ctrl.lowStr, ctrl.highStr );
383 for (
size_t c = 0, cnt =
mControls.size(); c < cnt; c++)
396 parms.Write(ctrl.
var, d);
400 parms.Write(ctrl.
var, (
int) d);
450 pParms = &localParms;
470 const auto kTestOnly =
true;
471 const auto kTestAndSet =
false;
500 for (
size_t c = 0, cnt =
mControls.size(); c < cnt; c++)
521 good = parms.Read(ctrl.
var, &val) &&
524 if (good && !bTestOnly)
530 good = parms.Read(ctrl.
var, &val) &&
533 if (good && !bTestOnly)
534 ctrl.
val = (double)val;
543 if (good && !bTestOnly)
544 ctrl.
val = (double)val;
549 good = parms.Read(ctrl.
var, &val);
550 if (good && !bTestOnly)
559 badCount += !good ? 1 : 0;
591 bool bAllowSpectralEditing =
false;
592 bool hasSpectral =
false;
599 const auto displays = pView->GetDisplays();
600 if (displays.end() != std::find(
601 displays.begin(), displays.end(),
607 bAllowSpectralEditing =
true;
612 if (!bAllowSpectralEditing || ((mF0 < 0.0) && (mF1 < 0.0))) {
615 XO(
"Enable track spectrogram view before\n"
616 "applying 'Spectral' effects."),
617 wxOK | wxICON_EXCLAMATION | wxCENTRE,
621 XO(
"To use 'Spectral effects', enable 'Spectral Selection'\n"
622 "in the track Spectrogram settings and select the\n"
623 "frequency range for the effect to act on."),
624 wxOK | wxICON_EXCLAMATION | wxCENTRE,
632 if (!mIsPrompt && !mExternal)
642 if (mFileName.GetModificationTime().IsLaterThan(mFileModified))
646 auto dummySettings = MakeSettings();
647 constexpr auto key = L
"TemporarySettings";
648 SaveUserPreset(
key, dummySettings);
652 mFileModified = mFileName.GetModificationTime();
655 (void) LoadUserPreset(
key, dummySettings);
668 auto cleanup =
finally([&]{
670 nyquistSettings.proxySettings = {};
674 proxy.mDebug = nyquistSettings.proxyDebug;
675 proxy.mControls = move(nyquistSettings.controls);
676 auto result =
Delegate(proxy, nyquistSettings.proxySettings);
738"error: File \"%s\" specified in header but not found in plug-in path.\n")
748 mProps += wxString::Format(
wxT(
"(putprop '*AUDACITY* (list %d %d %d) 'VERSION)\n"), AUDACITY_VERSION, AUDACITY_RELEASE, AUDACITY_REVISION);
749 wxString lang =
gPrefs->Read(
wxT(
"/Locale/Language"),
wxT(
""));
750 lang = (lang.empty())
753 mProps += wxString::Format(
wxT(
"(putprop '*AUDACITY* \"%s\" 'LANGUAGE)\n"), lang);
755 mProps += wxString::Format(
wxT(
"(setf *DECIMAL-SEPARATOR* #\\%c)\n"), wxNumberFormatter::GetDecimalSeparator());
763 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-DIR* \"%s\" 'HOME)\n"),
EscapeString(wxGetHomeDir()));
767 for (
size_t i = 0, cnt = paths.size(); i < cnt; i++)
771 list = list.RemoveLast();
773 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-DIR* (list %s) 'PLUGIN)\n"), list);
774 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-DIR* (list %s) 'PLUG-IN)\n"), list);
775 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-DIR* \"%s\" 'USER-PLUG-IN)\n"),
779 wxDateTime now = wxDateTime::Now();
780 int year = now.GetYear();
781 int doy = now.GetDayOfYear();
782 int dom = now.GetDay();
784 wxDateTime::Month month = now.GetMonth();
785 wxDateTime::WeekDay day = now.GetWeekDay();
788 mProps += wxString::Format(
wxT(
"(setf *SYSTEM-TIME* (list %d %d %d %d %d))\n"),
789 year, doy, now.GetHour(), now.GetMinute(), now.GetSecond());
791 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* \"%s\" 'DATE)\n"), now.FormatDate());
792 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* \"%s\" 'TIME)\n"), now.FormatTime());
793 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* \"%s\" 'ISO-DATE)\n"), now.FormatISODate());
794 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* \"%s\" 'ISO-TIME)\n"), now.FormatISOTime());
795 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* %d 'YEAR)\n"), year);
796 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* %d 'DAY)\n"), dom);
797 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* %d 'MONTH)\n"), month);
798 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* \"%s\" 'MONTH-NAME)\n"), now.GetMonthName(month));
799 mProps += wxString::Format(
wxT(
"(putprop '*SYSTEM-TIME* \"%s\" 'DAY-NAME)\n"), now.GetWeekDayName(day));
801 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* %d 'PROJECTS)\n"),
803 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* \"%s\" 'NAME)\n"),
EscapeString(project->GetProjectName()));
810 wxString waveTrackList;
814 for (
auto t : countRange) {
817 if (t->GetSelected())
818 waveTrackList += wxString::Format(
wxT(
"%d "), 1 + numTracks);
823 #if defined(USE_MIDI)
833 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* (float %s) 'RATE)\n"),
835 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* %d 'TRACKS)\n"), numTracks);
836 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* %d 'WAVETRACKS)\n"), numWave);
837 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* %d 'LABELTRACKS)\n"), numLabel);
838 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* %d 'MIDITRACKS)\n"), numMidi);
839 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* %d 'TIMETRACKS)\n"), numTime);
841 double previewLen = 6.0;
842 gPrefs->Read(
wxT(
"/AudioIO/EffectsPreviewLen"), &previewLen);
843 mProps += wxString::Format(
wxT(
"(putprop '*PROJECT* (float %s) 'PREVIEW-DURATION)\n"),
848 mProps += wxString::Format(
wxT(
"(setf *PREVIEWP* %s)\n"), isPreviewing);
850 mProps += wxString::Format(
wxT(
"(putprop '*SELECTION* (float %s) 'START)\n"),
852 mProps += wxString::Format(
wxT(
"(putprop '*SELECTION* (float %s) 'END)\n"),
854 mProps += wxString::Format(
wxT(
"(putprop '*SELECTION* (list %s) 'TRACKS)\n"), waveTrackList);
860 auto message =
XO(
"Audio selection required.");
863 wxOK | wxCENTRE | wxICON_EXCLAMATION,
864 XO(
"Nyquist Error") );
867 std::optional<TrackIterRange<WaveTrack>> pRange;
875 Track *gtLast = NULL;
878 bOnePassTool || pRange->first != pRange->second;
879 (void) (!pRange || (++pRange->first,
true))
885 mCurTrack[0] = pRange ? *pRange->first :
nullptr;
887 if ( (
mT1 >=
mT0) || bOnePassTool ) {
892 if (channels.size() > 1) {
902"Sorry, cannot apply effect on stereo tracks where the tracks don't match."),
936 wxString prevlocale = wxSetlocale(LC_NUMERIC, NULL);
937 wxSetlocale(LC_NUMERIC, wxString(
wxT(
"C")));
943 auto cleanup =
finally( [&] {
944 nyx_capture_output(NULL, (
void *)NULL);
945 nyx_set_os_callback(NULL, (
void *)NULL);
953 wxString lowHz =
wxT(
"nil");
954 wxString highHz =
wxT(
"nil");
955 wxString centerHz =
wxT(
"nil");
956 wxString bandwidth =
wxT(
"nil");
958#if defined(EXPERIMENTAL_SPECTRAL_EDITING)
967 if ((mF0 >= 0.0) && (mF1 >= 0.0)) {
971 if ((mF0 > 0.0) && (mF1 >= mF0)) {
974 double bw = log(mF1 / mF0) / log(2.0);
975 if (!std::isinf(bw)) {
981 mPerTrackProps += wxString::Format(
wxT(
"(putprop '*SELECTION* %s 'LOW-HZ)\n"), lowHz);
982 mPerTrackProps += wxString::Format(
wxT(
"(putprop '*SELECTION* %s 'CENTER-HZ)\n"), centerHz);
983 mPerTrackProps += wxString::Format(
wxT(
"(putprop '*SELECTION* %s 'HIGH-HZ)\n"), highHz);
984 mPerTrackProps += wxString::Format(
wxT(
"(putprop '*SELECTION* %s 'BANDWIDTH)\n"), bandwidth);
990 wxSetlocale(LC_NUMERIC, prevlocale);
992 if (!success || bOnePassTool) {
1013 XO(
"Debug Output: "),
1015 dlog.CentreOnParent();
1020 if( !bOnePassTool && ( nEffectsSoFar ==
nEffectsDone ))
1028 mT0 = selectedRegion.t0();
1029 mT1 = selectedRegion.t1();
1049 int res = wxID_APPLY;
1053 parent,
factory, pInstance, access, forceModal);
1081 auto newAccess = std::make_shared<SimpleEffectSettingsAccess>(newSettings);
1093 parent,
factory, pNewInstance, *newAccess, forceModal);
1105 parent,
factory, pNewInstance, *newAccess,
false );
1112 nyquistSettings.proxySettings = std::move(newSettings);
1113 nyquistSettings.proxyDebug = this->
mDebug;
1114 nyquistSettings.controls = move(effect.
mControls);
1186 cmd +=
wxT(
"(snd-set-latency 0.1)");
1191 cmd +=
wxT(
"(setf S 0.25)\n");
1193 nyx_set_audio_name(
"*TRACK*");
1194 cmd +=
wxT(
"(setf S 0.25)\n");
1197 nyx_set_audio_name(
"S");
1198 cmd +=
wxT(
"(setf *TRACK* '*unbound*)\n");
1211 wxString spectralEditp;
1222 auto displays = pView->GetDisplays();
1223 auto format = [&](
decltype(displays[0]) display ) {
1226 return wxString::Format(
wxT(
"\"%s\""),
1227 display.name.Stripped().Debug() );
1229 if (displays.empty())
1231 else if (displays.size() == 1)
1232 view =
format( displays[0] );
1234 view =
wxT(
"(list");
1235 for (
auto display : displays )
1236 view += wxString(
wxT(
" ")) +
format( display );
1241#if defined(USE_MIDI)
1244 view =
wxT(
"\"Midi\"");
1248 type =
wxT(
"label");
1249 view =
wxT(
"\"Label\"");
1253 view =
wxT(
"\"Time\"");
1257 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* %d 'INDEX)\n"), ++
mTrackIndex);
1259 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* \"%s\" 'TYPE)\n"), type);
1261 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* %s 'VIEW)\n"), view);
1265 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* %s 'SPECTRAL-EDIT-ENABLED)\n"), spectralEditp);
1271 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* (float %s) 'START-TIME)\n"),
1273 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* (float %s) 'END-TIME)\n"),
1275 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* (float %s) 'GAIN)\n"),
1277 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* (float %s) 'PAN)\n"),
1279 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* (float %s) 'RATE)\n"),
1282 switch (
mCurTrack[0]->GetSampleFormat())
1285 bitFormat =
wxT(
"16");
1288 bitFormat =
wxT(
"24");
1291 bitFormat =
wxT(
"32.0");
1294 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* %s 'FORMAT)\n"), bitFormat);
1296 float maxPeakLevel = 0.0;
1297 wxString clips, peakString, rmsString;
1300 float maxPeak = 0.0;
1304 clips +=
wxT(
"(list ");
1308 for (
size_t i=0; i<ca.size(); i++) {
1310 clips += wxString::Format(
wxT(
"(list (float %s) (float %s))"),
1313 }
else if (i == 1000) {
1316 }
else if (i > 1000) {
1324 min = pair.first, max = pair.second;
1325 maxPeak = wxMax(wxMax(fabs(
min), fabs(max)), maxPeak);
1326 maxPeakLevel = wxMax(maxPeakLevel, maxPeak);
1329 if (!std::isinf(maxPeak) && !std::isnan(maxPeak) && (maxPeak < FLT_MAX)) {
1332 peakString +=
wxT(
"nil ");
1336 if (!std::isinf(rms) && !std::isnan(rms)) {
1339 rmsString +=
wxT(
"NIL ");
1343 cmd += wxString::Format(
wxT(
"(putprop '*TRACK* %s%s ) 'CLIPS)\n"),
1348 cmd += wxString::Format(
wxT(
"(putprop '*SELECTION* (vector %s) 'PEAK)\n"), peakString) :
1349 cmd += wxString::Format(
wxT(
"(putprop '*SELECTION* %s 'PEAK)\n"), peakString);
1351 if (!std::isinf(maxPeakLevel) && !std::isnan(maxPeakLevel) && (maxPeakLevel < FLT_MAX)) {
1352 cmd += wxString::Format(
wxT(
"(putprop '*SELECTION* (float %s) 'PEAK-LEVEL)\n"),
1357 cmd += wxString::Format(
wxT(
"(putprop '*SELECTION* (vector %s) 'RMS)\n"), rmsString) :
1358 cmd += wxString::Format(
wxT(
"(putprop '*SELECTION* %s 'RMS)\n"), rmsString);
1363 nyx_set_audio_params(44100, 0);
1380 cmd +=
wxT(
"(setf s 0.25)\n");
1384 cmd +=
wxT(
"(setf *tracenable* T)\n");
1386 cmd +=
wxT(
"(setf *breakenable* T)\n");
1393 cmd +=
wxT(
"(setf *tracenable* NIL)\n");
1396 for (
unsigned int j = 0; j <
mControls.size(); j++) {
1403 cmd += wxString::Format(
wxT(
"(setf %s %s)\n"),
1410 cmd += wxString::Format(
wxT(
"(setf %s %d)\n"),
1415 cmd +=
wxT(
"(setf ");
1420 cmd +=
wxT(
"\")\n");
1431 str +=
wxT(
"\nset aud:result = main()\n");
1437 cmd +=
wxT(
"(setf *tracenable* nil)\n");
1438 cmd +=
wxT(
"(setf *breakenable* nil)\n");
1439 cmd +=
wxT(
"(setf *sal-traceback* t)\n");
1443 cmd +=
wxT(
"(setf *sal-compiler-debug* t)\n");
1446 cmd +=
wxT(
"(setf *sal-call-stack* nil)\n");
1450 cmd +=
wxT(
"(setf aud:result nil)\n");
1451 cmd +=
wxT(
"(sal-compile-audacity \"") +
str +
wxT(
"\" t t nil)\n");
1455 cmd +=
wxT(
"(prog1 aud:result (setf aud:result nil))\n");
1466 auto cleanup =
finally( [&] {
1473 rval = nyx_eval_expression(cmd.mb_str(wxConvUTF8));
1479 wxLogMessage(
wxT(
"\'%s\' returned:\n%s"),
1500 XO(
"';type tool' effects cannot return audio from Nyquist.\n")
1509 XO(
"';type tool' effects cannot return labels from Nyquist.\n")
1514 if (rval == nyx_error) {
1531 if (rval == nyx_list) {
1532 wxLogMessage(
"Nyquist returned nyx_list");
1537 XO(
"Nyquist returned a list.") );
1542 if (rval == nyx_string) {
1568 if (rval == nyx_double) {
1569 auto str =
XO(
"Nyquist returned the value: %f")
1570 .Format(nyx_get_double());
1575 if (rval == nyx_int) {
1576 auto str =
XO(
"Nyquist returned the value: %d")
1577 .Format(nyx_get_int());
1582 if (rval == nyx_labels) {
1584 unsigned int numLabels = nyx_get_num_labels();
1588 auto newTrack = std::make_shared<LabelTrack>();
1595 for (l = 0; l < numLabels; l++) {
1601 nyx_get_label(l, &t0, &t1, &
str);
1608 wxASSERT(rval == nyx_audio);
1610 int outChannels = nyx_get_audio_num_channels();
1613 XO(
"Nyquist returned too many audio channels.\n"));
1617 if (outChannels == -1) {
1619 XO(
"Nyquist returned one audio channel as an array.\n"));
1623 if (outChannels == 0) {
1625 XO(
"Nyquist returned an empty array.\n"));
1629 std::shared_ptr<WaveTrack> outputTrack[2];
1632 for (
int i = 0; i < outChannels; i++) {
1638 outputTrack[i]->SetRate( rate );
1658 std::rethrow_exception( pException );
1664 for (
int i = 0; i < outChannels; i++) {
1665 outputTrack[i]->Flush();
1670 *
this,
XO(
"Nyquist returned nil audio.\n"));
1679 out = outputTrack[i].get();
1682 out = outputTrack[0].get();
1719 wxString
str(nyqString, wxConvUTF8);
1720 if (nyqString != NULL && nyqString[0] &&
str.empty()) {
1722 str =
_(
"[Warning: Nyquist returned invalid UTF-8 string, converted here as Latin-1]");
1732 wxString
str = inStr;
1742 std::vector<EnumValueSymbol> results;
1743 if (text[0] ==
wxT(
'(')) {
1747 auto &choices = tzer.
tokens;
1749 for (
auto &choice : choices) {
1762 auto choices = wxStringTokenize(
1763 text[0] ==
wxT(
'"') ? text.Mid(1, text.length() - 2) : text,
1766 for (
auto &choice : choices)
1767 results.push_back( { choice.Trim(
true).Trim(
false) } );
1776 if (text[0] ==
wxT(
'(')) {
1779 for (
const auto &token : tzer.
tokens)
1780 results.push_back(
UnQuote( token ) );
1789 if (text[0] ==
wxT(
'(')) {
1792 auto &tokens = tzer.
tokens;
1793 if ( tokens.size() == 2 )
1804 if (text[0] ==
wxT(
'(')) {
1807 auto &types = tzer.
tokens;
1808 if ( !types.empty() && types[0][0] ==
wxT(
'(') )
1809 for (
auto &type : types)
1812 if ( results.empty() ) {
1816 auto pieces = wxSplit(
str,
'|' );
1818 auto size = pieces.size();
1819 if (
size % 2 == 1 )
1820 --
size, pieces.pop_back();
1821 for (
size_t ii = 0; ii <
size; ii += 2 ) {
1823 auto extensionStrings = wxSplit( pieces[ii + 1],
';' );
1824 for (
const auto &extensionString : extensionStrings )
1825 if ( extensionString.StartsWith(
wxT(
"*.") ) ) {
1826 auto ext = extensionString.substr( 2 );
1827 if (ext ==
wxT(
"*"))
1830 extensions.push_back( ext );
1832 results.push_back( {
Verbatim( pieces[ii] ), extensions } );
1868 wxString *pExtraString)
1871 *pExtraString = wxString{};
1873 int len = s.length();
1874 if (len >= 2 && s[0] ==
wxT(
'\"') && s[len - 1] ==
wxT(
'\"')) {
1875 auto unquoted = s.Mid(1, len - 2);
1880 else if (allowParens &&
1881 len >= 2 && s[0] ==
wxT(
'(') && s[len - 1] ==
wxT(
')')) {
1884 auto &tokens = tzer.
tokens;
1885 if (tokens.size() > 1) {
1886 if (pExtraString && tokens[1][0] ==
'(') {
1890 *pExtraString =
UnQuote(tokens[0],
false);
1909 wxString *pExtraString)
1933 const wxString &line,
bool eof,
1934 size_t trimStart,
size_t trimEnd)
1936 auto endToken = [&]{
1945 if (
q && !
sl && c ==
wxT(
'\\')) {
1951 if (!
sl && c ==
wxT(
'"')) {
1971 else if (!
q && !
paren && (c ==
wxT(
' ') || c ==
wxT(
'\t')))
1975 else if (!
q && c ==
wxT(
';'))
1981 else if (!
q && c ==
wxT(
'(')) {
1985 endToken(),
tok += c;
1990 else if (!
q && c ==
wxT(
')')) {
1994 tok += c, endToken();
1997 paren = 0, endToken();
2018 if (eof || (!
q && !
paren)) {
2032 Tokenizer &tzer,
const wxString &line,
bool eof,
bool first)
2034 if ( !tzer.
Tokenize(line, eof, first ? 1 : 0, 0) )
2037 const auto &tokens = tzer.
tokens;
2038 int len = tokens.size();
2045 if (len == 2 && tokens[0] ==
wxT(
"nyquist") &&
2046 (tokens[1] ==
wxT(
"plug-in") || tokens[1] ==
wxT(
"plugin"))) {
2051 if (len >= 2 && tokens[0] ==
wxT(
"type")) {
2052 wxString tok = tokens[1];
2054 if (tok ==
wxT(
"tool")) {
2068 if (tok ==
wxT(
"process")) {
2071 else if (tok ==
wxT(
"generate")) {
2074 else if (tok ==
wxT(
"analyze")) {
2078 if (len >= 3 && tokens[2] ==
wxT(
"spectral")) {;
2084 if (len == 2 && tokens[0] ==
wxT(
"codetype")) {
2086 if (tokens[1] ==
wxT(
"lisp")) {
2090 else if (tokens[1] ==
wxT(
"sal")) {
2097 if (len >= 2 && tokens[0] ==
wxT(
"debugflags")) {
2098 for (
int i = 1; i < len; i++) {
2101 if (tokens[i] ==
wxT(
"trace")) {
2104 else if (tokens[i] ==
wxT(
"notrace")) {
2107 else if (tokens[i] ==
wxT(
"compiler")) {
2110 else if (tokens[i] ==
wxT(
"nocompiler")) {
2121 if (len >= 2 && tokens[0] ==
wxT(
"version")) {
2123 tokens[1].ToLong(&v);
2124 if (v < 1 || v > 4) {
2128"This version of Audacity does not support Nyquist plug-in version %ld")
2135 if (len >= 2 && tokens[0] ==
wxT(
"name")) {
2145 if (
name.EndsWith(
wxT(
"...")))
2151 if (len >= 2 && tokens[0] ==
wxT(
"action")) {
2156 if (len >= 2 && tokens[0] ==
wxT(
"info")) {
2161 if (len >= 2 && tokens[0] ==
wxT(
"preview")) {
2162 if (tokens[1] ==
wxT(
"enabled") || tokens[1] ==
wxT(
"true")) {
2166 else if (tokens[1] ==
wxT(
"linear")) {
2170 else if (tokens[1] ==
wxT(
"selection")) {
2174 else if (tokens[1] ==
wxT(
"disabled") || tokens[1] ==
wxT(
"false")) {
2182 if (len >= 2 && tokens[0] ==
wxT(
"maxlen")) {
2184 tokens[1].ToLongLong(&v);
2188#if defined(EXPERIMENTAL_NYQUIST_SPLIT_CONTROL)
2189 if (len >= 2 && tokens[0] ==
wxT(
"mergeclips")) {
2192 tokens[1].ToLong(&v);
2197 if (len >= 2 && tokens[0] ==
wxT(
"restoresplits")) {
2200 tokens[1].ToLong(&v);
2206 if (len >= 2 && tokens[0] ==
wxT(
"author")) {
2211 if (len >= 2 && tokens[0] ==
wxT(
"release")) {
2218 if (len >= 2 && tokens[0] ==
wxT(
"copyright")) {
2224 if (len >= 2 && tokens[0] ==
wxT(
"manpage")) {
2231 if (len >= 2 && tokens[0] ==
wxT(
"helpfile")) {
2238 if (len >= 2 && tokens[0] ==
wxT(
"debugbutton")) {
2239 if (tokens[1] ==
wxT(
"disabled") || tokens[1] ==
wxT(
"false")) {
2246 if (len >= 3 && tokens[0] ==
wxT(
"control")) {
2249 if (len == 3 && tokens[1] ==
wxT(
"text")) {
2250 ctrl.
var = tokens[1];
2256 ctrl.
var = tokens[1];
2259 ctrl.
label = tokens[4];
2262 ctrl.
valStr = len > 5 ? tokens[5] : wxString{};
2264 if (ctrl.
valStr.length() > 0 &&
2272 if (tokens[3] ==
wxT(
"string")) {
2276 else if (tokens[3] ==
wxT(
"choice")) {
2281 else if (tokens[3] ==
wxT(
"file")) {
2295 if ((tokens[3] ==
wxT(
"float")) ||
2296 (tokens[3] ==
wxT(
"real")))
2298 else if (tokens[3] ==
wxT(
"int"))
2300 else if (tokens[3] ==
wxT(
"float-text"))
2302 else if (tokens[3] ==
wxT(
"int-text"))
2304 else if (tokens[3] ==
wxT(
"time"))
2309 str.Printf(
wxT(
"Bad Nyquist 'control' type specification: '%s' in plug-in file '%s'.\nControl not created."),
2329 ctrl.
low = -(FLT_MAX);
2340 ctrl.
high = INT_MAX;
2345 ctrl.
high = FLT_MAX;
2355 if (ctrl.
val < ctrl.
low) {
2378 if (len >= 2 && tokens[0] ==
wxT(
"categories")) {
2379 for (
size_t i = 1; i < tokens.size(); ++i) {
2394 wxTextInputStream pgm(stream,
wxT(
" \t"), wxConvAuto());
2416 while (!stream.Eof() && stream.IsOk())
2418 wxString line = pgm.ReadLine();
2419 if (line.length() > 1 &&
2423 (line[0] ==
wxT(
';') || line[0] ==
wxT(
'$')) )
2426 unsigned nLines = 1;
2430 line[0] ==
wxT(
'$') || line.StartsWith(
wxT(
";control") );
2432 done =
Parse(tzer, line, !control || stream.Eof(), nLines == 1);
2434 (line = pgm.ReadLine(), ++nLines,
true));
2445 if (line[0] ==
wxT(
'(') ||
2446 (line[0] ==
wxT(
'#') && line.length() > 1 && line[1] ==
wxT(
'|')))
2451 else if (line.Upper().Find(
wxT(
"RETURN")) != wxNOT_FOUND)
2466"Your code looks like SAL syntax, but there is no \'return\' statement.\n\
2467For SAL, use a return statement such as:\n\treturn *track* * 0.1\n\
2468or for LISP, begin with an open parenthesis such as:\n\t(mult *track* 0.1)\n ."),
2470 XO(
"Error in Nyquist code") );
2486 wxFileInputStream rawStream(
mFileName.GetFullPath());
2487 wxBufferedInputStream stream(rawStream, 10000);
2494 wxStringInputStream stream(cmd +
wxT(
" "));
2500 int64_t start, int64_t len, int64_t totlen,
2504 return This->
GetCallback(buffer, channel, start, len, totlen);
2508 int64_t start, int64_t len, int64_t WXUNUSED(totlen))
2548 std::memcpy(buffer, src, len *
sizeof(
float));
2551 double progress =
mScale *
2567 int64_t start, int64_t len, int64_t totlen,
2571 return This->
PutCallback(buffer, channel, start, len, totlen);
2575 int64_t start, int64_t len, int64_t totlen)
2578 return GuardedCall<int>( [&] {
2580 double progress =
mScale*((float)(start+len)/totlen);
2610 std::cout << (char)c;
2643#if defined(__WXMAC__)
2653 for (
size_t i = 0; i < audacityPathList.size(); i++)
2655 wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
2674 for (
size_t i = 0, cnt =
mControls.size(); i < cnt; i++)
2680 const auto count = ctrl.
choices.size();
2682 int val = (int)ctrl.
val;
2683 if (val < 0 || val >= (
int)count)
2689 c->SetSelection(val);
2694 double range = ctrl.
high - ctrl.
low;
2695 int val = (int)(0.5 + ctrl.
ticks * (ctrl.
val - ctrl.
low) / range);
2715 const wxString left =
wxT(
"\u201c"), right =
wxT(
"\u201d"), dumb =
'"';
2719 const wxString leftSingle =
wxT(
"\u2018"), rightSingle =
wxT(
"\u2019"),
2721 mInputCmd.Replace(leftSingle, dumbSingle,
true);
2722 mInputCmd.Replace(rightSingle, dumbSingle,
true);
2734 for (
unsigned int i = 0; i <
mControls.size(); i++)
2758 if (ctrl->
valStr.StartsWith(
"\"", &path))
2761 if (path.EndsWith(
"\"", &path))
2763 path.Replace(
"\"\"",
"\"");
2764 wxStringTokenizer tokenizer(path,
"\"");
2765 while (tokenizer.HasMoreTokens())
2767 wxString token = tokenizer.GetNextToken();
2770 const auto message =
2771 XO(
"\"%s\" is not a valid file path.").Format( token );
2774 wxOK | wxICON_EXCLAMATION | wxCENTRE,
2783 const auto message =
2785 XO(
"Mismatched quotes in\n%s").Format( ctrl->
valStr );
2788 wxOK | wxICON_EXCLAMATION | wxCENTRE,
2800 const auto message =
2801 XO(
"\"%s\" is not a valid file path.").Format( ctrl->
valStr );
2804 wxOK | wxICON_EXCLAMATION | wxCENTRE,
2816 ctrl->
low = INT_MIN;
2819 ctrl->
lowStr.IsSameAs(
wxT(
"nil"),
false))
2821 ctrl->
low = -(FLT_MAX);
2829 ctrl->
high = INT_MAX;
2834 ctrl->
high = FLT_MAX;
2846 if (ctrl->
val < ctrl->
low)
2869 S.StartVerticalLay();
2871 S.StartMultiColumn(3, wxEXPAND);
2873 S.SetStretchyCol(1);
2875 S.AddVariableText(
XO(
"Enter Nyquist Command: "));
2881 S.StartHorizontalLay(wxEXPAND, 1);
2884 .MinSize( { 500, 200 } )
2885 .AddTextWindow(
wxT(
""));
2887 S.EndHorizontalLay();
2889 S.StartHorizontalLay(wxALIGN_CENTER, 0);
2894 S.EndHorizontalLay();
2901 wxScrolledWindow *scroller =
S.Style(wxVSCROLL | wxTAB_TRAVERSAL)
2904 S.StartMultiColumn(4);
2906 for (
size_t i = 0; i <
mControls.size(); i++)
2913 S.StartHorizontalLay(wxALIGN_LEFT, 0);
2918 S.EndHorizontalLay();
2919 S.StartMultiColumn(4);
2923 auto prompt =
XXO(
"%s:").Format( ctrl.
name );
2924 S.AddPrompt( prompt );
2931 .Validator<wxGenericValidator>(&ctrl.
valStr)
2933 .AddTextBox( {},
wxT(
""), 50);
2960 .Position(wxALIGN_LEFT | wxALL)
2971 if ( !type.extensions.empty() )
2972 defaultExtension = type.extensions[0];
2978 .AddTextBox( {},
wxT(
""), 40);
2979 item->SetValidator(wxGenericValidator(&ctrl.
valStr));
2981 if (ctrl.
label.empty())
2983 ctrl.
label = wxGetTranslation( wxFileSelectorPromptStr );
2998 double range = ctrl.
high - ctrl.
low;
2999 S.Validator<FloatingPointValidator<double>>(
3004 ? NumValidatorStyle::THREE_TRAILING_ZEROES
3006 ? NumValidatorStyle::TWO_TRAILING_ZEROES
3007 : NumValidatorStyle::ONE_TRAILING_ZERO),
3013 S.Validator<IntegerValidator<double>>(
3014 &ctrl.
val, NumValidatorStyle::DEFAULT,
3015 (int) ctrl.
low, (
int) ctrl.
high);
3017 wxTextCtrl *item =
S
3019 .AddTextBox( {},
wxT(
""),
3026 .Style(wxSL_HORIZONTAL)
3027 .MinSize( { 150, -1 } )
3028 .AddSlider( {}, 0, ctrl.
ticks, 0);
3050 scroller->SetScrollRate(0, 20);
3053 scroller->SetName(
wxT(
"\a"));
3054 scroller->SetLabel(
wxT(
"\a"));
3076 XO(
"Current program has been modified.\nDiscard changes?"),
3085 XO(
"Load Nyquist script"),
3091 FileNames::TextFiles,
3094 wxFD_OPEN | wxRESIZE_BORDER);
3113 XO(
"Save Nyquist script"),
3121 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER);
3141 int val = evt.GetInt();
3142 double range = ctrl.
high - ctrl.
low;
3143 double newVal = (val / (double)ctrl.
ticks) * range + ctrl.
low;
3146 int precision = range < 1.0 ? 3 :
3154 if (fabs(newVal - ctrl.
val) >= (1 / (double)ctrl.
ticks) * range &&
3155 fabs(newVal - ctrl.
val) >= pow(0.1, precision) / 2)
3158 newVal *= pow(10.0, precision);
3159 newVal = floor(newVal + 0.5);
3160 newVal /= pow(10.0, precision);
3175 int i = evt.GetId() -
ID_Time;
3176 static double value = 0.0;
3185 if (val < ctrl.low || val > ctrl.
high) {
3186 const auto message =
XO(
"Value range:\n%s to %s")
3191 XO(
"Value Error") );
3196 else if (val > ctrl.
high)
3206 int i = evt.GetId() -
ID_FILE;
3211 unsigned int flags = 0;
3214 wxStringTokenizer tokenizer(ctrl.
highStr,
",");
3215 while ( tokenizer.HasMoreTokens() )
3217 wxString token = tokenizer.GetNextToken().Trim(
true).Trim(
false);
3218 if (token.IsSameAs(
"open",
false))
3221 flags &= ~wxFD_SAVE;
3222 flags &= ~wxFD_OVERWRITE_PROMPT;
3224 else if (token.IsSameAs(
"save",
false))
3227 flags &= ~wxFD_OPEN;
3228 flags &= ~wxFD_MULTIPLE;
3229 flags &= ~wxFD_FILE_MUST_EXIST;
3231 else if (token.IsSameAs(
"overwrite",
false) && !(flags & wxFD_OPEN))
3233 flags |= wxFD_OVERWRITE_PROMPT;
3235 else if (token.IsSameAs(
"exists",
false) && !(flags & wxFD_SAVE))
3237 flags |= wxFD_FILE_MUST_EXIST;
3239 else if (token.IsSameAs(
"multiple",
false) && !(flags & wxFD_SAVE))
3241 flags |= wxFD_MULTIPLE;
3248 wxFileName fname = ctrl.
valStr;
3249 wxString defaultDir = fname.GetPath();
3250 wxString defaultFile = fname.GetName();
3251 auto message =
XO(
"Select a file");
3253 if (flags & wxFD_MULTIPLE)
3254 message =
XO(
"Select one or more files");
3255 else if (flags & wxFD_SAVE)
3256 message =
XO(
"Save file as");
3265 if (openFileDialog.
ShowModal() == wxID_CANCEL)
3272 if (flags & wxFD_MULTIPLE)
3274 wxArrayString selectedFiles;
3275 openFileDialog.
GetPaths(selectedFiles);
3277 for (
size_t sf = 0; sf < selectedFiles.size(); sf++) {
3279 path += selectedFiles[sf];
3302#if defined(__WXMSW__)
3303 path.Replace(
"/", wxFileName::GetPathSeparator());
3306 path.Trim(
true).Trim(
false);
3308 typedef std::unordered_map<wxString, FilePath> map;
3310 {
"*home*", wxGetHomeDir()},
3311 {
"~", wxGetHomeDir()},
3318 int characters = path.Find(wxFileName::GetPathSeparator());
3319 if(characters == wxNOT_FOUND)
3324 if (pathKeys.find(path) != pathKeys.end())
3327 path = pathKeys[path] + wxFileName::GetPathSeparator();
3331 path = pathKeys[
"*default*"] + wxFileName::GetPathSeparator() + path;
3336 wxString firstDir = path.Left(characters);
3337 wxString rest = path.Mid(characters);
3339 if (pathKeys.find(firstDir) != pathKeys.end())
3341 path = pathKeys[firstDir] + rest;
3345 wxFileName fname = path;
3349 if (fname.wxFileName::IsOk() && fname.GetFullName().empty())
3351 path = fname.GetPathWithSep() +
_(
"untitled");
3352 if (!extension.empty())
3353 path = path +
'.' + extension;
3360 wxFileName fname = path;
3361 wxString dir = fname.GetPath();
3363 return (fname.wxFileName::IsOk() &&
3364 wxFileName::DirExists(dir) &&
3365 !fname.GetFullName().empty());
3371 int seconds =
static_cast<int>(t);
3372 int hh = seconds / 3600;
3373 int mm = seconds % 3600;
3375 return wxString::Format(
"%d:%d:%.3f", hh, mm, t - (hh * 3600 + mm * 60));
3381 int i = evt.GetId() -
ID_Text;
3385 if (wxDynamicCast(evt.GetEventObject(), wxWindow)->GetValidator()->TransferFromWindow())
3389 int pos = (int)floor((ctrl.
val - ctrl.
low) /
3393 slider->SetValue(pos);
3413:
wxDialogWrapper{ parent,
id,
title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER }
3421 S.AddVariableText( prompt,
false, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT );
3426 .Position(wxEXPAND | wxALL)
3427 .MinSize( { 480, 250 } )
3428 .Style(wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH)
3429 .AddTextWindow( message.Translation() );
3433 S.StartHorizontalLay(wxALIGN_CENTRE | wxLEFT | wxBOTTOM | wxRIGHT, 0 );
3436 S.Id(wxID_OK).AddButton(
XXO(
"OK"), wxALIGN_CENTRE,
true );
3438 S.EndHorizontalLay();
3442 SetAutoLayout(
true);
3443 GetSizer()->Fit(
this);
3444 GetSizer()->SetSizeHints(
this);
3457#include "../../../lib-src/libnyquist/nyquist/xlisp/xlisp.h"
3461 auto string =
UTF8CTOWX(getstring(xlgastring()));
3462#if !HAS_I18N_CONTEXTS
3473#if HAS_I18N_CONTEXTS
3474 auto string =
UTF8CTOWX(getstring(xlgastring()));
3475 auto context =
UTF8CTOWX(getstring(xlgastring()));
3477 return cvstring(wxGetTranslation(
string,
"", 0,
"", context )
3478 .mb_str(wxConvUTF8));
3486 auto string1 =
UTF8CTOWX(getstring(xlgastring()));
3487 auto string2 =
UTF8CTOWX(getstring(xlgastring()));
3488 auto number = getfixnum(xlgafixnum());
3489#if !HAS_I18N_CONTEXTS
3496 wxGetTranslation(string1, string2, number).mb_str(wxConvUTF8));
3501#if HAS_I18N_CONTEXTS
3502 auto string1 =
UTF8CTOWX(getstring(xlgastring()));
3503 auto string2 =
UTF8CTOWX(getstring(xlgastring()));
3504 auto number = getfixnum(xlgafixnum());
3505 auto context =
UTF8CTOWX(getstring(xlgastring()));
3507 return cvstring(wxGetTranslation( string1, string2, number,
"", context )
3508 .mb_str(wxConvUTF8));
3516 unsigned char * dstp;
3517 dst = new_string((
int)(
size+2));
3518 dstp = getstring(dst);
3532 wxString Left = Str.BeforeLast(
'\n').BeforeLast(
'\n').ToAscii();
3533 wxString Right = Str.BeforeLast(
'\n').AfterLast(
'\n').ToAscii();
3534 message = cvstring(Left);
3535 success = Right.EndsWith(
"OK") ? s_true :
nullptr;
3536 dst = cons(message, success);
3540#include "../../commands/ScriptCommandRelay.h"
3548 unsigned char *leftp;
3556 leftp = getstring(src);
3570 static bool firstTime =
true;
3575 static const FUNDEF functions[] = {
3583 xlbindfunctions( functions, WXSIZEOF( functions ) );
wxEVT_COMMAND_BUTTON_CLICKED
SimpleGuard< R > MakeSimpleGuard(R value) noexcept(noexcept(SimpleGuard< R >{ value }))
Convert a value to a handler function returning that value, suitable for GuardedCall<R>
Toolkit-neutral facade for basic user interface services.
static const AudacityProject::AttachedObjects::RegisteredFactory key
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
const TranslatableString name
#define NYQUISTEFFECTS_FAMILY
std::function< DialogFactoryResults(wxWindow &parent, EffectBase &, EffectUIServices &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
XXO("&Cut/Copy/Paste Toolbar")
wxString FileExtension
File extension, not including any leading dot.
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
STRINGS_API const wxString & GetCustomTranslation(const wxString &str1)
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
const NumericConverterType & NumericConverterType_TIME()
#define UNINITIALIZED_CONTROL
void * nyq_make_opaque_string(int size, unsigned char *src)
void * nyq_reformat_aud_do_response(const wxString &Str)
static const FileNames::FileType LispScripts
wxEVT_COMMAND_TEXT_UPDATED
static const wxChar * KEY_Command
static const FileNames::FileType NyquistScripts
EVT_COMMAND_RANGE(ID_Slider, ID_Slider+99, wxEVT_COMMAND_SLIDER_UPDATED, NyquistEffect::OnSlider) EVT_COMMAND_RANGE(ID_Text
#define NYQUIST_WORKER_ID
static const wxChar * KEY_Parameters
NyquistEffect::OnText ID_Time
static void RegisterFunctions()
#define NYQUIST_PROMPT_ID
#define NYQUIST_PROMPT_NAME
an object holding per-project preferred sample rate
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
void * ExecForLisp(char *pIn)
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
static Settings & settings()
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool WriteEnum(const wxString &key, int value, const EnumValueSymbol choices[], size_t nChoices)
bool GetParameters(wxString &parms)
bool ReadEnum(const wxString &key, int *pi, const EnumValueSymbol choices[], size_t nChoices, const ObsoleteMap obsoletes[]=nullptr, size_t nObsoletes=0) const
bool SetParameters(const wxString &parms)
TranslatableString GetName() const
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for many of the effects in Audacity.
std::shared_ptr< TrackList > mOutputTracks
void SetPreviewFullSelectionFlag(bool previewDurationFlag)
bool IsPreviewing() const
void SetLinearEffectFlag(bool linearEffectFlag)
const TrackList * inputTracks() const
wxArrayString mPresetNames
void ReplaceProcessedTracks(const bool bGoodResult)
const AudacityProject * FindProject() const
static bool EnablePreview(wxWindow *parent, bool enable=true)
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
void SetBatchProcessing() override
bool Delegate(Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
Re-invoke DoEffect on another Effect object that implements the work.
void CopyInputTracks(bool allSyncLockSelected=false)
virtual NumericFormatSymbol GetSelectionFormat()
bool TotalProgress(double frac, const TranslatableString &={}) const
Track * AddToOutputTracks(const std::shared_ptr< Track > &t)
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
bool IsBatchProcessing() const override
unsigned TestUIFlags(unsigned mask)
int GetNumWaveGroups() const
Performs effect computation.
EffectManager is the class that handles effects and effect categories.
void SetSkipStateFlag(bool flag)
static EffectManager & Get()
Hold values to send to effect output meters.
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
virtual int ShowHostInterface(EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
static NyquistSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
EffectSettings MakeSettings() const override
virtual wxString GetPath() const
virtual void GetPaths(wxArrayString &paths) const
std::vector< FileType > FileTypes
static FormatterContext SampleRateContext(double sampleRate)
static wxString ToString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, always uses the dot as decimal separator.
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
A LabelTrack is a Track that holds labels (LabelStruct).
static wxString GetDefaultName()
A Track that is used for Midi notes. (Somewhat old code).
void SetValue(double newValue)
A control on a NyquistDialog.
std::vector< EnumValueSymbol > choices
FileNames::FileTypes fileTypes
An Effect that calls up a Nyquist (XLISP) plug-in, i.e. many possible effects from this one class.
bool Process(EffectInstance &instance, EffectSettings &settings) override
static TranslatableString UnQuoteMsgid(const wxString &s, bool allowParens=true, wxString *pExtraString=nullptr)
TranslatableString GetDescription() const override
wxWeakRef< wxWindow > mUIParent
int GetCallback(float *buffer, int channel, int64_t start, int64_t len, int64_t totlen)
static double GetCtrlValue(const wxString &s)
wxTextCtrl * mCommandText
bool ParseCommand(const wxString &cmd)
TranslatableString mDebugOutput
std::pair< bool, FilePath > CheckHelpPage() const
bool TransferDataFromPromptWindow()
TranslatableString mCopyright
bool TransferDataFromWindow(EffectSettings &settings) override
TranslatableString mPromptName
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
void OutputCallback(int c)
std::exception_ptr mpException
bool Parse(Tokenizer &tokenizer, const wxString &line, bool eof, bool first)
FileExtensions ParseFileExtensions(const wxString &text)
void BuildEffectWindow(ShuttleGui &S)
bool IsDefault() const override
Whether the effect sorts "above the line" in the menus.
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
EffectFamilySymbol GetFamily() const override
Report identifier and user-visible name of the effect protocol.
bool ParseProgram(wxInputStream &stream)
static void StaticOSCallback(void *userdata)
bool DoLoadSettings(const CommandParameters &parms, EffectSettings &settings)
int SetLispVarsFromParameters(const CommandParameters &parms, bool bTestOnly)
void OnLoad(wxCommandEvent &evt)
bool EnablesDebug() const override
Whether the effect dialog should have a Debug button; default, always false.
static void StaticOutputCallback(int c, void *userdata)
bool TransferDataFromEffectWindow()
void OnFileButton(wxCommandEvent &evt)
bool TransferDataToPromptWindow()
wxString ToTimeFormat(double t)
int ShowHostInterface(EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
EffectType GetType() const override
Type determines how it behaves.
bool validatePath(wxString path)
bool TransferDataToEffectWindow()
TranslatableString mAuthor
FileNames::FileTypes ParseFileTypes(const wxString &text)
std::unique_ptr< float[]> Buffer
WaveTrack * mOutputTrack[2]
unsigned mNumSelectedChannels
EffectType GetClassification() const override
Determines which menu it appears in; default same as GetType().
static FilePaths GetNyquistSearchPath()
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
static int StaticPutCallback(float *buffer, int channel, int64_t start, int64_t len, int64_t totlen, void *userdata)
int PutCallback(float *buffer, int channel, int64_t start, int64_t len, int64_t totlen)
wxFileName mFileName
Name of the Nyquist script file this effect is loaded from.
bool TransferDataToWindow(const EffectSettings &settings) override
void OnSlider(wxCommandEvent &evt)
void OnSave(wxCommandEvent &evt)
TranslatableString mName
Name of the Effect (untranslated)
wxString EscapeString(const wxString &inStr)
TranslatableString mAction
FilePath HelpPage() const override
Fully qualified local help file name, default is empty.
std::vector< NyqControl > mControls
static wxString NyquistToWxString(const char *nyqString)
void SetCommand(const wxString &cmd)
ComponentInterfaceSymbol GetSymbol() const override
FileNames::FileType ParseFileType(const wxString &text)
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
void BuildPromptWindow(ShuttleGui &S)
void OnTime(wxCommandEvent &evt)
PluginPath GetPath() const override
wxArrayString mCategories
static std::vector< EnumValueSymbol > ParseChoice(const wxString &text)
TranslatableString mReleaseVersion
bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings) override
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
static wxString UnQuote(const wxString &s, bool allowParens=true, wxString *pExtraString=nullptr)
TranslatableString mInitError
static void resolveFilePath(wxString &path, FileExtension extension={})
void OnChoice(wxCommandEvent &evt)
static int StaticGetCallback(float *buffer, int channel, int64_t start, int64_t len, int64_t totlen, void *userdata)
sampleCount mCurBufferStart[2]
void OnText(wxCommandEvent &evt)
VendorSymbol GetVendor() const override
wxString GetVersion() const override
Dialog used with NyquistEffect.
void OnOk(wxCommandEvent &event)
static ProjectRate & Get(AudacityProject &project)
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Defines a selected portion of a project.
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
virtual void Define(Arg< bool > var, const wxChar *key, bool vdefault, bool vmin=false, bool vmax=false, bool vscl=false)
virtual void DefineEnum(Arg< int > var, const wxChar *key, int vdefault, const EnumValueSymbol strings[], size_t nStrings)
SettingsVisitor that gets parameter values into a string.
SettingsVisitor that retrieves a JSON format definition of a command's parameters.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
SettingsVisitor that sets parameters to a value (from a string)
bool SpectralSelectionEnabled() const
static SpectrogramSettings & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
static bool IsSyncLockSelected(const Track *pTrack)
static TrackIterRange< Track > Group(Track *pTrack)
A kind of Track used to 'warp time'.
Abstract base class for an object holding data associated with points on a time axis.
virtual double GetStartTime() const =0
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
virtual double GetEndTime() const =0
auto SelectedLeaders() -> TrackIterRange< TrackType >
auto Leaders() -> TrackIterRange< TrackType >
static TrackList & Get(AudacityProject &project)
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
A Track that contains audio waveform data.
bool Append(constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1, sampleFormat effectiveFormat=widestSampleFormat) override
size_t GetBestBlockSize(sampleCount t) const override
This returns a nonnegative number of samples meant to size a memory buffer.
WaveClipPointers SortedClipArray()
std::pair< float, float > GetMinMax(double t0, double t1, bool mayThrow=true) const
size_t GetIdealBlockSize()
float GetRMS(double t0, double t1, bool mayThrow=true) const
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
double GetRate() const override
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}, bool keepLink=true) const
static WaveTrackView * Find(WaveTrack *pTrack)
Positions or offsets within audio files need a wide type.
long long as_long_long() const
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
void Yield()
Dispatch waiting events, including actions enqueued by CallAfter.
FILES_API FilePath PlugInDir()
The user plug-in directory (not a system one)
FILES_API FilePath HtmlHelpDir()
FILES_API wxFileNameWrapper DefaultToDocumentsFolder(const wxString &preference)
FILES_API void AddUniquePathToPathList(const FilePath &path, FilePaths &pathList)
FILES_API FilePath BaseDir()
FILES_API FilePath DataDir()
Audacity user data directory.
FILES_API FilePath FindDefaultPath(Operation op)
FILES_API const FilePaths & AudacityPathList()
A list of directories that should be searched for Audacity files (plug-ins, help files,...
wxString GetSystemLanguageCode(const FilePaths &pathList)
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
FILES_API wxString TempDir()
double GetRate(const Track &track)
static RegisteredToolbarFactory factory
__finl float_x4 __vecc sqrt(const float_x4 &a)
Externalized state of a plug-in.
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Options & MenuEnabled(bool enable)
Options & AutoPos(bool enable)
Options & ReadOnly(bool enable)
bool Tokenize(const wxString &line, bool eof, size_t trimStart, size_t trimEnd)