新增获取插件parameter名称接口

实现获取vst2最后一次改变的parameter
This commit is contained in:
Nanako 2024-05-26 17:55:33 +08:00
parent 9b018b3363
commit 191f90de6d
4 changed files with 21 additions and 1 deletions

View File

@ -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()

View File

@ -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;

View File

@ -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;
}

View File

@ -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;