/* * Carla JSFX utils * Copyright (C) 2021 Jean Pierre Cimalando * Copyright (C) 2021-2022 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ #ifndef CARLA_JSFX_UTILS_HPP_INCLUDED #define CARLA_JSFX_UTILS_HPP_INCLUDED #include "CarlaDefines.h" #include "CarlaBackend.h" #include "CarlaUtils.hpp" #include "CarlaJuceUtils.hpp" #include "water/files/File.h" #include "water/text/String.h" #ifdef YSFX_API # error YSFX_API is not private #endif #include "ysfx/include/ysfx.h" #include CARLA_BACKEND_START_NAMESPACE // -------------------------------------------------------------------------------------------------------------------- struct CarlaJsfxLogging { static void logAll(intptr_t, const ysfx_log_level level, const char* const message) { switch (level) { case ysfx_log_info: carla_stdout("%s: %s", ysfx_log_level_string(level), message); break; case ysfx_log_warning: carla_stderr("%s: %s", ysfx_log_level_string(level), message); break; case ysfx_log_error: carla_stderr2("%s: %s", ysfx_log_level_string(level), message); break; } }; static void logErrorsOnly(intptr_t, const ysfx_log_level level, const char* const message) { switch (level) { case ysfx_log_info: break; case ysfx_log_warning: carla_stderr("%s: %s", ysfx_log_level_string(level), message); break; case ysfx_log_error: carla_stderr2("%s: %s", ysfx_log_level_string(level), message); break; } }; }; // -------------------------------------------------------------------------------------------------------------------- struct CarlaJsfxCategories { static PluginCategory getFromEffect(ysfx_t* effect) { PluginCategory category = PLUGIN_CATEGORY_OTHER; if (const uint32_t tagCount = ysfx_get_tags(effect, nullptr, 0)) { std::vector tags; tags.resize(tagCount); ysfx_get_tags(effect, tags.data(), tagCount); for (uint32_t i=0; i