From 0ae04be7e246b471134e9f6af04b91d9d3bf3e0a Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 2 Oct 2020 17:39:05 -0400 Subject: [PATCH] nyquist support in a module; application need not link libnyquist --- .../lib-module-manager/ModuleSettings.cpp | 1 + modules/nyquist/CMakeLists.txt | 1 + modules/nyquist/mod-nyq-bench/CMakeLists.txt | 2 +- modules/nyquist/mod-nyq-bench/NyqBench.cpp | 2 +- modules/nyquist/mod-nyq-bench/NyqBench.h | 2 +- modules/nyquist/mod-nyquist/CMakeLists.txt | 21 +++++++++++ .../nyquist/mod-nyquist}/LoadNyquist.cpp | 5 +-- .../nyquist/mod-nyquist}/LoadNyquist.h | 0 .../nyquist/mod-nyquist}/Nyquist.cpp | 35 ++++++++++++------- .../nyquist/mod-nyquist}/Nyquist.h | 4 +-- src/CMakeLists.txt | 10 ------ src/commands/ScriptCommandRelay.cpp | 14 +------- src/commands/ScriptCommandRelay.h | 5 +-- 13 files changed, 55 insertions(+), 47 deletions(-) create mode 100644 modules/nyquist/mod-nyquist/CMakeLists.txt rename {src/effects/nyquist => modules/nyquist/mod-nyquist}/LoadNyquist.cpp (99%) rename {src/effects/nyquist => modules/nyquist/mod-nyquist}/LoadNyquist.h (100%) rename {src/effects/nyquist => modules/nyquist/mod-nyquist}/Nyquist.cpp (99%) rename {src/effects/nyquist => modules/nyquist/mod-nyquist}/Nyquist.h (99%) diff --git a/libraries/lib-module-manager/ModuleSettings.cpp b/libraries/lib-module-manager/ModuleSettings.cpp index c80706e8b334..313e407fe756 100644 --- a/libraries/lib-module-manager/ModuleSettings.cpp +++ b/libraries/lib-module-manager/ModuleSettings.cpp @@ -93,6 +93,7 @@ static const std::unordered_set &autoEnabledModules() "mod-vst", "mod-vst3", "mod-effect-classes", + "mod-nyquist", }; return modules; } diff --git a/modules/nyquist/CMakeLists.txt b/modules/nyquist/CMakeLists.txt index 004cbb8f23e7..af8f88b4dde9 100644 --- a/modules/nyquist/CMakeLists.txt +++ b/modules/nyquist/CMakeLists.txt @@ -3,6 +3,7 @@ # The list of modules is ordered so that each module occurs after any others # that it depends on set( MODULES + mod-nyquist ) if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" ) diff --git a/modules/nyquist/mod-nyq-bench/CMakeLists.txt b/modules/nyquist/mod-nyq-bench/CMakeLists.txt index 7e328c62f147..6150bf4d1a60 100644 --- a/modules/nyquist/mod-nyq-bench/CMakeLists.txt +++ b/modules/nyquist/mod-nyq-bench/CMakeLists.txt @@ -14,7 +14,7 @@ set( DEFINES ) set( LIBRARIES PRIVATE - Audacity + mod-nyquist-interface ) audacity_module( ${TARGET} "${SOURCES}" "${LIBRARIES}" "${DEFINES}" "" ) diff --git a/modules/nyquist/mod-nyq-bench/NyqBench.cpp b/modules/nyquist/mod-nyq-bench/NyqBench.cpp index ff3da0590562..1410745adcf5 100644 --- a/modules/nyquist/mod-nyq-bench/NyqBench.cpp +++ b/modules/nyquist/mod-nyq-bench/NyqBench.cpp @@ -32,7 +32,7 @@ #include "ShuttleGui.h" #include "effects/EffectManager.h" #include "effects/EffectUI.h" -#include "effects/nyquist/Nyquist.h" +#include "Nyquist.h" #include "../images/AudacityLogo.xpm" #include "CommandContext.h" #include "AudacityMessageBox.h" diff --git a/modules/nyquist/mod-nyq-bench/NyqBench.h b/modules/nyquist/mod-nyq-bench/NyqBench.h index 31464259e243..38fa842d4c18 100644 --- a/modules/nyquist/mod-nyq-bench/NyqBench.h +++ b/modules/nyquist/mod-nyq-bench/NyqBench.h @@ -18,7 +18,7 @@ #include #include "CommandManager.h" -#include "effects/nyquist/Nyquist.h" +#include "Nyquist.h" class wxFileName; diff --git a/modules/nyquist/mod-nyquist/CMakeLists.txt b/modules/nyquist/mod-nyquist/CMakeLists.txt new file mode 100644 index 000000000000..ea0b9a03520f --- /dev/null +++ b/modules/nyquist/mod-nyquist/CMakeLists.txt @@ -0,0 +1,21 @@ +#[[ +Interface to the Nyquist library, which can implement effects, generators, +analyzers, and tools invoking macro commands +]] + +set( SOURCES + LoadNyquist.cpp + LoadNyquist.h + Nyquist.cpp + Nyquist.h +) +set( LIBRARIES + Audacity + libnyquist +) + +# Third party libraries used only by this module +set(EXTRA_CLUSTER_NODES "${LIBRARIES}" PARENT_SCOPE) + +audacity_module( mod-nyquist "${SOURCES}" "${LIBRARIES}" + "" "" ) diff --git a/src/effects/nyquist/LoadNyquist.cpp b/modules/nyquist/mod-nyquist/LoadNyquist.cpp similarity index 99% rename from src/effects/nyquist/LoadNyquist.cpp rename to modules/nyquist/mod-nyquist/LoadNyquist.cpp index 44cf8a9adc5c..06d7aad3cb08 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/modules/nyquist/mod-nyquist/LoadNyquist.cpp @@ -8,8 +8,6 @@ **********************************************************************/ - - #include "LoadNyquist.h" #include @@ -271,3 +269,6 @@ bool NyquistEffectsModule::CheckPluginExist(const PluginPath& path) const // ============================================================================ // NyquistEffectsModule implementation // ============================================================================ + +#include "ModuleConstants.h" +DEFINE_MODULE_ENTRIES diff --git a/src/effects/nyquist/LoadNyquist.h b/modules/nyquist/mod-nyquist/LoadNyquist.h similarity index 100% rename from src/effects/nyquist/LoadNyquist.h rename to modules/nyquist/mod-nyquist/LoadNyquist.h diff --git a/src/effects/nyquist/Nyquist.cpp b/modules/nyquist/mod-nyquist/Nyquist.cpp similarity index 99% rename from src/effects/nyquist/Nyquist.cpp rename to modules/nyquist/mod-nyquist/Nyquist.cpp index 65bca0b61e25..578d21055163 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/modules/nyquist/mod-nyquist/Nyquist.cpp @@ -24,7 +24,6 @@ effects from this one class. *//*******************************************************************/ - #include "Nyquist.h" #include "EffectOutputTracks.h" @@ -51,17 +50,17 @@ effects from this one class. #include #include -#include "../../LabelTrack.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 "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 "effects/EffectEditor.h" +#include "effects/EffectManager.h" #include "AudacityMessageBox.h" #include "BasicUI.h" #include "FileNames.h" @@ -3500,7 +3499,7 @@ void NyquistOutputDialog::OnOk(wxCommandEvent & /* event */) } // Registration of extra functions in XLisp. -#include "../../../lib-src/libnyquist/nyquist/xlisp/xlisp.h" +#include "nyquist/xlisp/xlisp.h" static LVAL gettext() { @@ -3583,8 +3582,18 @@ void * nyq_reformat_aud_do_response(const wxString & Str) { return (void *)dst; } -#include "../../commands/ScriptCommandRelay.h" +#include "commands/ScriptCommandRelay.h" + + +static void * ExecForLisp( char * pIn ) +{ + wxString Str1(pIn); + wxString Str2; + + ExecFromMain(&Str1, &Str2); + return nyq_reformat_aud_do_response(Str2); +} /* xlc_aud_do -- interface to C routine aud_do */ /**/ diff --git a/src/effects/nyquist/Nyquist.h b/modules/nyquist/mod-nyquist/Nyquist.h similarity index 99% rename from src/effects/nyquist/Nyquist.h rename to modules/nyquist/mod-nyquist/Nyquist.h index 935ade67feea..81097ab922ce 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/modules/nyquist/mod-nyquist/Nyquist.h @@ -11,7 +11,7 @@ #ifndef __AUDACITY_EFFECT_NYQUIST__ #define __AUDACITY_EFFECT_NYQUIST__ -#include "../StatefulEffect.h" +#include "effects/StatefulEffect.h" #include "FileNames.h" #include "SampleCount.h" #include "wxPanelWrapper.h" @@ -73,7 +73,7 @@ struct NyquistSettings { // Other fields, to do }; -class AUDACITY_DLL_API NyquistEffect final +class NyquistEffect final : public EffectWithSettings { public: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e77f24b5a63..720c8e092ded 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -334,15 +334,6 @@ list( APPEND SOURCES effects/TwoPassSimpleMono.cpp effects/TwoPassSimpleMono.h - # Nyquist Effects - - $<$: - effects/nyquist/LoadNyquist.cpp - effects/nyquist/LoadNyquist.h - effects/nyquist/Nyquist.cpp - effects/nyquist/Nyquist.h - > - # Export export/ExportAudioDialog.cpp @@ -820,7 +811,6 @@ set( LIBRARIES PUBLIC ${CMAKE_REQUIRED_LIBRARIES} ZLIB::ZLIB - $<$:libnyquist> $<$:PkgConfig::GLIB> $<$:PkgConfig::GTK> $<$:Threads::Threads> diff --git a/src/commands/ScriptCommandRelay.cpp b/src/commands/ScriptCommandRelay.cpp index 5a1dac26f2f8..34abeca07021 100644 --- a/src/commands/ScriptCommandRelay.cpp +++ b/src/commands/ScriptCommandRelay.cpp @@ -70,7 +70,7 @@ static int ExecFromWorker(wxString *pIn, wxString *pOut) } /// Executes a command on the main (GUI) thread. -static int ExecFromMain(wxString *pIn, wxString *pOut) +int ExecFromMain(wxString *pIn, wxString *pOut) { return ExecCommand(pIn, pOut, true); } @@ -90,15 +90,3 @@ void ScriptCommandRelay::StartScriptServer(tpRegScriptServerFunc scriptFn) std::thread(server, scriptFn).detach(); } - -#if USE_NYQUIST -void * ExecForLisp( char * pIn ) -{ - wxString Str1(pIn); - wxString Str2; - - ExecFromMain(&Str1, &Str2); - - return nyq_reformat_aud_do_response(Str2); -} -#endif diff --git a/src/commands/ScriptCommandRelay.h b/src/commands/ScriptCommandRelay.h index d2350d0f0050..0176b3e644ab 100644 --- a/src/commands/ScriptCommandRelay.h +++ b/src/commands/ScriptCommandRelay.h @@ -31,9 +31,6 @@ class AUDACITY_DLL_API ScriptCommandRelay static void StartScriptServer(tpRegScriptServerFunc scriptFn); }; -// The void * return is actually a Lisp LVAL and will be cast to such as needed. -extern void * ExecForLisp( char * pIn ); -extern void * nyq_make_opaque_string( int size, unsigned char *src ); -extern void * nyq_reformat_aud_do_response(const wxString & Str); +AUDACITY_DLL_API int ExecFromMain(wxString *pIn, wxString *pOut); #endif /* End of include guard: __SCRIPT_COMMAND_RELAY__ */