diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index de2c60c..d22af90 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -31,3 +31,9 @@ elseif(APPLE) elseif(UNIX AND NOT APPLE) target_compile_definitions(${PROJECT_NAME} PUBLIC PLATFORM_WINDOWS=0 PLATFORM_MACOS=0 PLATFORM_LINUX=1 GLFW_EXPOSE_NATIVE_X11) endif() + +if (CMAKE_BUILD_TYPE MATCHES "Debug") + target_compile_definitions(${PROJECT_NAME} PUBLIC BUILD_DEBUG=1) +else() + target_compile_definitions(${PROJECT_NAME} PUBLIC BUILD_DEBUG=0) +endif() \ No newline at end of file diff --git a/core/audio/plugin_host/plugin_host.h b/core/audio/plugin_host/plugin_host.h index 398b834..13f04fd 100644 --- a/core/audio/plugin_host/plugin_host.h +++ b/core/audio/plugin_host/plugin_host.h @@ -37,6 +37,8 @@ public: [[nodiscard]] virtual std::string load_name() const { return ""; } [[nodiscard]] virtual std::string load_vendor() const { return ""; } + virtual std::string get_parameter_name(int index) const { return ""; } + void init_channel_interface(); std::string name; diff --git a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp index 836dfa3..25ff103 100644 --- a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp +++ b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp @@ -49,8 +49,13 @@ VstIntPtr vst_master_callback(AEffect* effect, VstInt32 opcode, VstInt32 index, { switch (opcode) { - case audioMasterAutomate: + case audioMasterAutomate: { + auto host = ((vst2_plugin_host *) effect->user); +#if BUILD_DEBUG + spdlog::info("vst2 plugin {} automate, {} index = {}, value = {}", host->name, host->get_parameter_name(index), index, opt); +#endif return 1; + } case audioMasterVersion: return kVstVersion; // 返回插件版本号 case audioMasterWantMidi: @@ -261,3 +266,9 @@ void vst2_plugin_host::close_editor() { VstIntPtr vst2_plugin_host::dispatch(VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt) const { return effect_->dispatcher(effect_, opcode, index, value, ptr, opt); } + +std::string vst2_plugin_host::get_parameter_name(int index) const { + char buffer[256]; + dispatch(effGetParamName, index, 0, buffer); + return buffer; +} diff --git a/core/audio/plugin_host/vst2/vst2_plugin_host.h b/core/audio/plugin_host/vst2/vst2_plugin_host.h index 7b4b5b4..083b280 100644 --- a/core/audio/plugin_host/vst2/vst2_plugin_host.h +++ b/core/audio/plugin_host/vst2/vst2_plugin_host.h @@ -26,6 +26,7 @@ public: [[nodiscard]] bool has_editor() const override; void get_editor_size(uint32_t& width, uint32_t& height) const override; // [[nodiscard]] ImVec2 get_editor_size() const override; + std::string get_parameter_name(int index) const override; [[nodiscard]] std::string load_name() const override; [[nodiscard]] std::string load_vendor() const override;